How do I add a varscore when jump over the enemy?

  • Hi,

    I've been looking through a lot of tutorial and couldn't found the situation I'm looking for.

    I want a score to count when Player jump over (not kill) the enemy.

    The reason is if Player touch Enemy, Player will die.

    So to make a score count, Player have to jump over with out touching any part of the enemy.

    I found a mario type tutorial and I did try some other way but it didn't work.

    Seem like you have to collision with Enemy to make it count. I try to find a way to compare Y with Enemy but still not working.

    Anyone know what should I do?

    Thanks,

  • If you want points only once give enemy variable "givePoints" or so, boolean for example.

    Is boolean set
    Enemy compare Y > Player.Y
    Enemy compare X < Player.X
    
    =>
    Add points
    Set givePoints false[/code:14vlqxfp]
    
    If you level is not simple left to right then you could maybe compare distance and/or make some more coordinate checks.
  • Thanks for your comment.

    I try that and it somehow start counting the score.

    However the score just keep running when ever I jump either over the enemy or not.

    I did set the varible to add 10 to the varScore but what it does is just continue running the score until player touch the ground.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Also even I toggle disabled on set givePoints to false.

    There seem to be no different at all.

  • Good question, here's something I knocked up quick...

    I made it work both ways left to right or vice versa, let me know if it's what you need...

    https://dl.dropboxusercontent.com/u/146 ... check.capx

  • You could also pin a invisible sprite to the enemies (above them) and when the player collides with the invisible sprite then add to their score. You can have an instance variable on the invisible sprite that tracks if the player already collided with it so that you can keep them from getting more points jumping over the same enemy if you want.

  • pixel perfick

    Thank you! I try your way and do some modify and it works

    BluePhaze

    That's an interesting way to count a score. Seem like there're a lot of way to get the work done.

    Thanks you guy!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)