Canvas Pixel Digging

0 favourites
  • 6 posts
From the Asset Store
Basic template for drawing game with masks and easy customization
  • So, from what I can see, There is no way to change a collision box once the item has been created?

    I am trying to come up with a way to make a simple digging game. I want a player sprite to walk on a block then dig a small hole that becomes a part of the terrain - meaning the player sprite can fall into the hole.   I tried using Destination out on a sprite, but the collision is still an issue (or am I doing it wrong?) Then I studied the Canvas Plugin Posts and saw a reference of using pixel colors as your collision detectors. But I can't make mine work. I have tried many ways. (I can't post my capx at this time BTW...)

    Is there a Tutorial somewhere to help me with this?

  • There is no way to change a collision box at runtime. However, nobosy said you can't change animation frames, which can each have different collisions...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • rojohound, Very interesting way to do the worm pixel detection. If I understand correctly, you are testing every pixel on the edge of the Worm Sprite to see if it is touching a ground pixel as indicated by the Array. You used an Array so you could have a "detectable" pixel (the x,y coordinate in the array.)?

    I have an Idea to use image points on a sprite (2 bottom 2 mid-sides 2 top) and cycle through them per tick: Something like this:

    Every Tick

    For "Cycle"=1 to 6

    ->System Compare 2 values -> Canvas rgbAt(sprite.ImagePoint(Loopindex("Cycle"))=rgba(Whatever color the ground is)

    Then move back like you did if it touches.

    Would that work? And Would that speed up the FPS? (Haven't tried it yet... Waiting for Day Off... UGH!!!)

  • It tests every pixel in the players bounding box for collision. I used an array to store the collision data instead of using "rgbAt" because it's faster. Your approach would work, but there could be instances that thin parts of the terrain would intersect your player and it would not register as a collision.

  • rojohound, I see what you mean. When I run the Lemmings example from the other thread and speed up the lemmings, They skip...

    I think I got some ideas from your example! Thanks!

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