Posted: 12th Mar 2004 22:45
This is my first code doing something like this so I dont know how much it really sucks since I am just a begginer but the code is pretty short. what it does is when you press 1 or 2 more can be added but it hides the weapon and shows the new one
+ Code Snippet
`load guns
DIM w1(1):DIM w2(1)

Load object "Media/Guns/Sniper.x",1
Load object "Media/Guns/Blaster.x",2

position object 1,5,.05,5
position object 1,5,.05,5

hide object 1
hide object 2

w1 = 1
w2 = 0

`Put this in loop

if inkey$()="1" and w1 = 0 then w1 = 1:w2 = 0
if inkey$()="2" and w2 = 0 then w1 = 0:w2 = 1

if inkey$()="1" then show object 10:hide object 11
if inkey$()="2" then hide object 10:show object 11

Plz rate my code I hope it helps some of you out there
Posted: 13th Mar 2004 2:20
its bad practice to have, if inkey$()="1", and then the same thing on the next line, as if you pressed down "1", for the 1st inkey but it was release by the time it got to the 2nd inkey itwouldent run that code, so compact it. and to make adding guns easier

and i dont know what w1,w1 etc does, as it is irrelevant in your loop, same as your arrays.


+ Code Snippet
load object "gun1.x",1
load object "gun2.x",2

guncount=2
selected_gun=1

for i=1 to guncount
 if scancode(i+1)=1 then selected_gun=i
 hide object i
next i

show object selected_gun


thats the same code, but much simpler to add more guns, and is more efficient ingame
Posted: 13th Mar 2004 10:56
well I am kind of newbie when it comes to new codes I have just used the more simple ones and the one I posted up there works without trouble for me and I still havent read on how to use the next i commands and stuff like that

w1=weapon 1 for when w1 = 1 then shows gun 1 if w2 = 1 then it shows the second gun and so on