Jump to content


Photo

TDS Gun System


  • Please log in to reply
3 replies to this topic

#1 Wootnezz

Wootnezz

    GMC Member

  • GMC Member
  • 35 posts
  • Version:Unknown

Posted 20 July 2012 - 09:12 PM

Hi there , Right now i'm trying to make a tds zombie splitscreen game and i wonder which is the easiest way to have other guns that just one. I want the players need to buy their own gun and is it possible to have a gun system when u have Split-Screen? so each player has it own guns? plz reply




//Wootnezz
  • 0

#2 Follomania

Follomania

    Unum Mirabile

  • GMC Member
  • 445 posts
  • Version:GM:Studio

Posted 20 July 2012 - 09:29 PM

It is quite possible and can be quite simple. First you'll want to make a variable to hold which gun the player is using (perhaps call it "current_gun"). Set it to 0 in the create event, so 0 is the default gun. When you want to change the gun, just change the number you have in current_gun. Now when you shoot the gun, make a switch statement:
switch (current_gun){    /*Use the "current_gun" variable as the variable to check*/
    case 0:{
        /*The gun is the default gun
          Do your gun code here for the default gun*/
    }
    case 1:{
        /*The gun is gun 1.  Perhaps a machine gun?*/
    }
    case 2:{
        /*The gun is gun 2.  Perhaps a bazooka?*/
    }
    case 3:{
        /*The gun is gun 3.  Perhaps a shotgun?*/
    }
    /*etc...*/
}
Just fill in the case {} statements with the code specific to the gun.
  • 0

#3 Wootnezz

Wootnezz

    GMC Member

  • GMC Member
  • 35 posts
  • Version:Unknown

Posted 20 July 2012 - 10:19 PM

It is quite possible and can be quite simple. First you'll want to make a variable to hold which gun the player is using (perhaps call it "current_gun"). Set it to 0 in the create event, so 0 is the default gun. When you want to change the gun, just change the number you have in current_gun. Now when you shoot the gun, make a switch statement:

switch (current_gun){    /*Use the "current_gun" variable as the variable to check*/
    case 0:{
        /*The gun is the default gun
          Do your gun code here for the default gun*/
    }
    case 1:{
        /*The gun is gun 1.  Perhaps a machine gun?*/
    }
    case 2:{
        /*The gun is gun 2.  Perhaps a bazooka?*/
    }
    case 3:{
        /*The gun is gun 3.  Perhaps a shotgun?*/
    }
    /*etc...*/
}
Just fill in the case {} statements with the code specific to the gun.



How do i do with ammo then?
  • 0

#4 Follomania

Follomania

    Unum Mirabile

  • GMC Member
  • 445 posts
  • Version:GM:Studio

Posted 20 July 2012 - 10:45 PM

I'm assuming you are referring to ammo for each gun?
Here you would use a simple array, where the gun number is the index of the array.
ammo[0] = 100; /*Set the ammo of the default gun to 100*/
ammo[1] = 50; /*Set the ammo of gun 1 to 50*/
/*etc...*/

Now when you shoot:
if (ammo[current_gun] > 0){
    ammo[current_gun] -= 1;
    switch (current_gun){    /*Use the "current_gun" variable as the variable to check*/
        case 0:{
            /*The gun is the default gun
              Do your gun code here for the default gun*/
        }
        case 1:{
            /*The gun is gun 1.  Perhaps a machine gun?*/
        }
        case 2:{
            /*The gun is gun 2.  Perhaps a bazooka?*/
        }
        case 3:{
            /*The gun is gun 3.  Perhaps a shotgun?*/
        }
        /*etc...*/
    }
}

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users