Throwing an object in 8 directional interface

Get help using Construct 2

Post » Thu Dec 12, 2013 10:51 pm

Hi
I'm looking for a way to throw an object a "grenade" for example in 8 directional , I searched the forum but didn't find anything could help.
All i found is using physics, and I'm not sure it's gonna work in my case.

Thanks
B
5
Posts: 15
Reputation: 305

Post » Fri Dec 13, 2013 1:20 pm

You could be more specific about what you want. What type of game is this? Is it platformer, top down shooter or what?

Without more specific info, we could not provide anything useful for you.
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Wed Dec 18, 2013 7:56 am

Hi
It's a top view shooter.
B
5
Posts: 15
Reputation: 305

Post » Wed Dec 18, 2013 11:42 am

8 directional top down shooter? You could extend from the Ghost Shooter sample, but then you need to clarify further: how and what will set the angle of your grenade?

The how part is : in your event sheet, you can, for instance,

- if key spacebar is pressed:
- - create a grenade at player's object
- - set angle of grenade to ____ angle.

The blank above is the what part. What should be the angle of your grenade? Should we set it accordingly when the player is holding the directional arrows?

If that's the case, extending from above, you could have a global variable and some more keyboard related events like this:

Global variable grenadeAngle = 0
(Right click somewhere NOT on your events IN your event sheet and you should see an option to create a global variable)

- if key left is being holded:
- - if key up is being holded:
- - - set global variable grenadeAngle to -135.
- - else if key down is holded:
- - - set global variable grenadeAngle to 135.
- - else
- - - set global variable grenadeAngle to 180.
- else if key right is being holded:
- - if key up is being holded:
- - - set global variable grenadeAngle to -45.
- - else if key down is holded:
- - - set global variable grenadeAngle to 45.
- - else
- - - set global variable grenadeAngle to 0.
- else if key up is being holded:
- - set global variable grenadeAngle to -90.
- else if key down is being holded:
- - set global variable grenadeAngle to 90.

- if key spacebar is pressed:
- - create a grenade at player's object
- - set angle of grenade to grenadeAngle angle.

Make sure you put the spacebar event below the left right up down business. Because events from top to bottom. This will allow your grenadeAngle to reflect your recent input in this tick right away.

So what did we just do from above? We set the variable grenadeAngle to respective key inputs. If you don't understand what the heck did I just write above, you may wish to google if else statement in programming.

(If any of the term feels confusing or you need more assistance, please say so and add my name "@keroberos" in your next reply)
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 31 guests