Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

Making A Bomb Fire From Under My Boss?, in a 2d platforming game?


Recommended Posts

I'm made a script in the step event of the boss where my boss fires a bomb from right under the ship. But it does'nt work the bomb fires in different places of the room. And I want the bomb to create from under the ship. Here is 2 samples of the code: And also i'm using Game Maker 6

if ( can_bomb = 1)
{
instance_create(obj_eggman.35,obj_eggman.50,obj_bomb);
sound_play(bombdrop)
alarm[0] = 10;
can_bomb = 0;
}[/CODE]

[CODE]if ( can_bomb = 1)
{
instance_create(view_xview + 35,view_yview + 50,obj_bomb);
sound_play(bombdrop)
alarm[0] = 10;
can_bomb = 0;
}[/CODE]

But it just fires in other places of the room can anyone help me with this?

Link to comment
Share on other sites

"instance_create(obj_eggman.35,obj_eggman.50,obj_bomb);"

obj_eggman.35? Heh, seems like you mixing semantics.

Anyway, to get a variable stored in a different object, it's "object_name.variable_name", so for obj_eggman's x variable it'd be "obj_eggman.x". Of course, that's not needed if this code is being operated from the object "obj_eggman", you'd just say "x".

Here's what the code should look like:

if ( can_bomb = 1)
{
   instance_create(obj_eggman.x+35,obj_eggman.y+50,obj_bomb);
   sound_play(bombdrop)
   alarm[0] = 10;
   can_bomb = 0;
}

Link to comment
Share on other sites

There are a couple of cases where semicolons are needed (maybe more):

-After the var statement (ex: var xx; )

-In for loops (ex: for(x=0; x<10; x+=1))

-Sometimes whenever you're using an explicity ID# to get its variables (ex: (100101).x)

Generally semicolons are optional in GML, but it's probably bad habbit to not have them since they can cause very weird and hard to tracable errors in very rare cases.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...