(platformer) destroy blocks when the player walks on them

Get help using Construct 2

Post » Sun Oct 18, 2015 10:55 am

Hi.
I'm trying to achieve a well known effect in platformer games where cracked blocks are destroyed when the player walks on them.

A destructible block should be destroyed only if :
The entire player hitbox touches it, OR any part of the player hitbox touches it as long as the remaining hitbox touches another destructible block.

If the player keeps running on a bridge made of destructible blocks, they should be destroyed one after the other as the player run over them (like with a 0.5s delay).

Any idea how to achieve this ?

Image

The last picture represents what would happen if the player spawns directly on the center destructible block and if its hitbox is smaller.
Last edited by Coin-coin le Canapin on Sun Oct 18, 2015 12:18 pm, edited 1 time in total.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Sun Oct 18, 2015 11:17 am

I'd add a timer-behaviour and then something like this should work..

player is overlapping at offset y=2 destructible
> destructible set timer "destruct" for 0.5

destructible on timer "destruct
> destructible destroy

You might be able to do this with just a wait action, because you want to destruct anyway..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Oct 18, 2015 12:21 pm

I already tried this but it doesn't work for the two first pictures I posted : if the player is overlapping at y=1 a cracked block BUT also overlapping at y=1 an indestructible block, then the destructible block shouldn't be destroyed.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Sun Oct 18, 2015 12:34 pm

Add another condition?

Player is not overlapping at offset other block..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Oct 18, 2015 1:04 pm

Okay I managed to make it working with this :

Image

There is still one issue thought. If the player is still, overlaps both an indestructible and a destructible block and his width suddently decreases, making him overlapping only the destrutible block, it doesn't trigger the condition and the destructible block is not destroyed. I guess I should put these conditions in a function I call at each tick but also each time the player width changes…?

edit : forgot to link the picture :mrgreen:
Last edited by Coin-coin le Canapin on Sun Oct 18, 2015 1:32 pm, edited 1 time in total.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Sun Oct 18, 2015 1:19 pm

The event should work, even with the width decreasing..

Not sure how you have your event set up though..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Oct 18, 2015 1:36 pm

Well I used a function which is called at each tick and when the player width changes and it works perfectly. \o/
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Mon Oct 19, 2015 6:38 am

Here's one way to do it:
https://dl.dropboxusercontent.com/u/542 ... _fall.capx

To satisfy the requirements of the first two images you need to only let the blocks fall if all of them are destructible. The logic looks like this:
Code: Select all
global number cnt=0

+---------------------------------------+
| player overlaps block at offset (0,2) | set cnt to block.pickedCount
+---------------------------------------+
    +-----------------------------------+
    | block is destructable             | let block fall
    | cnt = block.pickedCount           |
    +-----------------------------------+


The block delay bit can be done with by queuing the blocks to fall up and letting them fall one by one.
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Tue Oct 20, 2015 1:16 pm

Thank you very much :)
B
12
S
7
G
7
Posts: 450
Reputation: 4,276


Return to How do I....?

Who is online

Users browsing this forum: ksiads, Magistross, mtnboy22, Rable and 4 guests