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 

Platform Game Help Please

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



Joined: 07 Jan 2006
Posts: 8

PostPosted: Sat Jan 07, 2006 12:53 pm    Post subject: Platform Game Help Please Reply with quote

Hi All,

I need some help with collision, I have it working (sort of) but when the background scrolls the image moves, but not the collision stuff(which should be moving) , its hard to explain, its like the collision background is still in the same place, yet its moving

http://www.freewebs.com/shifthouse/MegaMan.zip
Back to top
View user's profile Send private message
AkumaATR



Joined: 30 Oct 2005
Posts: 11

PostPosted: Sat Jan 07, 2006 1:13 pm    Post subject: Hey Reply with quote

I gave a theory up on this in the IRC channel you were in earlier; maybe you didn't see my response.

From playing with your demo and taking a brief look at your code, I think your collision function is checking against the background image data as it is in memory (untransformed aka unmoved). You need to perform the collision check between Mega Man and a surface that has the transformed background data (blit the background transformed ("moved") to another surface and perform collision on that extra surface, perhaps). You could also just compare directly to screen pixel data instead of using an extra surface. Also you might consider having a different means of defining your levels at a later time as I'm not sure how far the pixel checking can be taken (although I've used that method before in shooter type demos)...

good luck
Back to top
View user's profile Send private message
soulphalanx



Joined: 22 Aug 2005
Posts: 35

PostPosted: Sat Jan 07, 2006 1:34 pm    Post subject: Reply with quote

I have a released something that you could look at http://soulphalanx.psplua.com/NG%200.0.2.zip

the game looks at a separate collision map to determine where the ground is
not to mention scrolling
Back to top
View user's profile Send private message
shifty_bill



Joined: 07 Jan 2006
Posts: 8

PostPosted: Sat Jan 07, 2006 1:52 pm    Post subject: Reply with quote

thanks for your help yet i still cant get it to work :(

how do i blit the (moved) background to another surface?
Back to top
View user's profile Send private message
soulphalanx



Joined: 22 Aug 2005
Posts: 35

PostPosted: Sat Jan 07, 2006 1:54 pm    Post subject: Reply with quote

i cant seem to download your program

could you post some code?
Back to top
View user's profile Send private message
shifty_bill



Joined: 07 Jan 2006
Posts: 8

PostPosted: Sat Jan 07, 2006 3:29 pm    Post subject: Reply with quote

thats strange . . . ok here it is
Code:

System.usbDiskModeActivate()
white = Color.new(255, 255, 255)
canjump = true
canplay = false
canmoveleft = true
canmoveright = true
grounded = false
ground = 1
playerdir = left
jump = "down"
jumptimer = 0
move = false
moveleft = false
moveright = false
playerwidth = 40
playerheight = 43
mmrunright = {}
for i=1, 14 do
mmrunright[i] = Image.load("mmsprites/runright/runright" .. i .. ".png")
end
mmrunleft = {}
for i=1, 14 do
mmrunleft[i] = Image.load("mmsprites/runleft/runleft" .. i .. ".png")
end
runpicnumber = 1

mmstandright = {}
for i=1, 6 do
mmstandright[i] = Image.load("mmsprites/standright/standright" .. i .. ".png")
end
mmstandleft = {}
for i=1, 6 do
mmstandleft[i] = Image.load("mmsprites/standleft/standleft" .. i .. ".png")
end
startanimation = {}
for i=1, 26 do
startanimation[i] = Image.load("mmsprites/start/start" .. i .. ".png")
end
mmjumpleft = {}
for i= 1, 1 do
mmjumpleft[i] = Image.load("mmsprites/jump/jumpleft" .. i .. ".png")
end
mmjumpright = {}
for i= 1, 1 do
mmjumpright[i] = Image.load("mmsprites/jump/jumpright" .. i .. ".png")
end
collisionback = Image.load("mmsprites/backgrounds/back1.png")
background = Image.load("mmsprites/backgrounds/background1.png")

collisionback2 = Image.load("mmsprites/backgrounds/back2.png")
background2 = Image.load("mmsprites/backgrounds/background2.png")
backx = 0
backx2 = 480
collisioncolor = Color.new(112,112,112)
image = Image.createEmpty(1, 1)
collisionx = playerx
collisiony = playery

startanimationpic = 1
starttimer = 0
standpicnumber = 1
picnumer = 1
stance = mmstandright
moveleft = false
moveright = false
lastdir = "right"
playerx = 100
playery = 200


timer = 0

function input()  ---------------------controls
   pad = Controls.read()
if canplay == true then
   if pad:left() == true and canmoveleft == true then
      moveleft = true
      moveright = false
      lastdir = "left"
   else
      moveleft = false
   end
   if pad:right() == true and canmoveright == true then
      moveright = true
      moveleft = false
      lastdir = "right"
   else
      moveright = false
   end
end   

   if moveleft == true and moveright == false then
     stance = mmrunleft
      playerx = playerx - 2
   elseif moveright == true and moveleft == false then
      stance = mmrunright
      playerx = playerx + 2
   end

   if (moveleft == false and moveright == false and lastdir == "left") then
         stance = mmstandleft
      elseif (moveright == false and moveleft == false and lastdir == "right") then
         stance = mmstandright
      end

   if (pad:cross() == true and grounded == true and jump == false) then
      jump = "up"
      grounded = false
   end
   if jump == "up" then
      jumptimer = jumptimer + 1
      if jumptimer < 24 then
         playery = playery - 4
      end
      if jumptimer > 24 then
         jump = "down"
         jumptimer = 0
      end
   end
   if grounded == false and lastdir == "left" then
      stance = mmjumpleft
   elseif grounded == false and lastdir == "right" then
      stance = mmjumpright
   end
   if stance == mmstandright then
      picnumber = standpicnumber
   elseif stance == mmstandleft then
      picnumber = standpicnumber
   elseif stance == mmrunright then
      picnumber = runpicnumber
   elseif stance == mmrunleft then
      picnumber = runpicnumber
   elseif stance == mmjumpleft then
      picnumber = 1
   elseif stance == mmjumpright then
      picnumber = 1
   end
end 
 
function gravity() --------------------------------------gravity
   if grounded == false and jump == "up" then
      playery = playery - 2
   elseif grounded == false and jump == "down" then
      playery = playery + 3
   end
end

function collision()  -----------------------------------collision

   if (collisionback:pixel(playerx , playery + playerheight - 3) == collisioncolor) then
      jump = false
      grounded = true
      jumptimer = 0
   else
      grounded = false
      jumptimer = jumptimer + 1
      if jumptimer > 20 then
         jump = "down"
      end
   end

   if (collisionback:pixel(playerx + playerwidth - 4, playery + 25) == collisioncolor) then
      canmoveright = false
      canmoveleft = true
   else
      canmoveright = true
   end
   if (collisionback:pixel(playerx - 4, playery + 25) == collisioncolor) then
      canmoveright = true
      canmoveleft = false
   else
      canmoveleft = true
   end
end

function time()  ---------------------------------------timers
   timer = timer + 1
   if timer >3 then
      timer = 0
      if canplay == false then
      startanimationpic = startanimationpic + 1
         if startanimationpic >= 26 then
            startanimationpic = 26
            starttimer = starttimer + 1
            if starttimer >=10 then
               canplay = true
            end
         end
      end
      runpicnumber = runpicnumber + 1
         if runpicnumber >= 14 then
            runpicnumber = 1
         end
      standpicnumber = standpicnumber + 1
      if standpicnumber >= 6 then
         standpicnumber = 1
         end
      end
   
end   

function scroll()  -----------------------------scolling the backgroiund image


   if playerx >= 300 and moveright == true and canmoveright == true then
      playerx = 299
      backx = backx - 2
      backx2 = backx2 - 2
   end
   if playerx <= 120 and moveleft == true and canmoveleft == true then
      playerx = 121
      backx = backx + 2
      backx2 = backx2 + 2
   end
end
while true do

   gravity()
   collision()
   input()
   time()
   scroll()
   if pad:start() then
         break
   end

   if grounded == true then
      ground = 1
   else
      ground = 0
   end

   
  --gravity()
screen:blit(backx,0, collisionback, false)
--screen:blit(backx,0, background, false)
screen:blit(backx2,0,collisionback, false)
screen:print(0,0, jumptimer, collisioncolor)
   if canplay == false then
      screen:blit(playerx - 16, playery - 9, startanimation[startanimationpic], true)
   else
   screen:blit(playerx, playery, stance[picnumber], true)
   end
--screen:fontPrint(monoSpaced, 10, 214, "MEGA MAN", white)
--screen:fontPrint(monoSpaced, 20, 234, lastdir, white)
   

screen:waitVblankStart()
screen:flip()
screen:clear()
end



i think if u copy then paste the link into a new browser window it will download
Back to top
View user's profile Send private message
illfoundedmind



Joined: 24 Nov 2005
Posts: 22
Location: N/A

PostPosted: Mon Jan 09, 2006 2:41 am    Post subject: Reply with quote

I downloaded your app and went through the code. The basic movement functions look good. I was going through the same collision problem for a RPG I'm working on with a group of people. I ended up scrapping my original way (which is much like yours setting each collusion line by hand) and moving on to doing a array that get the tileset used in that area and see if that is a passable object or not. Maybe that will help you out? good luck

BTW did you do the MegaMan sprites by hand?
_________________
illfoundedmind Production Studio
Back to top
View user's profile Send private message Visit poster's website
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