Collision Problems...

Blitz3D Forums/Blitz3D Beginners Area/Collision Problems...

Bucky(Posted 2003) [#1]
Hello,

I am making a lunar lander clone and I have run into a collision conumdrum ( using IMAGE COLLIDE ).... any help welcome

When the ship collides with a platform it may be moving at more than 1 pixel so at the time of collision you might end up inside the the platform you have collided with.

Now my ship is just ment to be landing on it, hoping to take off again. But because its inside the platform , by a pixel - it thinks its having a collision and and then puts ships speed to 0 - because thats what happens in collision

I have searched the boards for stuff about this, found similar questions but not a solid answer. Any way of stoping my ship going into the platform in the first place?

Thanks in advance - Bucky

p.s - I have really enjoy blitz basic though it makes my brain hurt. Maybe I am using it for the first time...


Gnasher(Posted 2003) [#2]
hello
here is a small example mabey it solves your problem, the 1 pixel in problem you could always push the ship up a pix when it has landed.. i made a 5 min program mabey it solves your problem

cheers
gnasher

Graphics 800,600
SetBuffer BackBuffer()
Global s.ship,p.plat,g#=0

Type ship
Field x#,y#,a
End Type

Type plat
Field x,y
End Type

s.ship=New ship
s\x#=200.0
s\y#=0.0
s\a=1

p.plat= New plat
p\x=200
p\y=550


While Not KeyHit(1)

Cls
draw_ship()
draw_plat()
checkcol()
move_ship()

Flip

Wend

Function gravity()
g#=g#+0.01
s\y#=s\y#+0.5+g#
End Function

Function move_ship()
If KeyDown(17) Then s\y#=s\y#-1.0-g#
End Function

Function draw_ship()
Color 255,255,0
Rect s\x#,s\y#,20,20
End Function

Function draw_plat()
Color 255,255,255
Rect p\x,p\y,50,10
End Function

Function checkcol()
If Not RectsOverlap(s\x#,s\y#,20,20,p\x,p\y,50,10)
gravity()
End If
End Function


keyboard(Posted 2003) [#3]
you can also use location

simple example:
if (ShipX+ShipHeight) => PlatformX then (ShipX+ShipHeight) = PlatformX


<edit>
<edit>
that is two edits on one line, I am dyslexic today sorry Bucky...


Bucky(Posted 2003) [#4]
Thanks for that Keyboard and Gnasher - but special thanks for the gift of code.

Cheers Bucky