Ive been writing a weapon selection system for a game ill be working on sooon and have got a bit stuck while writing the menus
Heres the code of one on the weapons
//Pistol Weapon
if Sprite Exist (11)=0
Create Animated Sprite 11,"PistolIcon.bmp",3,1,11
Sprite 11,20,90,20
Endif
if PistolState=1 then Set Sprite Frame 11,1
if PistolState=2 then Set Sprite Frame 11,2
if PistolState=3 then Set Sprite Frame 11,3
//if mouse is over pistol icon
if MouseX()>20 && MouseX()<52 && MouseY()>90 && MouseY()<122 && Mouseclick()=1
if Pressed = 0
if TotalPrimaryWeapons <2 // Check if you have less than 2 weapons selected
if Sprite Frame (11) = 2 //if not selected
PistolState=3 // Set correct image
Inc TotalPrimaryWeapons,1
if PrimaryWeaponOne$ = "Empty" //if weapon slot one is empty
PrimaryWeaponOne$ = "Standard Pistol" //Set slot one to equal Standard Pistol
Else //if slot one isnt empty and slot 2 is
PrimaryWeaponTwo$ = "Standard Pistol" //set slot two to equal Standard Pistol
Endif
Endif
Endif
if Sprite Frame (11) = 3 //if it is pressed and it is already selected
PistolState=2 //set image to unselected
Dec TotalPrimaryWeapons,1 //decrease total number of weapons
//Set the weapon variable back to empty
if PrimaryWeaponOne$ = "Standard Pistol" then PrimaryWeaponOne$ = "Empty"
if PrimaryWeaponTwo$ = "Standard Pistol" then PrimaryWeaponTwo$ = "Empty"
Endif
Endif
Endif
basically im wondering if there was some sort function or for loop to do this for around another 10 weapons without doing 400 lines just to selected the variables to get the weapons
also im open to comments about my code and other suggestions on how to improve it even if it doesnt do it in a loop
thanks in advance