How do I make Super Mario Bros 2 styled throwing system?

Get help using Construct 2

Post » Wed Jul 29, 2015 4:12 pm

Hi,

Like topic says, I'm currently making smb2 styled game, where player can pick up items/things or enemies and throw them. I have implemented throw -mechanic in the game and it is working fine :)

Now I'm implementing destroying -mechanic. Throwing an item against an enemy will destroy the enemy. That was an easy task to make to implement BUT I'm having a hard time figuring out how to do the same with the enemy. I mean, when player throw an enemy against another enemy, both of them should be destroyed (like in smb2). I can destroy the enemy which was thrown, because I have set an boolean variable, which tells when enemy is picked up (actually picked up in-game) but I can't destroy the other enemy (the one which receive the hit and is on the ground).

I'm using families on items and enemies. Both are in their own families. I know I have to tell construct 2 which enemy is receiving the hit and that is the problem. I can't figure out how I can pick that enemy, who was walking on the ground. I feel like I have tried everything. I have tried to put destroying -mechanic into a function, set another boolean, pick nearest enemy which was not thrown etc and nothing works like I want to.

My current events looks something like this:

1# items -family: is picked up, on collision with enemies -family = destroy enemies -family.

2# enemies -family: is picked up, on collision with enemies -family = destroy enemies -family.

I hope my mumbling makes sense. Anyone want to help me out with this one? I would really appreciate any kind of help ^^
B
16
S
2
Posts: 60
Reputation: 984

Post » Wed Jul 29, 2015 4:26 pm

there should an easier way, but should be able this way:

create a global variable - destroy

enemy on collision with enemy
-- enemy is picked up
> system set destroy to "yes"
-- destroy is "yes"
> enemy destroy
-- system every tick (or empty subevent)
> set destroy to "no"

where -- stands for subevent
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 » Wed Jul 29, 2015 4:44 pm

Thank you, it's working ^^
B
16
S
2
Posts: 60
Reputation: 984

Post » Fri Oct 23, 2015 7:51 am

Message: Mithrill can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
@LittleStain, you code is working perfectly. Currently I'm trying to improve the mechanics. When I throw an enemy against another enemy, that thrown enemy is be able to destroy multiple enemies (like in smb2) after thrown.

I'm having another problem with the collision checks and pretty much with everything :/

My current code is like this:
Image

I checker this forum post and I tried to implement that example https://www.scirra.com/tutorials/797/how-to-handle-instances-of-same-sprite-collision-colliding into my project. I made it to work but it's still doing the same as previously: both enemies are destroyed.

Code for this like so:
Image

So my question is: how I make that thrown enemy can hit multiple enemies when thrown? Clearly I'm missing something here (again) and (again) any kind of help would be highly appreciated.
B
16
S
2
Posts: 60
Reputation: 984

Post » Fri Oct 23, 2015 10:11 am

What was wrong with the code in your first example?

Forgive me if I'm wrong, but I don't see need for using instance1 and instance0 in this case for they are easily distinguishable by their instance variables..
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 » Fri Oct 23, 2015 10:32 am

There's nothing wrong with the code itself. Currently, when an enemy collides with another enemy, both are destroyed. Which was fine. Now, like I mentioned earlier, I'm trying to do mechanic that when an enemy is thrown and collides with another enemy both are killed BUT the enemy which was thrown, can collide with another enemy and kill it. Like a chain reaction kind of thing.

And mont probably I'm trying to do everything in a overcomplicated way :/
B
16
S
2
Posts: 60
Reputation: 984

Post » Fri Oct 23, 2015 11:08 am

In your first example I don't see any actions destroying your smallenemies..

All I see is a set collisions disabled action, which you could remove for the isthrown instance and it would still collide with another smallenemies instance..
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 » Fri Oct 23, 2015 11:42 am

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 » Fri Oct 23, 2015 12:02 pm

I figured it out :D

Thank you for your capx -example. I will check it after I backup all my project files and upgrade construct2.
B
16
S
2
Posts: 60
Reputation: 984


Return to How do I....?

Who is online

Users browsing this forum: jezjones24 and 8 guests