Just a little mod to improve shot-block collision physics. before it was random :0:
Method Update ()
' Hit the player (note 'posyonly', 2nd parameter, of PlayerCollide)...
If PlayerCollide (1, 1) Then Destroy; Return
ys = ys + Gravity
x = x + xs
y = y + ys
' Remove if below bottom of screen...
If y > GraphicsHeight ()
Destroy
Else
' Check current Shot against all Blocks...
' (Notice that this only checks Block objects in the list!)
For blk:Block = EachIn GravityItemList
' Get x offset (rectangles are mid-handled)...
ox = x - width / 2
oy = y - height / 2
ogx = blk.x - blk.width / 2
ogy = blk.y - blk.width / 2
' Check collision...
If OverLap (ox, oy, ox + width, oy + height, ogx, ogy, ogx + blk.width, ogy + blk.height)
' If Block is already dead (ie. falling), reflect Shot, otherwise
' un-fix block and create explosion...
' Note: ys is current Shot object's y speed...
If blk.fixed = False
ys = -ys
Else
blk.fixed = False
blk.ys = ys/2
blk.xs = xs/2+(blk.x-x)/10
blk.angspeed = (blk.x-x)/2
ExplosionParticle.Explode ogx, ogy, 4
EndIf
EndIf
'FlushMem ' FlushMem Crash!
Next
EndIf
End Method (method update of shot type)
|