TGC Codebase Backup



Simple gun changes by Vusay

11th Apr 2004 11:55
Summary

A basic code to let you switch guns. Made mainly for beginners but could be improved. Feel free to improve and use.



Description

This lets you switch between no guns, gun 1 and gun 2. It's very basic and simple but could work quite well in a fps and is very adjustable.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    remstart
Controls:
UP = show gun 1
DOWN = show gun 2 
LEFT = show no guns
remend



rem make the guns - you should replace these with gun models
make object cylinder 1,2
make object cube 2,4

rem rotate objects to form a gun
rotate object 1,90,1,1
rotate object 2,90,1,1

rem position objects in the right place - where you hold a gun
position object 1,1,-7,1.5
position object 2,1,-7,1.5



rem hide both guns - when a=3 nboth guns hidden (see a=3 below)
a=3


rem begin loop
do

rem a=1 - show gun 1
if a=1 
show object 1 
hide object 2
endif

rem a=2 - show gun 2
if a=2 
show object 2 
hide object 1
endif

rem a=3 - hide both guns 
if a=3
hide object 1
hide object 2
endif

rem when up key pressed perform a=1(show gun 1)
if upkey()=1 
a=1
endif

rem when down key pressed perform a=2(show gun 2)
if downkey()=1 
a=2
endif

rem when left key pressed perform a=3(hide both guns)
if leftkey()=1
a=3
endif

rem end loop
loop