How do i code a reload mechanic

Get help using Construct 2

Post » Tue Mar 31, 2015 10:25 pm

How should i go about coding a reload mechanic in a top down shooter game? Any and all advice is appericiated. Answers and examples are appreciated even more as this project is for a class and time sensitive.
B
6
S
1
Posts: 47
Reputation: 759

Post » Wed Apr 01, 2015 4:25 am

Hi theDeletr,

I don't really know how others would build it up, but I'll try to explain how I usually do.
Do you want to put ammo limit too ? I will consider that you don't for this simple explanation.

So you need a variable for this. For example lets use a number variable called "ammo" wich is
supposed to be the number of bullets in your gun, and that your gun is a classic
pistol with 15 bullets in a loader. For example :

IF player press SPACE
IF "ammo" is greater than 0 Spawn Bullet
Play sound "GunFire.ogg"
Add to "ammo" -1
Else
IF "ammo" is equal to 0 Hero animation "Reloading"
Play sound "GunReload.ogg"
Wait 0.5 seconds
Set "ammo" to 15.

This makes your player reload if he press Space and that the loader is empty. The 0.5 wait command is
the time needed to reload your gun.

Please tell me if you don't understand what I mean, I think others might have a better way to do it.
B
24
S
5
Posts: 42
Reputation: 1,286

Post » Wed Apr 01, 2015 5:02 am

thnx yours worked
B
6
S
1
Posts: 47
Reputation: 759


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 8 guests