Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-25-2003, 02:52 AM   #1
Registered: May 2003
Location: US
Distribution: Ubuntu
Posts: 30

Rep: Reputation: 15
[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
Old 11-25-2003, 05:26 AM   #2
Registered: Oct 2003
Location: New Zealand, Wellington
Distribution: Red Hat 9, Gentoo 1.4, Vector 4.0
Posts: 74

Rep: Reputation: 15
Get Ticks!

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

double Stime=0;

double frame_time=(SDL_GetTicks()-Stime)/1000.0;

//Main part starts here
//Main part ends here


if you have any questions, ask!
Old 11-25-2003, 11:45 AM   #3
Registered: May 2003
Location: US
Distribution: Ubuntu
Posts: 30

Original Poster
Rep: Reputation: 15
Thumbs up

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to program an SDL application but cannot find the SDL.h file:SuSE 9.2&KDevelop pujolasdf Linux - Newbie 4 03-13-2005 08:50 AM
Slow framerate in 3d i286 Linux - Games 10 01-11-2004 01:04 PM
Framerate Issue Bigun Linux - General 2 09-21-2003 09:39 AM
xine framerate JesusCow Linux - Software 3 08-22-2003 01:09 PM
Gears framerate RecoilUK Linux - General 1 08-30-2001 01:31 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:28 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration