Jump to content


Photo

Code seem to skip to last part


  • Please log in to reply
3 replies to this topic

#1 ChefDavid22

ChefDavid22

    No, YOU shut up!

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

Posted 20 August 2012 - 06:56 PM

I'm using this to detect if there is an object called obj_blue_left and seeing if there is an object to the right of it called obj_blue_right. The ID's of these objects are assigned to global.id1 and global.id2 - then once it checks that if it didnt find any global.id1 and 2 would be 0 thus ending the game.

For some reason it seems to jump right past the check and immediately see id1,2 as 0.

with (parentObject)
{
 if (global.id1 = 0)
  {
   global.idT=instance_position(x+96,y,parentObject);
      
       if global.idT
         {
            if(object_index==obj_blue_left&&global.idT.object_index==obj_blue_right)          
             {
                global.id1=id;
                global.id2=global.idT;
            }
         }
   }       

  if (global.id1 = 0) and (global.id2 = 0)
  {
    global.gameover = true;
  }

 }

  • 0

#2 smash ball

smash ball

    Volcanic Light

  • GMC Member
  • 1117 posts
  • Version:GM7

Posted 20 August 2012 - 07:15 PM

Does it instantly go to the game over or does it never game over? If the first check is an instance that doesn't have a parentObject at x+96,y, you realize that it instantly game overs? If the first check does, then it won't. So it depends on what instance receives the first check.

Edited by smash ball, 20 August 2012 - 07:17 PM.

  • 0

#3 ChefDavid22

ChefDavid22

    No, YOU shut up!

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

Posted 20 August 2012 - 07:20 PM

I figured it out and will ask an admin to remove.

I moved

if (global.id1 = 0) and (global.id2 = 0)
{
global.gameover = true;
}

to a line outside the IF it was a part of and it worked.

To answer your question it was instantly saying game over, even when it wasnt.

Edited by ChefDavid22, 20 August 2012 - 07:21 PM.

  • 0

#4 smash ball

smash ball

    Volcanic Light

  • GMC Member
  • 1117 posts
  • Version:GM7

Posted 20 August 2012 - 07:25 PM

I figured it out and will ask an admin to remove.

Why would you do that? The topic can stay here, it doesn't need to be removed.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users