forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

lack of control in how often to redraw screen...?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
fattymc03



Joined: 11 Feb 2006
Posts: 18

PostPosted: Mon Feb 13, 2006 11:21 pm    Post subject: lack of control in how often to redraw screen...? Reply with quote

In my game, i'm moving the background (like a scrolling background 2d game). In my main WHILE DO loop, I just shift the background 1 pixel over. I have no timer when to do this, so it just does it everytime it goes through the loop. How can I actually control the speed and make it move faster, because right now, its moving at 1 pixel per loop pass and it doesnt really move fast. If i make it move more than 1 pixel it would look jumpy. I just find it strange that I cannot move the background faster (but still smoothly). Any ideas.
Back to top
View user's profile Send private message
KawaGeo



Joined: 27 Aug 2005
Posts: 191
Location: Calif Mountains

PostPosted: Tue Feb 14, 2006 2:17 am    Post subject: Reply with quote

Even 2 pixels, still jumpy to naked eyes??

Maybe a better idea... move one pixel during even loop and two pixels during odd loop.
_________________
Geo Massar
Retired Engineer
Back to top
View user's profile Send private message Send e-mail
fattymc03



Joined: 11 Feb 2006
Posts: 18

PostPosted: Tue Feb 14, 2006 2:32 am    Post subject: Reply with quote

I guess your right, its not noticable. I guess the real issue is the background isnt moving in a separate thread and i'm afraid that once there is more code and calculations within that loop, it will move the background at a slower speed. It's like the speed of the background moving is based on how much processing is being done in the loop. Or am I wrong..?
Back to top
View user's profile Send private message
KawaGeo



Joined: 27 Aug 2005
Posts: 191
Location: Calif Mountains

PostPosted: Tue Feb 14, 2006 2:51 am    Post subject: Reply with quote

Good question, indeed. Others who might have experienced with background moving would answer better.

Suggest using a timer to time the amout of time required to move the background.
_________________
Geo Massar
Retired Engineer
Back to top
View user's profile Send private message Send e-mail
fattymc03



Joined: 11 Feb 2006
Posts: 18

PostPosted: Tue Feb 14, 2006 3:39 am    Post subject: Reply with quote

Yeah, I tried a timer, but that would only be used if I wanted it to move slower. Like right now, there is no timer and it just moves every time through the loop -- so thats like the maximum speed it moves (by moving 1 pixel) in the current loop. So adding a timer would only be useful if I wanted to slow it down.
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Tue Feb 14, 2006 4:26 am    Post subject: Reply with quote

are you using a backbuffer?

greets
lumo
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
fattymc03



Joined: 11 Feb 2006
Posts: 18

PostPosted: Tue Feb 14, 2006 5:29 am    Post subject: Reply with quote

doesn't it automatically draw to the back buffer (with screen:blit()) until you say screen:flip()?
Back to top
View user's profile Send private message
liquidjin



Joined: 19 Feb 2006
Posts: 12

PostPosted: Sun Feb 19, 2006 6:03 pm    Post subject: Reply with quote

fattymc03 wrote:
doesn't it automatically draw to the back buffer (with screen:blit()) until you say screen:flip()?



The answer to your question is yes.

However, check out the last section of the tutorial on the Wiki. You want to blit smaller images onto a larger offscreen image and then blit that larger image to the screen to preserve the native framerate.
Back to top
View user's profile Send private message
fattymc03



Joined: 11 Feb 2006
Posts: 18

PostPosted: Mon Feb 20, 2006 2:13 am    Post subject: Reply with quote

thank you! is there a way to tell at what frame rate my program is running at?
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Mon Feb 20, 2006 2:18 am    Post subject: Reply with quote

i could support a FPS function, but i am not able to compile luaplayer...
freetype won't install correct.

let me know if someone is able then ill send the function to add

greets
lumo
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Mon Feb 20, 2006 2:56 am    Post subject: Reply with quote

ok, i found the bug, and solved it.
next problem is that there seems to be an 'mistake' (guess it is one as the source of luaplayer on svn does not compile without beeing modyfied.)

so i had to remove the SIO stuff (sorry)
i added the FPS functions (did not test em!!!)

just call system.initFPS() when you start your script
then call system.getFPS() when you want the current FPS value.
(usually every iteration)

here is the download for luaplayer with FPS:
download here

greets
lumo
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
liquidjin



Joined: 19 Feb 2006
Posts: 12

PostPosted: Mon Feb 20, 2006 1:18 pm    Post subject: Reply with quote

fattymc03 wrote:
thank you! is there a way to tell at what frame rate my program is running at?


I can't give you exact code, because I'm not too familiar with working on the PSP yet. However in the beginning of your main loop you would want to do the following
{
- if FPS counter >= 10 (to minimize spiking only check every 10 frames)
-check difference between oldtime (milliseconds) and newly acquired time(milliseconds)
- FPS = 10000/difference(milliseconds)
- set FPS counter = 0
END
- if FPS counter = 0
- oldtime = current time (milliseconds)
END
-increment FPS counter

... your code ...
}

Hope this helps,

LiquidJin
Back to top
View user's profile Send private message
fattymc03



Joined: 11 Feb 2006
Posts: 18

PostPosted: Tue Feb 21, 2006 1:35 am    Post subject: Reply with quote

thanks for all the help on this subject, everything has been helpful.. i do have a follup question to my original. it's hard for me to explain this but i'll try..

So, I'm trying to make a 2d side scrolling plane shooter game. In the main loop, it redraws the screen every pass through with updated positions of objects on the screen. The issue comes with how to show different speeds of different objects. If I want to shoot a straight bullet and make it look like it's traveling faster, the only way I could figure was to make it move in the X direction more than 1, so if I added 5 every pass through the loop it would move faster. That's fine. But the issue comes if, for example I wanted to make a bullet travel in an arc path. If I draw it at every X point, it will travel along that path fine, but it would be slow. If I try and speed it up and use the same method as mentioned before, it doesn't really follow the path because it would be jumping to far into the path (like at X = 1, X = 6, X = 11, etc) so it would look jumpy and not a smooth path. So what I really want to be able to do is make it draw that faster, but it doesnt seem like that is even possible because I'm already drawing to the screen at the max speed it seems if I don't even have a timer and I'm redrawing every time through the loop. Am I doing something wrong or is this a limitation w/o having multiple threads. Please help. Thanks.!
Back to top
View user's profile Send private message
liquidjin



Joined: 19 Feb 2006
Posts: 12

PostPosted: Tue Feb 21, 2006 4:10 am    Post subject: Reply with quote

You're on the right track. Speed is just a measure of distance/time. So if you want to make something move faster than another object, you would increase the distance it moves in the same time period.

However, when you are dealing with arcs I would advise you to use parametric equations to find your exact coordinates. Do a search for these. This should solve your problem when it comes to the object moving off the path and causing jumps.

fattymc03 wrote:
thanks for all the help on this subject, everything has been helpful.. i do have a follup question to my original. it's hard for me to explain this but i'll try..

So, I'm trying to make a 2d side scrolling plane shooter game. In the main loop, it redraws the screen every pass through with updated positions of objects on the screen. The issue comes with how to show different speeds of different objects. If I want to shoot a straight bullet and make it look like it's traveling faster, the only way I could figure was to make it move in the X direction more than 1, so if I added 5 every pass through the loop it would move faster. That's fine. But the issue comes if, for example I wanted to make a bullet travel in an arc path. If I draw it at every X point, it will travel along that path fine, but it would be slow. If I try and speed it up and use the same method as mentioned before, it doesn't really follow the path because it would be jumping to far into the path (like at X = 1, X = 6, X = 11, etc) so it would look jumpy and not a smooth path. So what I really want to be able to do is make it draw that faster, but it doesnt seem like that is even possible because I'm already drawing to the screen at the max speed it seems if I don't even have a timer and I'm redrawing every time through the loop. Am I doing something wrong or is this a limitation w/o having multiple threads. Please help. Thanks.!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group