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 

Sidescroller Help

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



Joined: 05 Oct 2005
Posts: 14

PostPosted: Wed Nov 23, 2005 11:53 pm    Post subject: Sidescroller Help Reply with quote

Hi
I Am making my first (Well kinda second) Lua game.
It is my first Sidescroller though and i needed to know
how would i get him to hit barrier's and jump on them including
image's ect?

Sorry but this is my code

Code:
x = 2
y = 195
leftlimit = 0
rightlimit = 450
uplimit = 65
downlimit = 244
jumping2 = false
sprite = {}

sprite[1] = Image.load("Mario/sprite.png")
sprite[2] = Image.load("Mario/sprite2.png")
sprite[3] = Image.load("Mario/sprite3.png")
sprite[4] = Image.load("Mario/sprite2-2.png")
sprite[5] = Image.load("Mario/sprite3-3.png")
sprite[6] = Image.load("Mario/sprite-1.png")
sprite[7] = Image.load("Mario/sprite4.png")
sprite[8] = Image.load("Mario/sprite4-4.png")
sprite[9] = Image.load("Mario/sprite6-6.png")
Spriteimg=sprite[1]

anim = 1
animTimer = 0
LastDirection = sprite[9]


function walkRight()
LastDirection=sprite[1]
animTimer=animTimer+1
   if animTimer>=1 and animTimer<=4 then Spriteimg=sprite[2]
   elseif animTimer>=5 and animTimer<=8 then Spriteimg=sprite[3]
   end
   if animTimer>=9 then animTimer=0 end
end

function walkLeft()
LastDirection=sprite[6]
animTimer=animTimer+1
   if animTimer>=1 and animTimer<=4 then Spriteimg=sprite[4]
   elseif animTimer>=5 and animTimer<=8 then Spriteimg=sprite[5]
   end
   if animTimer>=9 then animTimer=0 end
end

while true do
   screen:blit(0, 0, background, 0, 0, background:width(), background:height(), false)
   screen:blit(415, 190, Kart)

   pad = Controls.read()
   if pad:right() then walkRight() x=x+2 Spriteimg=Spriteimg
   elseif pad:left() then walkLeft() x=x-2 Spriteimg=Spriteimg
   else Spriteimg=LastDirection

   if pad:cross() then
   if jumping2 == false then
   jumping = true
   end
end
if jumping == true then
   if jumping2 == true then
      jumping = false
   end
   y = y - 4
   if y < 130 then
      jumping2 = true
      jumping = false
   end
end
if jumping2 == true then
   y = y + 4
   if y > 197 then
      y = 197
      jumping2 = false
   end
end
end



   if x<=leftlimit then x=leftlimit
   elseif x>=rightlimit then x=rightlimit end

  screen:blit(x, y, Spriteimg)
  screen.waitVblankStart()
   screen.flip()
end

yeah it's the worst code EVER but i did it withing a few min's lol.
Also when my player trie's to jump he can run in the sky?
lol Well it is my first try and it was pretty fast....
I Guess i could start from scratch but i dont have the time yet.

EDIT:
I Didnt include all my code sorry about that but it does'nt matter.
_________________
Currently Working On
PSP Chao Garden - Lua
Next Project might be
Dragon Ball P
or Metroid Prime
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