Jump to content


Photo

Double Shot?


  • Please log in to reply
1 reply to this topic

#1 Kortuga

Kortuga

    GMC Member

  • New Member
  • 20 posts
  • Version:GM8

Posted 24 April 2012 - 10:36 PM

I'm making a TDS in which the player can purchase a gun upgrade that allows him to shoot two bullets at once rather than one. Having trouble making this happen. Here's the code I have for the bullet(s) being shot, 'pl' being the player and the colors being the bullets (They're all the same object, just different sprites corresponding with the player's current weapon-in-hand):

if global.shotcount=1
    {
        switch (global.pl_weapon)
        {
        case (0) : instance_create(pl.x,pl.y,red); break;
        case (1) : instance_create(pl.x,pl.y,orange); break;
        case (2) : instance_create(pl.x,pl.y,yellow); break;
        case (3) : instance_create(pl.x,pl.y,green); break;
        case (4) : instance_create(pl.x,pl.y,blue); break;
        case (5) : instance_create(pl.x,pl.y,purple); break;
        case (6) : instance_create(pl.x,pl.y,white); break;
        case (7) : instance_create(pl.x,pl.y,black); break;
        }
if global.shotcount=2
    {
        switch (global.pl_weapon)
        {
        case (0) : instance_create(pl.x+2,pl.y+2,red)
        instance_create(pl.x-2,pl.y-2,red); break;
        case (1) : instance_create(pl.x+2,pl.y+2,orange)
        instance_create(pl.x-2,pl.y-2,orange); break;
        case (2) : instance_create(pl.x+2,pl.y+2,yellow)
        instance_create(pl.x-2,pl.y-2,yellow); break;
        case (3) : instance_create(pl.x+2,pl.y+2,green)
        instance_create(pl.x-2,pl.y-2,green); break;
        case (4) : instance_create(pl.x+2,pl.y+2,blue)
        instance_create(pl.x-2,pl.y-2,blue); break;
        case (5) : instance_create(pl.x+2,pl.y+2,purple)
        instance_create(pl.x-2,pl.y-2,purple); break;
        case (6) : instance_create(pl.x+2,pl.y+2,white)
        instance_create(pl.x-2,pl.y-2,white); break;
        case (7) : instance_create(pl.x+2,pl.y+2,black)
        instance_create(pl.x-2,pl.y-2,black); break;
        }
    }
}

This is in the 'glob right button' event. When I try to shoot two bullets, nothing happens, but when I shoot one, it works properly. What went wrong in the 'if shotcount=2' part? And if you'd be so kind, how could I make it work? Think Galaga.

Edited by Kortuga, 24 April 2012 - 10:38 PM.

  • 0

#2 Kortuga

Kortuga

    GMC Member

  • New Member
  • 20 posts
  • Version:GM8

Posted 24 April 2012 - 11:17 PM

NEVERMIND! My brackets were messed up!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users