Clock Jumper game

I still learning and although I don’t know how to make a hit test of two objects I make my own using only variables and this is the result

Clock Jumper

I hope you like it

I’ll keep playing with variables, by now I have a test of an object hitting some objects in a flying game.

7 Likes

Cool! Like it!!

1 Like

I didn't either, until today. HA HA! :laughing:

Over the past few days, I had a bad case of writer's block. But this morning, after seeing your post (and realizing that the game section isn't complete without collision detection) I decided to try once again.

The matter.js documentation and demo covers the basics of "sensors".

...the example targets the bodies directly, but that gets tedious for game development. There's something called "collision filters", but that's more programming. Isn't there something more Hype like?

Since I just wrote the "Game Data" chapter, which covers custom attribute data, I decided to try that. It totally works and works well! Instead of adding every platform in the game as a collision group, I simply gave it a "data-ground" attribute. Then, using three sensors (main, left and right) the game actually jumps like a platformer — including wall jumping.

 Matter.Events.on(hypeDocument.getElementProperty(hypeDocument.getElementById("sensor"), "physics-engine"), "collisionStart", function (event) {

      var pairs = event.pairs;               

      for (var i = 0, pl = pairs.length; i < pl; ++i) {
           
           var pair = pairs[i];

           if (pair.bodyA.elementId === "sensor") {
                var bonk = hypeDocument.getElementById(pair.bodyB.elementId);
                if (bonk.hasAttribute("data-ground")) {
                     window.ground = true;
                }
           }
      }

 });

The trick is the "hasAttribute" method. Also, what was tripping me up, is that the matter.js example does the "collisionStart", "collisionEnd", "collisionActive" as its own function. I was running it with every keypress and flooding the console.log. I was like... what's with this API?! HA HA. So now, I just set the collision detection at the start.

Anyway, I'm planning to cover this in the Hype book, but the template is online.

Template PostPhysics Mini Templates for Tumult Hype 4 - #23 by Photics
Animated GIF of wall jumpingPhysics Mini Templates for Tumult Hype 4 - #27 by Photics

3 Likes

:astonished: WOW :astonished:

Thank you for taking the time to help everybody and give all this useful information to make better content

Although I don’t know how to implement this right now, I’ll start studying and practicing

I really liked FLASH in that part, the build in Hit detection was so easy to implement in a single line, so I think we have to get used to the HYPE way

THANKS again for your time and effort :star_struck:

1 Like