Page 1 of 1

How do I create bullets?

PostPosted: Wed Jun 10, 2015 6:38 pm
by imothep85
hello to all

In my game, i have a sprite who is moving from left to right with the keyboard touch left-right from the directional pad (platform game)
HOW to tell to my game, when i push "space" and moving to right the sprite shoot to the right side, if im moving to the left and push "space" i need also the same but for the left.

thanks

Re: How do I create bullets?

PostPosted: Wed Jun 10, 2015 6:47 pm
by Valhallen
Hey there, check out this tutorial about spawning bullets: "Game Development w/ Construct 2 Tutorial - 8 - Shooting Bullets" by TheNewBoston on YouTube.

The bullet will go in the direction the sprite is facing, so if the sprite doesn't flip when you change directions, you'll have to keep track of which way the sprite is facing based on the last movement input, and flip the bullet direction manually.

Re: How do I create bullets?

PostPosted: Wed Jun 10, 2015 6:49 pm
by imothep85
ah thanks a lot :D

Re: How do I create bullets?

PostPosted: Wed Jun 10, 2015 6:58 pm
by imothep85
in my case i dont use at all the mouse but just the keyboard, also my sprite move only from left to right 2 directions only, so i dont know how to solve that :s

Re: How do I create bullets?

PostPosted: Wed Jun 10, 2015 7:03 pm
by Valhallen
That's okay. How about this:

Say your sprite starts facing to the right:
When you press left, your sprite flips 180 to face left. When you press right, your sprite flips 180 to face right again.

When a bullet object gets spawned from your sprite (your sprite will do "spawn another object"), it will automatically be facing the same direction as your sprite.

Don't worry about the mouse controls in the video, just focus on how he spawns the bullet. You can use the same thing in your game when you press the spacebar.

Re: How do I create bullets?

PostPosted: Wed Jun 10, 2015 7:05 pm
by Kyatric
If the sprite goes to the right, the Bullet behavior (applied to the bullet shot) angle of movement should be 0. If going to the left, the angle of movement should be 180.

Re: How do I create bullets?

PostPosted: Wed Jun 10, 2015 7:09 pm
by imothep85
thanks for your help guys :D

Re: How do I create bullets?

PostPosted: Wed Jun 10, 2015 7:24 pm
by imothep85
ok its done, but it fires too much bullets :D

Re: How do I create bullets?

PostPosted: Wed Jun 10, 2015 7:30 pm
by imothep85
ok solved, now i just need to tell to the ennemies to keep a little distance between them