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 jramada, our newest member.

Who's Online: 3 Guests, 1 User
yaustar

Total Members: 555
Total Posts: 13059
Total Topics: 1480
Total Categories: 8
Total Boards: 35

Recent Posts:

Re: PGELua Help - need term for a special rotation fix (mathematical issue) by yaustar
Re: Lua Loader? by Buddy4point0
Re: Lua Loader? by osgeld
Re: Lua Loader? by acer5050
Re: Lua Loader? by bumuckl
Re: Lua Loader? by acer5050
Re: Lua Loader? by bumuckl
Lua Loader? by acer5050


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