Time for action — detailing collision detection

During the collision callback method, we will set the collision markers and objects, so that we can act on them during the OnObjectUpdate method.

  1. Start with a Select statement on the first object's collision group.
    Method OnObjectCollision:Int(obj:ftObject, obj2:ftObject)
    Select obj.GetColGroup()
    
  2. Check whether it is a wall.
    Case g.grpWall
    
  3. If the second object is in the player's second collision zone (128 pixels away), then set g.hitWall2 to True. We do this by checking the collision group of the second object.
    If obj2.GetColGroup()=g.grpPlayer2 Then g.hitWall2=True
    
  4. Now, check whether the second object is the first collision zone of the player (64 pixels away), and if yes, set g.hitWall to True.
    If obj2.GetColGroup()=g.grpPlayer Then g.hitWall=True
    
  5. Check whether the first object is a crate.
    Case g.grpCrate
    
  6. If the second object is the first collision zone of the player, then set g.hitCrate with the first object.
    If obj2.GetColGroup()=g.grpPlayer Then g.hitCrate=obj
    
  7. Again, if the second object is the second collision zone of the player, then set g.hitCrate2 with the first object.
    If obj2.GetColGroup()=g.grpPlayer2 Then g.hitCrate2=obj
    
  8. Finally, check whether the first object is a target.
    Case g.grpTarget
    
  9. If yes, then check whether the second object is a crate and it isn't moving anymore. If yes, that means that a crate is on a target and we need to increase the g.onTarget field.
    If obj2.GetColGroup()=g.grpCrate And obj2.GetTransitionCount()=0 Then g.onTarget += 1
    
  10. Close the Select statement.
    End
    Return 0
    End
    

What just happened?

During the collision callback method, we first checked what kind of first object we have. And depending on that, we have set various collision markers and objects that help to act on them when we want to update the movement of crates and the player machine.

I can't see it anymore—the transition is finished!

The absolutely last thing that we will add together is the action that occurs when the level is complete and it has finished its fading-out transition.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.253.55