Canvas Pixel Digging

Get help using Construct 2

Post » Mon Mar 19, 2012 5:28 am

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?

B
192
S
6
G
7
Posts: 213
Reputation: 10,178

Post » Mon Mar 19, 2012 10:27 am

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...
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,390

Post » Mon Mar 19, 2012 4:57 pm

B
79
S
24
G
52
Posts: 4,724
Reputation: 39,711

Post » Tue Mar 20, 2012 5:01 am

@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!!!)
B
192
S
6
G
7
Posts: 213
Reputation: 10,178

Post » Tue Mar 20, 2012 4:49 pm

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.
B
79
S
24
G
52
Posts: 4,724
Reputation: 39,711

Post » Wed Mar 21, 2012 4:29 am

@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!
B
192
S
6
G
7
Posts: 213
Reputation: 10,178


Return to How do I....?

Who is online

Users browsing this forum: Governador, RookieDev, tarek2, Thelegendvinny and 19 guests