Ok with out the code below, my program works fine.
When the left mouse button is pressed, it plays the sound that I have indicated it to play. The problem was that I needed a way for the gun to change when the player presses the button to switch to a differnt inventory slot.
I tried using the code below, inside of the loop, and something funny is happening. It the game starts at INVENTORY[0] which is equal to ASSAULTRIFLE. ASSAULT RIFLE has a value of 6.
When I press the button to open slot 0, the images still change and the inventory sound plays fine, so not everything is just messed up, I know its just the values inside of the CurrentGun object.
I try to fire after pressing the button for slot 0, and nothing fires. I press slot 1, and nothing fires.
I press slot 2 and it fires the sound that should be in slot 1. I press slot 3 and it also fires the slot 1 sound. I go back to slot 1, and it doesnt fire anything.'
I go back to slot 0, and nothing fires.
I go back to slot 2 from slot 0, and now slots 2 and 3 fire the sound from slot 0.
This is beyond my young programming mind.
Here is the code that is inside the loop.
if(INVENTORY[iCurrentSlot] == ASSAULTRIFLE)
{
CurrentGun.FIREMODE = AssaultRifle.FIREMODE;
CurrentGun.FIRESOUND = AssaultRifle.FIRESOUND;
CurrentGun.iAmmoPerMag = AssaultRifle.iAmmoPerMag;
CurrentGun.iDamage = AssaultRifle.iDamage;
CurrentGun.iDistance = AssaultRifle.iDistance;
CurrentGun.iDropOffRate = AssaultRifle.iDropOffRate;
CurrentGun.iMags = AssaultRifle.iMags;
CurrentGun.iProjectileVelocity = AssaultRifle.iProjectileVelocity;
CurrentGun.iRecoil = CurrentGun.iRecoil;
CurrentGun.iReloadTime = AssaultRifle.iReloadTime;
CurrentGun.iROF = CurrentGun.iROF;
CurrentGun.PROJECTILE = AssaultRifle.PROJECTILE;
CurrentGun.bShotSoundPlayed = true;
}
if(INVENTORY[iCurrentSlot] == SHOTGUN)
{
CurrentGun.FIREMODE = Shotgun.FIREMODE;
CurrentGun.FIRESOUND = Shotgun.FIRESOUND;
CurrentGun.iAmmoPerMag = Shotgun.iAmmoPerMag;
CurrentGun.iDamage = Shotgun.iDamage;
CurrentGun.iDistance = Shotgun.iDistance;
CurrentGun.iDropOffRate = Shotgun.iDropOffRate;
CurrentGun.iMags = Shotgun.iMags;
CurrentGun.iProjectileVelocity = Shotgun.iProjectileVelocity;
CurrentGun.iRecoil = Shotgun.iRecoil;
CurrentGun.iReloadTime = Shotgun.iReloadTime;
CurrentGun.iROF = Shotgun.iROF;
CurrentGun.PROJECTILE = Shotgun.PROJECTILE;
CurrentGun.bShotSoundPlayed = true;
}
Below is the code that works when I put it before the loop.
Problem with that the user cannot change the values which is bad!
But it does fire the correct sound.
CurrentGun.FIREMODE = AssaultRifle.FIREMODE;
CurrentGun.FIRESOUND = AssaultRifle.FIRESOUND;
CurrentGun.iAmmoPerMag = AssaultRifle.iAmmoPerMag;
CurrentGun.iDamage = AssaultRifle.iDamage;
CurrentGun.iDistance = AssaultRifle.iDistance;
CurrentGun.iDropOffRate = AssaultRifle.iDropOffRate;
CurrentGun.iMags = AssaultRifle.iMags;
CurrentGun.iProjectileVelocity = AssaultRifle.iProjectileVelocity;
CurrentGun.iRecoil = CurrentGun.iRecoil;
CurrentGun.iReloadTime = AssaultRifle.iReloadTime;
CurrentGun.iROF = CurrentGun.iROF;
CurrentGun.PROJECTILE = AssaultRifle.PROJECTILE;
CurrentGun.bShotSoundPlayed = true;
5/14/06- 1298 lines into my 3D game engine! Player Movement and File System completed. Working on weapon inventory and player classes.