[SDL] help setting framerate??
i'm a novice programmer, and i've been working on a break out clone (VERY early stages), and i can't figure out how to get a lower framerate.....if that's the problem. the game runs at 138 fps currently, and the ball moves much too fast. if anyone has experience w/ sdl, i'd appreciate it if you would have a look at the code, and give me some suggestions. i don't have a website, so i uploaded the file in another forum. thanks a million :)
You need your game to be NOT based on fps, because it will run at different speed
on defferent computers.
you need to have a cycle which runs for as long as program runs
you also need to know how much time each cycle lasts
so let's say you have a variable "float x_cor" which is x position of the object...
then you have "float speed" which is how many PIXELS your object mover PER SECOND
you use "SDL_GetTicks()" function to find out for how much time passed from the start of the
program. Adding it all together you will get something like this
//Main part starts here
//Main part ends here
if you have any questions, ask!
thanks alot :) because i had no idea where to start....i read something about GetTicks(), and included it in the game, but didn't quite know how to use it. i'm gonna try to implement what you posted. i'll reply about how i'm doing.....thanks again :)
|All times are GMT -5. The time now is 07:04 PM.|