My first game.

Started by
5 comments, last by RobN 17 years, 5 months ago
Here is my first attempt at game programming, written in C++ and SDL tell me what you think !: http://www.libsdl.org/games.php?order=name&category=-1&completed=0&os=-1&match_name=DART&perpage=50
Advertisement
I tried the game out. It's pretty hard to stay away from the UFO, is it possible to avoid it at all? :D
Also, the movement gets a little bit anoying when you press two direction buttons at the same time and it doesn't change direction. I like the concept though. :)
A good first try! Congratulations. I like the fact that the background was different every game. I had some trouble controlling the frog though: you can't have two arrow keys down at the same time. If you post how you track the keys, and the direction of the frog, I'm sure I can help you, though. I think there should be a delay, or a wait for a key press before you respawn, though. Altogether, pretty good for first try.
Yea i realised the turning is buggy and doesnt react well to quick turns which is pretty elemental to the game.

Heres part of the code for changing direction:
The direction property is just used for showing the appropiate sprite.
Velocity is added onto the objects current x,y posistion.
Quote:
case SDLK_LEFT:
frog.stopped = false;
frog.direction = frog.Left;
frog.velocityx = -8;
frog.velocityy = 0;
break;

case SDLK_RIGHT:
frog.stopped = false;
frog.direction = frog.Right;
frog.velocityx = +8;
frog.velocityy = 0;
break;


Heres the code for stopping the frog:
Quote:
case SDL_KEYUP:
{

switch(event.key.keysym.sym)
{


case SDLK_UP:
frog.velocityy = 0;
break;

case SDLK_DOWN:
frog.velocityy = 0;
break;
case SDLK_LEFT:
frog.velocityx = 0;
break;
case SDLK_RIGHT:
frog.velocityx = 0;
break;


}


I think the buggy movement is caused when opposite arrow keys are pressed cancelling each other out and setting velocity to 0 ? any ideas how to get round this ?

Ok i fixed the movement bug!
Ive updated the link to the fixed version.
try it now !
Quote:Original post by RobN
Ok i fixed the movement bug!
Ive updated the link to the fixed version.
try it now !


Nice game.

One thing you may want to consider are the little clouds or whatever that cross the screen, when you create them you put them at x = 0, so I can see them being created.

If you created them a x = -imageWidth, they would drift on screen instead, I think this would look better.

Good work.
Another update, updated it so the clouds drift on the screen as rip-off recommended and more significantly modified the code so it doesnt use 100% CPU !

This topic is closed to new replies.

Advertisement