• 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!

Boss Floating To The Top Of Room

A

AlphaRedDragon

Guest
so i am working on a game where one of the bosses is meant to jump above you and fall and crush blocks below him, kinda like one of the mario boss fights,will post image link. but when i run the game he always hovers at the top and when he falls, he breaks a block and goes back to the top, basically the oppisate of what he is supposed to do. i will post the code below, thank you for your help


http://mariowiki.jixun.org/images/0/0a/1st_ground_pound.PNG
(what he is supposed to do)

vatiable global.falling_earth is to detect when he is falling to crush a block.

(step Event Code)

cooldown -=1


if(cooldown <=0)
{
cooled = 0
jumped = 1



}

if(jumped = 1)
{
if(obj_player.x < obj_earth_boss.x)
{
global.jump_dir = -1

}
else
{
global.jump_dir = 1

}

if(global.falling_earth = 0)
{
if(global.jump_dir = -1)
{
vsp = -10
hsp = -8


}
if(global.jump_dir = 1)
{
vsp = -10
hsp = 8
}




}

if(obj_earth_boss.x = obj_player.x)
{
global.falling_earth = 1;

}

if(global.falling_earth = 1)
{
vsp = 25
hsp = 0



}




}

if(vsp <= 10)
{

vsp += grav


}

if(jumped =0)
{
if(cooled = 0)
{
cooled = 1;
cooldown = 300;



}


}


// horizantal collission

if (place_meeting(x+hsp,y,obj_collide))
{
while(!place_meeting(x+sign(hsp),y,obj_collide))
{
x += sign(hsp);
}
hsp = 0;
}
//vert collision

if (place_meeting(x,y+vsp,obj_collide))
{
while(!place_meeting(x,y+sign(vsp),obj_collide))
{
y += sign(vsp);
}
vsp = 0;
jumped = 0;
}


x+= hsp
y+= vsp
 
A

Allegro

Guest
First, why use global variables to handle things local to the instance?

When you say breaking a block and and not returning to a different state is not what he's supposed to do, but post the Mario Bros 3 Bowser fight, I get mixed signals. What you make it sound like you want is for the enemy to function like Big Thwomp in Mario Maker - fall over the player and plow through the floor, never to be seen again.

If that is the case, why not just make him not physically collide with the floor, but instead go through it, then in a collision event, destroy the blocks he "collided" with?
 

TheouAegis

Member
He's saying he wants the Bowser fight, but the boss isn't doing that. Instead of standing on the ground and jumping up, it's floating in the air, falls down, then jumps back up. I'd look over it more, but I gotta get to work.

At a glance, without seeing your creation code, I'd say you set grav to a negative number.
 
A

AlphaRedDragon

Guest
First, why use global variables to handle things local to the instance?

When you say breaking a block and and not returning to a different state is not what he's supposed to do, but post the Mario Bros 3 Bowser fight, I get mixed signals. What you make it sound like you want is for the enemy to function like Big Thwomp in Mario Maker - fall over the player and plow through the floor, never to be seen again.

If that is the case, why not just make him not physically collide with the floor, but instead go through it, then in a collision event, destroy the blocks he "collided" with?

i kinda wanted to make a mix between both of them, like the big thwomp but omly break one of the blocks each time he falls. so basically when you start, he waits a bit, jumps in your direction, and when he is above you, become like a big thwomp and fall and break one block bellow him, then wait a bit, and do that over until he breaks all the blocks and dies in a pit
 
W

Wild_West

Guest
i kinda wanted to make a mix between both of them, like the big thwomp but omly break one of the blocks each time he falls. so basically when you start, he waits a bit, jumps in your direction, and when he is above you, become like a big thwomp and fall and break one block bellow him, then wait a bit, and do that over until he breaks all the blocks and dies in a pit
if it were me, I'd probably set up the boss like this :

/// In Create event

//set a timer for a jump
jump = number to wait;

///step event

jump -= 1;

//when jump hits 0
if (jump <= 0)
{
if (player.x < x)
{
//leave the jump timer at 0 until done smashing
jump = 0;
vspeed = - some number for jump height
hspeed = - some number to move left by

//if your height over the player matches how high you jumped, stop moving left and try to crush
if( place_meeting(x, ,y - it's jump height, player) )
{
hspeed = 0;
vspeed = a fall speed;
jump = starting number again;
}
}
}
then in the boss' collision with the blocks, have it bounce off after saying with( other ){ instance_destroy(); }
and then vspeed = - some number until it becomes less than either a max height or the room's height depending on how big the room is.

and if you want it to go back to the ground just have it choose a direction move it in the Xaxis and send it down until it makes contact with the floor.

You'd probably wanna set a variable for the "state" it's currently in, like is_falling so it only destroys a block upon touching it while that's set to true.

Anyway don't know if that helps but it's how I'd d it.

My code never works right on the first go but I've gotten all my enemies completed using these kinds of methods so , yeah. lol
 
A

AlphaRedDragon

Guest
if it were me, I'd probably set up the boss like this :

/// In Create event

//set a timer for a jump
jump = number to wait;

///step event

jump -= 1;

//when jump hits 0
if (jump <= 0)
{
if (player.x < x)
{
//leave the jump timer at 0 until done smashing
jump = 0;
vspeed = - some number for jump height
hspeed = - some number to move left by

//if your height over the player matches how high you jumped, stop moving left and try to crush
if( place_meeting(x, ,y - it's jump height, player) )
{
hspeed = 0;
vspeed = a fall speed;
jump = starting number again;
}
}
}
then in the boss' collision with the blocks, have it bounce off after saying with( other ){ instance_destroy(); }
and then vspeed = - some number until it becomes less than either a max height or the room's height depending on how big the room is.

and if you want it to go back to the ground just have it choose a direction move it in the Xaxis and send it down until it makes contact with the floor.

You'd probably wanna set a variable for the "state" it's currently in, like is_falling so it only destroys a block upon touching it while that's set to true.

Anyway don't know if that helps but it's how I'd d it.

My code never works right on the first go but I've gotten all my enemies completed using these kinds of methods so , yeah. lol

that could work, i have a few questions though. first, if i use a with statement to instance_destroy the block, wont that destroy all of the blocks? also, what do you mean by this


//if your height over the player matches how high you jumped, stop moving left and try to crush
if( place_meeting(x, ,y - it's jump height, player) )


cant i do if(player.x = x)?
 

TheouAegis

Member
with (other) inside an actual collision event would destroy the block the boss collided with and nothing else.

Or you could do in code

with instance_position(bbox_left+bbox_right>>1, bbox_bottom, obj_block) instance_destroy();

That'd destroy the block directly below the center of the boss when he falls.


As for "if player.x == x", no you can't do that. The odds of the player's x ever equaling the boss's x are actually very slim. His method would make sure the boss is at least over the player.

Alternatively:

if bbox_left < player.bbox_right && bbox_right > player.bbox_left

That might be better than his method, since it's essentially what he's trying to do but with fewer calculations.
 
W

Wild_West

Guest
that could work, i have a few questions though. first, if i use a with statement to instance_destroy the block, wont that destroy all of the blocks? also, what do you mean by this


//if your height over the player matches how high you jumped, stop moving left and try to crush
if( place_meeting(x, ,y - it's jump height, player) )


cant i do if(player.x = x)?
Oh yeah that should be fine too, was just following my own train of thought for how it was moving.
Like once your above he player only in case the player tries to jump over the boss, the boss shouldn't try to crush then obviously but that can be avoided with the is jumping variable status.

But for the blocks all being destroyed, no that shouldn't happen, if you use the "other" keyword, so that'll reference ONLY the other block that's currently colliding with the boss, not just every block in the room. but if it does you can always get the block object's instance id so only that one is destroyed.
 
Top