• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Syncing Counters

Hi

Can someone *please* help fix this. I've been trying to fix it for over a month down. I have a bar at the top of my screen that lets you select a bat to play as. Once you click on it, it greys out and a timer starts counting down until you can use that bat again. Simple, right? But what is happening is I click on the lightning bat it starts counting down and then I click on the wind bat and suddenly the two sync up. If the lightning bat is at say, 23, and I pull the wind bat, the wind bat syncs up to 23,

I know the first thing you would think is that they are sharing a variable but I've exhausted that option. I've tried going through the debugger and I didn't get much help wit h that either. I'm going to paste some code and hopefully get some help. There has to be something *I'm* missing.


Bats2 Object Step Event

Code:
//myTimer
global.batBcountdown--;


//count down on myTimer to 0.
//at 0 you have the bat
if (global.batBcountdown <= 0)
{
    Player.hasbatB = true;      //have bat
    Player.myTimerbatB = false;     //myTimer is not active
   
   
   
    with (global.bhourglass)    //destroy the hourglasds icon
    {
        instance_destroy();
        global.batBcountdown = room_speed*50;    //restore the countdown
        //global.batBmyTimer =0;
    }
}
Bats 3 Object Step Event
Code:
draw_self();

if (Player.hasbatC)
{
    draw_sprite(WindBatFace, 0, x, y);
}

else
{
    draw_sprite(GreyScaleWind, 0, x, y);
}

if (Player.myTimerbatC == true)
{

   
   
    draw_set_colour(c_red);  
    draw_set_font(myTimerFont);
    draw_text_transformed_colour(x+50, 20, string(floor(global.batCcountdown/50)), 4, 4, 0, c_black, c_black, c_black, c_black, 1.0);
    draw_set_font(Arial_Font_Modified);
    draw_set_colour(c_black);  
}
Drop Bat Object Step
Code:
global.sentry_myTimer--;

if (y > 800)
{
    with (Player)
    {
        if (global.dropped_bat == false)
        {
           
            global.dracula_myTimer = 0;
            if (global.select_bat == 1)
            {
                if (hasbatA)
                {
                    if (global.can_click && global.sentry_myTimer <= 0) {
                   
                    //global.current_bat = instance_create_depth(340, 950, 1700, SentryBatObject);
                    global.current_bat = instance_create_depth(340, 950, 1700, SentryBatObject);
                    audio_play_sound(SentryBat, 10, false);
                    global.dropped_bat = true;
                    global.sentry_myTimer = room_speed;
                    with (EightStarObject)
                    {
                        image_index = 1;
                        global.hex_myTimer = room_speed;
                    }
                    }
               
                   
                }
            }
       
            if (global.select_bat == 2)
            {
                global.current_bat = instance_create_depth(390, 1050, -1100, LightningBatObject);
                with (global.current_bat)
                {
                   
                    audio_play_sound(LightningStrike, 10, false);
                    if (Player.hasbatB)
                    {
                       
                        show_debug_message("Player hasBatB");
                        sprite_index = LightningBatStill;
                        global.dropped_bat = true;
                        audio_play_sound(LightningBat, 10, false);
                        if (!global.is_anarchyMode)
                        {  
                            Player.hasbatB = false;
                            Player.myTimerbatB = true;
                            show_debug_message("Player has myTimerBatB + " + string( Player.myTimerbatB));
                            show_debug_message("PLayer has hasbatB: " + string(Player.hasbatB));
                           
                            global.bhourglass = instance_create_depth(Bats2.x, Bats2.y, -1100, myTimerHourglassObject);
                            global.batBmyTimer = 0;
                            global.batBcountdodwn = room_speed*50;
                        }
                       
                        else
                        {
                            Player.hasbatB = true;
                            Player.myTimerbatB = false;
                            show_debug_message("Player has myTimerBatB + " + string( Player.myTimerbatB));
                            show_debug_message("PLayer has hasbatB: " + string(Player.hasbatB));
                       
                            //global.bhourglass = instance_create_depth(Bats2.x, Bats2.y, -10000, myTimerHourglassObject);
                            //global.batBmyTimer = 0;
                            //global.batBcountdodwn = room_speed*50;
                                   
                           
                        }
                    }  
                   
                }
               
            }
            if (global.select_bat == 3)
            {
                global.current_bat = instance_create_depth(340, 980, 1700, WindBatObject);
               
                with (global.current_bat)
                {
                    audio_play_sound(DropWindBat, 10, false);
                    sprite_index = WindBatStill;
                    global.dropped_bat = true;
                    audio_play_sound(HurricaneBat, 10, false);
                    if (!global.is_anarchyMode)
                    {
                        Player.hasbatC = false;
                        Player.myTimerbatC = true;
                            global.chourglass = instance_create_depth(Bats3.x, Bats3.y, 1700, myTimerHourglassObject);
                            global.batCmyTimer = 0;
                            global.batCcountdodwn = room_speed*50;
                       
                    }
                    else
                    {
                        Player.hasbatC = true;
                        Player.myTimerbatC = false;
                            //global.chourglass = instance_create_depth(Bats3.x, Bats3.y, -10000, myTimerHourglassObject);
                            //global.batCmyTimer = 0;
                            //global.batCcountdodwn = room_speed*50;
                    }
                }
               
            }
 

zATARA_0

Member
with (global.bhourglass) //destroy the hourglasds icon
{
instance_destroy();
global.batBcountdown = room_speed*50; //restore the countdown
//global.batBmyTimer =0;
}

is global.bhourglass an instance? also its being destroyed before editing the global.batBcountdown
but most likely the problem is that you have a lot of global values and probably you are overwriting one on accident.
like global.current_bat. When you make a bat 2 or bat 3, they both get initilized as global.current_bat.
 
I messed up pasting the contents of Bat2 and Bat3 step events.
This is what they are:

Bats2 step
Code:
//myTimer
global.batBcountdown--;


//count down on myTimer to 0.
//at 0 you have the bat
if (global.batBcountdown <= 0)
{
    Player.hasbatB = true;      //have bat
    Player.myTimerbatB = false;     //myTimer is not active
  
  
  
    with (global.bhourglass)    //destroy the hourglasds icon
    {
        instance_destroy();
        global.batBcountdown = room_speed*50;    //restore the countdown
        //global.batBmyTimer =0;
    }
}
and bats 3 step

Code:
    global.batCmyTimer++;

    global.batCcountdown--;
  
    //countdown--;
    //if (room_speed*60 - myTimer >= 0)
    ////{
    //    countdown  = room_speed*60 - myTimer;
    //}
  
    if (global.batCcountdown <= 0 )
    {
      
            Player.hasbatC = true;
            Player.myTimerbatC = false;
            with (global.chourglass)
            {
                instance_destroy();
                global.batCcountdown = room_speed*50;     
                global.batCmyTimer =0;
            }
          
    }
with (global.bhourglass) //destroy the hourglasds icon
{
instance_destroy();
global.batBcountdown = room_speed*50; //restore the countdown
//global.batBmyTimer =0;
}

is global.bhourglass an instance? also its being destroyed before editing the global.batBcountdown
but most likely the problem is that you have a lot of global values and probably you are overwriting one on accident.
like global.current_bat. When you make a bat 2 or bat 3, they both get initilized as global.current_bat.
global.bhourglass is an instance of an hourglass object that shows up while the counter is counting down. when the counter reaches 0 it is destroyed. As for a global variable overwriting another global variable I was pretty thorough and I am certain that's not the problem
 
Not sure.

This is the code for Create Event for Bats2 and 3
Code:
global.isopen2 = false;

numberOfClicks = 0;

walking = false;
idle = false;
sentry = false;
placing = false;
still = false;
create_new_bat = true;

countdown = room_speed*50;
myTimer =0;

*********)
And this is the code for create event Bats 3








*/


with (Player)
{
    if (hasbatC == true)
    {
        Bats3.visible = true;
    }
}


//if (global.select_bat == 3)
//{
    //myTimer++;
    global.batCmyTimer++;

    global.batCcountdown--;
   
    //countdown--;
    //if (room_speed*60 - myTimer >= 0)
    ////{
    //    countdown  = room_speed*60 - myTimer;
    //}
   
    if (global.batCcountdown <= 0 )
    {
       
            Player.hasbatC = true;
            Player.myTimerbatC = false;
            with (global.chourglass)
            {
                instance_destroy();
                global.batCcountdown = room_speed*50;      
                global.batCmyTimer =0;
            }
           
    }
And while i'm at it, here is the Draw Code:
Bats2

Code:
Code for Draw Event Bats 2


draw_self();

if (Player.hasbatB)
{
    draw_sprite(LightningBatFace, 0, x, y);
}

else
{
    //show_debug_message("Greyscale Lightning Face");
    draw_sprite(GreyScaleLightning, 0, x, y);
}

if (Player.myTimerbatB == true)
{

   
    //show_debug_message("Greyscale Lightning myTimer CO untdown " + string(countdown));
    draw_set_colour(c_red);  
    draw_set_font(myTimerFont);
    draw_text_transformed_colour(x+ 50, y, string(floor(global.batBcountdown/50)), 4, 4, 0, c_black, c_black, c_black, c_black, 1.0);
    draw_set_font(Arial_Font_Modified);
    draw_set_colour(c_black);  
}
   
Draw Event for Bats 3


draw_self();

if (Player.hasbatC)
{
    draw_sprite(WindBatFace, 0, x, y);
}

else
{
    draw_sprite(GreyScaleWind, 0, x, y);
}

if (Player.myTimerbatC == true)
{

   
   
    draw_set_colour(c_red);  
    draw_set_font(myTimerFont);
    draw_text_transformed_colour(x+50, 20, string(floor(global.batCcountdown/50)), 4, 4, 0, c_black, c_black, c_black, c_black, 1.0);
    draw_set_font(Arial_Font_Modified);
    draw_set_colour(c_black);  
}
 
Code:
Not sure.

This is the code for Create Event for Bats2:
global.isopen2 = false;

numberOfClicks = 0;

walking = false;
idle = false;
sentry = false;
placing = false;
still = false;
create_new_bat = true;

countdown = room_speed*50;
myTimer =0;

*********)
And this is the code for create event Bats 3








*/


with (Player)
{
    if (hasbatC == true)
    {
        Bats3.visible = true;
    }
}


//if (global.select_bat == 3)
//{
    //myTimer++;
    global.batCmyTimer++;

    global.batCcountdown--;
   
    //countdown--;
    //if (room_speed*60 - myTimer >= 0)
    ////{
    //    countdown  = room_speed*60 - myTimer;
    //}
   
    if (global.batCcountdown <= 0 )
    {
       
            Player.hasbatC = true;
            Player.myTimerbatC = false;
            with (global.chourglass)
            {
                instance_destroy();
                global.batCcountdown = room_speed*50;      
                global.batCmyTimer =0;
            }
           
    }
And while i'm at it, here is the Draw Code:
Bats2

Code:
Code for Draw Event Bats 2


draw_self();

if (Player.hasbatB)
{
    draw_sprite(LightningBatFace, 0, x, y);
}

else
{
    //show_debug_message("Greyscale Lightning Face");
    draw_sprite(GreyScaleLightning, 0, x, y);
}

if (Player.myTimerbatB == true)
{

   
    //show_debug_message("Greyscale Lightning myTimer CO untdown " + string(countdown));
    draw_set_colour(c_red);  
    draw_set_font(myTimerFont);
    draw_text_transformed_colour(x+ 50, y, string(floor(global.batBcountdown/50)), 4, 4, 0, c_black, c_black, c_black, c_black, 1.0);
    draw_set_font(Arial_Font_Modified);
    draw_set_colour(c_black);  
}
   
Draw Event for Bats 3


draw_self();

if (Player.hasbatC)
{
    draw_sprite(WindBatFace, 0, x, y);
}

else
{
    draw_sprite(GreyScaleWind, 0, x, y);
}

if (Player.myTimerbatC == true)
{

   
   
    draw_set_colour(c_red);  
    draw_set_font(myTimerFont);
    draw_text_transformed_colour(x+50, 20, string(floor(global.batCcountdown/50)), 4, 4, 0, c_black, c_black, c_black, c_black, 1.0);
    draw_set_font(Arial_Font_Modified);
    draw_set_colour(c_black);  
}
And here is the left mouse button. That's just about everything

Code:
Bats2 Left Mouse Button CLicked

if (Player.hasbatB == true)
{
    if global.dropped_bat == false
    {
        if (mouse_check_button_released(mb_left) && (global.can_click))
        {
            global.lightning_drop_myTimer = room_speed;
            global.select_bat = 2;
            global.lightning_drop = true;
            audio_play_sound(PickBat, 10, false);
            instance_create_depth(270, 9, -15000, DropBatObject);
            alarm[0] = 20;
        }
    }
}

Bats3 Left Mouse BUtton Pressed


if (Player.hasbatC == true)
{
    if global.dropped_bat == false
    {
        if (mouse_check_button_released(mb_left) && (global.can_click))
        {
            global.select_bat = 3;
            global.wind_drop = true;
            global.wind_drop_myTimer = room_speed;   
            audio_play_sound(PickBat, 10, false);
            instance_create_depth(270, 9, -15000, DropBatObject);
            alarm[0] = 20;
        }
    }
}
 
Top