Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Challenge: 2D Tank

Name: Anonymous 2010-05-14 15:43

The Challenge:
|---->Program a 2d tank application in the language of your choice that adheres to the following:

#-The tank must rotate using the left and right directional keys.
#-The tank must loosely resemble a tank.
#-The tank must move forward or backward respectively from the direction it is facing using the up and down directional keys.
#-Pressing spacebar must fire a 'shot' in the direction the tank is facing.
#-The perspective of the user must be fixed and facing down at the tank.
#-The tank, shot, and ground must each have their own color. (all shots may have the same color)


<------You have 24 hours!------>
GET TO WORK!

Name: Anonymous 2010-05-21 12:13

>>153
to run on *nix :

--- original.cpp    2010-05-21 18:06:19.913591576 +0200
+++ linux.cpp    2010-05-21 18:11:20.216878465 +0200
@@ -1,9 +1,9 @@
+/* g++ -lSDL -lGL tank.cpp && ./a.out */
 #include <SDL/SDL.h>
-#include <OpenGL/gl.h>
+#include <GL/gl.h>
 #include <iostream>
 #include <list>
 #include <math.h>
-#include "Sound.h"
 
 #define square(x) ((x) * (x))
 
@@ -143,12 +143,9 @@
 
 struct Tank : Sprite{
     int fireAngle; // 0,1, or 2
-    int soundChannel;
     void ShootLaser() {
         float laserAngle = ((rand() % 41) - 20.0) / 200.0 + angle;
         gSprites.push_back(new Laser(player,Global(0,.7),laserAngle));
-        if(soundChannel == -1 || !IsPlaying(soundChannel));
-            soundChannel = PlaySound("laser2");
         }
     virtual void Draw(){
         glBegin(GL_TRIANGLES);
@@ -163,7 +160,7 @@
         if(sprite->type == kObstacle) UndoMove();
         }
     Tank(){
-        size = 7; speed = 40; type = kTank, soundChannel = -1;
+        size = 7; speed = 40; type = kTank;
         }
     };
 
@@ -197,14 +194,12 @@
 void DetectCollisions();
 void DrawSprites();
 
-int SDL_main(int argc,char* argv[])
+int main(int argc,char* argv[])
 {
 SDL_Surface *screen;
 SDL_Event event;
 
 SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
-InitializeSound();
-LoadSounds();
 
 screen = SDL_SetVideoMode(800, 600, 32, SDL_OPENGL/* | SDL_FULLSCREEN*/);
 glViewport(0, 0, screen->w, screen->h);

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List