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 

Problems with timers

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
F.J. Sánchez



Joined: 06 Nov 2005
Posts: 10

PostPosted: Thu Dec 15, 2005 9:18 am    Post subject: Problems with timers Reply with quote

Hi everybody,
I'm trying to do an animated character using a tile set. I'm doing this with timers, but it's no very accurate, this code for example sometimes works, sometimes doesn't, aprox 2 of 10 times works and 8 doesn't. You can try this if you don't believe me!

Code:

System.usbDiskModeActivate()

sprite = 1      -- First sprite to show
dir = 1         -- Direction of the animation effect
delay = Timer.new()

-- Loading of images
fondo = Image.load("fondo.png");
sprites = Image.load("sprites1.png");

while true do
        screen:blit(0, 0, fondo, 0, 0, fondo:width(), fondo:height(), false)

-- This part must update the sprite to be displayed each 200ms
-- but I only can 600ms

time1 = math.floor( delay:start()/100)

        if time1  == 5 then                -- Change 5 to 6 and always will work
                if dir == 1 then
                        if sprite == 5 then
                                dir = 0
                                sprite = 4
                        else sprite = sprite + 1
                        end
                else
                        if sprite == 2 then
                                dir = 1
                                sprite = 3
                        else sprite = sprite - 1
                        end
                end
        delay:reset()
        end

        screen:print(20,10,fuck)
        posX = 1*sprite + 37*sprite
        screen:blit(20, 210, sprites, posX, 0, 37, 48, true)
        screen.waitVblankStart()
        screen.flip()

        pad = Controls.read()
        if pad:start() then
                break
        end
end


Can any one help me?
_________________
Hack your mind
Okupa tu mente.
Back to top
View user's profile Send private message
dkla



Joined: 17 Oct 2005
Posts: 21

PostPosted: Thu Dec 15, 2005 11:27 am    Post subject: Reply with quote

Are you using LuaPlayer 0.15? Earlier versions had a problem displaying timers, but it has been fixed now. Give that a try.
Back to top
View user's profile Send private message Yahoo Messenger
F.J. Sánchez



Joined: 06 Nov 2005
Posts: 10

PostPosted: Fri Dec 16, 2005 6:00 am    Post subject: I know this Reply with quote

But I'm using lastest version, 0.15. You can try it ;)
_________________
Hack your mind
Okupa tu mente.
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