Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / This block of code totally messes up my program!

Author
Message
Briere
19
Years of Service
User Offline
Joined: 28th Feb 2005
Location: Amherst New York, United States
Posted: 15th May 2006 00:07 Edited at: 15th May 2006 00:10
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.



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.



5/14/06- 1298 lines into my 3D game engine! Player Movement and File System completed. Working on weapon inventory and player classes.
Barnski
18
Years of Service
User Offline
Joined: 26th Jan 2006
Location: Switzerland, Zurich
Posted: 15th May 2006 16:47
I think you can reduce the amount of code lines by simply doing:

CurrentGun = AssaultRifle


or:

CurrentGun = INVENTORY[iCurrentSlot]


this means working with pointers, of course. But it could help reduce the possible sources of bugs, since you will operate on the original object / struct.

Login to post a reply

Server time is: 2024-11-19 06:41:43
Your offset time is: 2024-11-19 06:41:43