Submit Your Own Code

PSP Lua CodeBase : Simple Animation

Description:
This code will display a simple animation to the screen.

First it load the 5 animation images
animation1.png
animation2.png
animation3.png
animtaion4.png
animation5.png
and puts them into a table.

To change the animation speed change the numbers that the loop count goes up by.
Lower = Faster
Higher = Slower

-- EVILMANA.COM PSP LUA CODEBASE
-- www.evilmana.com/tutorials/codebase
-- Simple Animation
-- SUBMITTED BY: cwirsing

-- Load Images Into A Table
animation = {}
for a = 1, 5 do
animation[a] = Image.load("animation" ..a..".png")
end

-- Player Info
player = {}
player.x = 220
player.y = 110
player.pad = "none"


-- Set Default Image
animation1 = anim

-- Set loop count
loopCount = 0

-- Read Controls
while true do
pad = Controls.read()
screen:clear()

-- Animation Loop
if pad:cross() then
if loopCount >= 0 and loopCount < 6 then anim = animation[1]
elseif loopCount >= 6 and loopCount < 12 then anim = animation[2]
elseif loopCount >= 12 and loopCount < 18 then anim = animation[3]
elseif loopCount >= 18 and loopCount < 24 then anim = animation[4]
elseif loopCount >= 24 and loopCount < 30 then anim = animation[5] end
if loopCount + 1 >= 30 then loopCount = 0 else loopCount = loopCount + 1 end
end

-- Display Default Image
screen:blit(player.x,player.y,anim)

-- End Loop
screen.waitVblankStart()
screen.flip()
end

Back to CodeBase
 

Please welcome anthonyjee, our newest member.

Who's Online:

Total Members: 522
Total Posts: 13085
Total Topics: 1515
Total Categories: 7
Total Boards: 42

Recent Posts:

Re: Hello every body... by DeniseVera
Need help please by Robbynator
Re: Hello every body... by horvathann
Re: background criminal record check by backgroundchecker
background criminal record check by backgroundchecker
Intro to Perl Part 2: What are Scalars? & Examples by Chi Kitory
Intro to Perl Part 1 About Perl and Hello World by Chi Kitory
Re: Trying To Get Rid of the Spammers by Charlie


Copyright © 2006-2009 www.EvilMana.com All rights reserved.
EvilMana Logo by emcp and Charlie