04-28-2020, 01:09 PM
I think this would worked out better:
Explainations:
- Since the brick object is already classified as a solid object. This prevent obj_mario overlap the mask for the brick object. In order to remedy this, collision_rectangle is an extended version of object collision event with far more flexibility. I added the value of 1 plus player's movement speed to have a more accurate collision.
- For an instant trigger event, alarms are not really good with that. Event user is something that's far more useful if you want to activate something instantly.
I wrote the script on my phone so I can't be 100% sure if it works. But under my knowledge it should worked better than it is before. Also, I'm not too sure what do you mean by walk from an angle, it would be easier for me to work on if it has more details about it.
Code:
Step event:
execute code:
var p_hspeed = 0;
var p_vspeed = 0;
if !(instance_exists(obj_mario))
{ exit; }
else
{
p_hspeed = obj_mario.hspeed;
p_vspeed = obj_mario.vspeed;
}
if (global.powerup == 15) && (collision_rectangle(bbox_left-(1+p_hspeed), bbox_top-(1+p_vspeed), bbox_right+(1-p_hspeed), bbox_bottom+(1-p_vspeed), obj_mario, 1, 1))
{
event_user(0);
}
User Event 0 (other events):
execute code:
sound_play(snd_break);
score += 50;
{
ID = instance_create(x+8, y+8, obj_shard)
{
with (ID) motion_set(45, 6);
with (ID) sprite_index = spr_shard_t;
}
ID = instance_create(x+8, y+8, obj_shard);
{
with (ID) motion_set(60, 6);
with (ID) sprite_index = spr_shard_t;
}
ID = instance_create(x+8, y+8, obj_shard);
{
with (ID) motion_set(120, 6);
with (ID) sprite_index = spr_shard_t;
}
ID = instance_create(x+8, y+8, obj_shard);
{
with (ID) motion_set(135, 6);
with (ID) sprite_index = spr_shard_t;
}
}
with (self) instance_destroy();
Explainations:
- Since the brick object is already classified as a solid object. This prevent obj_mario overlap the mask for the brick object. In order to remedy this, collision_rectangle is an extended version of object collision event with far more flexibility. I added the value of 1 plus player's movement speed to have a more accurate collision.
- For an instant trigger event, alarms are not really good with that. Event user is something that's far more useful if you want to activate something instantly.
I wrote the script on my phone so I can't be 100% sure if it works. But under my knowledge it should worked better than it is before. Also, I'm not too sure what do you mean by walk from an angle, it would be easier for me to work on if it has more details about it.