Jump to content

Photo

Help with collision detection with pfscroll


3 replies to this topic

#1 Captain Spazer OFFLINE  

Captain Spazer

    Chopper Commander

  • 110 posts

Posted Thu Jan 24, 2019 10:42 AM

Im experimenting with a platformer with a 4 way scrolling level, i got collision detection working well left and right, and I can do collision for hitting a roof, but not floors, whatever I do, when touching the floor the player zips along the ground. Is there a simple solution I'm not seeing?

 

the idea is you got a helicopter on your back, holding down the firebutton makes you fly, releasing it makes you fall down

 rem Generated 24-01-2019 14:19:54 by Visual bB Version 1.0.0.568
 rem **********************************
 rem *<filename>                      *
 rem *<description>                   *
 rem *<author>                        *
 rem *<contact info>                  *
 rem *<license>                       *
 rem **********************************


 player0y = 79
 player0x = 50



 playfield:
 ................................
 ................................
 X...XXXXXXXXXXXXXXXXXXXXXXXXXXXX
 ................................
 ................................
 ................................
 ................................
 ................................
 .....................X..........
 ....................XX..........
 XXXXXXXXXXXXXXXXXX..XXXXXXXXXXXX
end






main
 COLUPF = $0E
 COLUP0 = $0E


 player0:
 %00001100
 %00001000
 %00001000
 %00111100
 %00111000
 %00100110
 %00100110
 %01110000
end




 drawscreen

 if b = 0 && collision(player0,playfield) then pfscroll left
 if b = 1 && collision(player0,playfield) then pfscroll right

 if joy0left then pfscroll right : b = 0
 if joy0right then pfscroll left : b = 1

 if joy0fire then pfscroll down

 if !joy0fire then pfscroll up

 if collision(player0,playfield) then pfscroll down

 goto main




#2 Lewis2907 ONLINE  

Lewis2907

    Moonsweeper

  • 318 posts
  • Location:Senatobia, MS

Posted Thu Jan 24, 2019 5:08 PM

CPT Spazer,

This may help.

http://atariage.com/...ata-want-4-way/

#3 Lewis2907 ONLINE  

Lewis2907

    Moonsweeper

  • 318 posts
  • Location:Senatobia, MS

Posted Thu Jan 24, 2019 5:11 PM

I forgot to say I'm interested in what you come up with also, thanks.

#4 Captain Spazer OFFLINE  

Captain Spazer

    Chopper Commander

  • Topic Starter
  • 110 posts

Posted Fri Jan 25, 2019 7:09 AM

Thank you, very interesting. I managed to get it working better, you no longer slide all over the place. Your demo is very helpful.

 

edits made:

 rem Generated 25-01-2019 13:47:00 by Visual bB Version 1.0.0.568
 rem **********************************
 rem *<filename>                      *
 rem *<description>                   *
 rem *<author>                        *
 rem *<contact info>                  *
 rem *<license>                       *
 rem **********************************

 player0x = 50 : player0y = 50


 playfield:
 ................................
 ................................
 ..........XXX...................
 ...........X....................
 ................................
 ......................XXXXXXX...
 .......................XX.XX....
 ......XXXXXXX...........X.......
 .......X.XXX....................
 ..........X.....................
 ................................
end






main
 COLUP0 = $0E

 COLUPF = $0E




  if d = 10 then player0:
 %00011000
 %00010000
 %00010000
 %01111000
 %01110000
 %00011000
 %00100000
 %00011000
end

 if d = 20 then player0:
 %01001100
 %01111000
 %00010000
 %01111000
 %01110000
 %00011000
 %00100000
 %00011000
end



 if c = 10 then player0:
 %00011000
 %00010000
 %00010000
 %01111000
 %01110000
 %00011000
 %00100000
 %00011000
end

 if c = 20 then player0:
 %00011000
 %01010000
 %00010000
 %01111000
 %01110000
 %00011000
 %00100000
 %00011000
end



 drawscreen

 rem if a = 0 then fall
 rem if a = 1 then fly
 rem if a = 2 then land on floor
 rem if a = 3 player hits the roof

 if a = then pfscroll up
 if !joy0up then a = 0
 if a = 0 && collision(player0,playfield) then a = 2
 if a = 2 then pfscroll down : b = 0 : d = 0

 rem fly animation
 if a = 1 then c = c + 1
 if a = 0 then c = c + 1
 if c > 20 then c = 0

 rem walk animation

 if a = 1 then pfscroll down
 if joy0up then a = 1
 
 if a = 1 && collision(player0,playfield) then a = 3
 if a = 3 then pfscroll down

 if b = 1 && collision(player0,playfield) then pfscroll left
 if b = 2 && collision(player0,playfield) then pfscroll right


 if joy0left && a = 0 then pfscroll right : b = 1 : e = 1
 if joy0right && a = 0 then pfscroll left : b = 2 : e = 0

 if joy0left && a = 1 then pfscroll right : b = 1 : e = 1
 if joy0right && a = 1 then pfscroll left : b = 2 : e = 0

 rem flip player sprite
 if e = 1 then REFP0 = 8
 if e = 0 then REFP0 = 0

 goto main



Edited by Captain Spazer, Fri Jan 25, 2019 7:27 AM.





0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users