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 

Why Is My Program Stuttering Instead of Playing Smoothly?

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



Joined: 12 Jun 2008
Posts: 1

PostPosted: Thu Jun 19, 2008 12:00 pm    Post subject: Why Is My Program Stuttering Instead of Playing Smoothly? Reply with quote

I am creating a program for timing speedsolves (solving Rubik's Cubes or other such puzzles fast) that, as of now, can save your times and lets you switch between different categories of solving such as One-Handed, Speed, or Blindfolded while allowing you to save an inddividual time for each category. The program was running very smoothly until, it seems, I added the feature to switch categories. Now, for example, when the timer runs it stutters instead of progressing smoothly. I have searched but I really do not have any real idea as to what I should search to find out why this is happening. Could someone help me out? The code is below.

Thanks,
dChan

Code:
System.usbDiskModeActivate ()

white = Color.new (255,255,255)
black = Color.new (0,0,0)
red = Color.new (255,0,0)
lime = Color.new (128,255,0)

fontcherl = Font.load ("cherl.ttf")
fontcherl:setPixelSizes (72,72)

fontcherl2 = Font.load ("cherl.ttf")
fontcherl2:setPixelSizes (28,28)

fontcheri = Font.load ("CHERI.ttf")
fontcheri:setPixelSizes (36,36)

fonttrashco = Font.load ("trashco.ttf")
fonttrashco:setPixelSizes (48,48)

category =  {}
category[1] = {c = "One-Handed Solve"}
category[2] = {c = "Speed Solve"}
category[3] = {c = "Blindfolded Solve"}
categorynumber = 2

categoryrecord = "ss"

counter = Timer.new ()
counter:stop ()

background = Image.createEmpty (480,272)
background:clear (white)

function timerControls ()
if categorynumber == 1 then
categoryrecord = "oh"
end

if categorynumber == 2 then
categoryrecord = "ss"
end

if categorynumber == 3 then
categoryrecord = "bld"
end

if counter:time () > 600000 then
counter:reset (0)
end

if pad:cross () then
counter:stop ()
end

if pad:square () then
counter:stop ()
counter:reset (0)
end

if pad:triangle () then
file = io.open ("record"..categoryrecord..".txt","w")
file:write (currentTime)
file:close ()
end

if pad:r () and categorynumber < 3 then
categorynumber = categorynumber + 1
end

if pad:l () and categorynumber > 1 then
categorynumber = categorynumber - 1
end

if pad:r () and pad:l () and counter:stop () then
counter:reset (0)
counter:start ()
end
end

while true do
screen:clear ()

screen:blit (0,0,background)

currentTime = counter:time () / 1000

file = io.open ("record"..categoryrecord..".txt","r")
record = file:read ("*n")
file:close ()

screen:fontPrint (fonttrashco,140,50,"cWatch",lime)
screen:fontPrint (fontcherl2,140,80,category[categorynumber].c,black)
screen:fontPrint (fontcherl,140,136,currentTime,black)
screen:fontPrint (fontcherl2,60,200,"Personal Record:",black)
screen:fontPrint (fontcheri,300,200,record,black)

pad = Controls.read ()

timerControls ()

screen.waitVblankStart ()
screen.flip ()

if pad:start () then
break
end
end


EDIT: The activation of the USB connection is just to help me revise the code faster. It has no use in the actual program. The program also does not recognize when I press a button right away. Sometimes it takes several tries before it realizes I am pressing a button.
Back to top
View user's profile Send private message Send e-mail
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