Page 1 of 1

Finally Starting Shooter For My Final In Class...

Posted: Sat Mar 20, 2010 7:51 pm
by davidthefat
:roll: I remember making a thread long time ago that I needed to start my final for my AP class... but never got started.

I just DLed Code::Blocks and got rid of DevC++ today, and I got it to set up SDL right and blah blah... Now I drew up the Class lay out thing and I am ready to get started.

Image

I was thinking of doing destructible environment similar to Space invaders, like how they did it with the shields.

The game will be a top down view shooter similar to endless war (http://www.maxgames.com/game/endless-war-4.html) but not as hectic and bigger maps and ect.

So far I think I have to focus on formatting the classes right, since last attempts failed and had to reformat. I think the draw class will have a constructor that loads the sprite sheets. So a new draw object has to be initialized for the enemies and players and map. Would you say that its the wisest choice? or have the individual classes have their own sprite stored in as an object and have the draw function take in the coordinates and the SDL_Surface as arguments? I personally don't like functions taking in more than 3 arguments though...

Also how would I go about rotating the player in 360 degrees? I was thinking of making a sprite for every 22 degree angles and getting the slope of the mouse and the player and getting the tan of that, but that will use up more memory. I won't be venturing into OpenGL, I tried, I got lost...

Re: Finally Starting Shooter For My Final In Class...

Posted: Sun Mar 21, 2010 12:25 am
by davidthefat
Image


Hopefully you can understand why the red is bad... Well If I get the slope of a coordinate with both negative x and y coordinates, it will come up as a positive, which will get a false reading with the inverse tangent function... So I will have to flip it if the y coordinate is negative, less hassle than checking the x axis

Re: Finally Starting Shooter For My Final In Class...

Posted: Sun Mar 21, 2010 12:28 am
by quickshot14
You got a nice plan here and a great project, yes negtives when dealing with anything collesion or calculation wise is always a problem. Most just go around it, (as with tilescrolling for example) sometimes you have to deal with it, particluarly when dealing with something such as pyshics or just 3d space obviously. Anywayz looks like a great plan and very neat stuff, best of luck of you with it and keep us informed! Finshed final or not anywork you do only can expand your knowledge of gaming deign/programming and well thats a good thing imo :)

Re: Finally Starting Shooter For My Final In Class...

Posted: Sun Mar 21, 2010 12:44 am
by davidthefat
A quick write up of the degree function

Code: Select all

double GetDeg(int PlayerX, int PlayerY, int MouseX, int MouseY)
{

//Get the Slope of the line
double Slope = (PlayerY - MouseY) / (PlayerX - MouseX);

if (MouseY > PlayerY)
{
return atan(Slope);
}

else if (MouseY < PlayerY)
{
return 360 - atan(Slope);
}

else if (MouseY == PlayerY && MouseX > PlayerX)
{
return 0;
}

else if (MouseY > PlayerY && MouseX == PlayerX)
{
return 90;
}

else if (MouseY < PlayerY && MouseX == PlayerX)
{
return 270;
}

else return 180

}

Fixed my code... Remember, just pulling it out of my ass ATM

Re: Finally Starting Shooter For My Final In Class...

Posted: Sun Mar 21, 2010 8:36 pm
by davidthefat
What is a better way to draw objects into the screen? The draw class has a constructor that takes in a file and loads the image on a SDL_Surface in the class or have a function that takes in an array of SDL_Surfaces and the index of the image and draw those on the screen? So the Player and Enemy Classes both have their own array of images

Re: Finally Starting Shooter For My Final In Class...

Posted: Thu Mar 25, 2010 5:54 pm
by RyanPridgeon
It's best not to have each entity hold their own set of SDL_Surface's, because then when you have loads of enemies you'll be wasting loads of memory on duplicate images. You need a design where each actor can share images to save RAM :)