[First SDL game] Care to give some feedback ?

Started by
0 comments, last by sednihp 11 years, 10 months ago
Hello there.After a lot of brainstorming and some unslept nights, I finally managed to make a game that uses a multimedia library biggrin.png .
The gameplay is very simple and straight forward : all the player has to do is fill the screen with circles, untill the total covered area passes a limit.


This one is the third project.The first project is about testing SDL, the second one is the "brute " game and the third one has menus in it .
The "brute" game was actually easy to make, and I finished it quickly.The hard part was implementing it as a FSM, because I wanted to add menus and stuff.It's not final yet . I tried to keep the code as clean as I can.
You have to press "Enter" during menus.
I want to add a time limit for each level , but I have no idea how to do that .

Anyway, opinions ?
Advertisement
To set a time limit, whenever the main level starts, assign SDL_GetTicks() to a variable, then at the end of each frame, check if the current time minus the start time is bigger than the time limit. i.e.

[source lang="cpp"]const int levelTimeLimit = 30000 //30s time limit
int startTime = SDL_GetTicks()

while(game is running)
{
//insert game loop code here

if(SDL_GetTicks() - startTime > levelTimeLimit) //check the current time vs the time limit
{
//exit level code goes here
}
}[/source]


The game seemed to work perfectly well from my quick trial, I like the idea behind it and the animations were pretty nice, but trying to read the code gave me a headache. Try to format your code nicely with proper indenting (like my example code above) to make it easier to read and understand for others. You might want to look into object oriented code as well, it'll make things easier for you in the long run when your games get bigger. If you want an idea I've got a few SDL games and their sourcecode at the link in my signature.

This topic is closed to new replies.

Advertisement