2D Side Scroll Shooter Help

For questions about using Classic.

Post » Fri Jan 09, 2015 3:01 am

Hello,

I'm trying to make a metroid-like game, but I'm having a problem. I want to make the shooting so that there is no bullet to be seen. Basically I want the player to see explosions coming from the barrel and a ricochet effect coming from whatever is in front of the player. I can't seem to find a solution on how to detect what is in front of the player and where to spawn the ricochet effect. Here's the effect I want:

Image

Any idea how I would go about detecting what is in front of the player depending on orientation?

I also have another issue which is the blast coming from the barrel. The blast doesn't follow the player. When you first press fire it appears at the player but if you continue to hold and walk around it stays in the same spot. Any help with this?

Sorry if I'm sounding newbish, but I'm just new to Construct.
B
3
Posts: 5
Reputation: 185

Post » Fri Jan 09, 2015 12:18 pm

This is what loops are for.
You'll still need an object to collide with the wall, but you'll simply make it invisible. You'll spawn a bullet object at the end of the gun object, and run a loop that iterates the bullet's position across space until it finds a collision. Loops run within a step instead of once every step, so it will not continue any other code until that loop is done, and the iteration ensures contact, so the bullet movement is instantaneous without concern of it overlapping too far or phasing through other objects.

Basically, you would use a while loop condition. The loop is run while the bullet is not overlapping anything. The actions in the loop should move the bullet forward one or more pixels ahead (the farther this distance, the less iterations the loop will have to run as the bullet will make contact that much faster, so keep that in mind). In an else condition, add a break loop action, destroy the bullet and create the spark effect.
Be mindful of while loops, as they will run forever until a condition is satisfied. Make sure your environment is air tight, or create an escape condition such as breaking the loop or destroying the bullet after it has traveled a certain distance.
B
6
S
1
Posts: 15
Reputation: 530

Post » Fri Jan 09, 2015 7:10 pm

Thanks a ton! I will definitely have to try this. Yea I figure I'll make it so that if the bullet goes off camera then the bullet is destroyed. In other words, you can't shoot things off screen which I'm fine with.
B
3
Posts: 5
Reputation: 185

Post » Fri Jan 23, 2015 10:28 pm

For the blast following the player couldn't you use the action, Set position to Player after checking the angle?
B
24
S
7
G
1
Posts: 36
Reputation: 2,049


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest