so ive went about making a bar in which the player presses spacebar when the line is in the green zone.
Ive made it as simple as making a sprite which is the bar and greenzone and using it in an object which draws a 1 pixel line that moves back and forward followed by some hard set constants.
it works. it works well but its disgusting.
Ideally id like to draw everything in code. The bar, a green bar within and make some things tweakable so that it can eventually be called from a script. Has anyone programmed something similar?
Ive made it as simple as making a sprite which is the bar and greenzone and using it in an object which draws a 1 pixel line that moves back and forward followed by some hard set constants.
GML:
draw_self();
var sprWidth, sprHeight, max_x, min_x;
sprWidth = sprite_get_width(sprite_index);
sprHeight = sprite_get_height(sprite_index);
min_x = x;
max_x = (x + sprWidth);
draw_line(xx, y-1, xx, (y - 1) + sprHeight);
if (change != 1){
if xx < max_x
{
xx += spd;
} else change = 1;
}
if (change == 1) {
if (xx > min_x)
{
xx -= spd;
} else change = 0;
}
if keyboard_check_pressed(vk_up) && (canPress == true)
{
if (xx > (x + 22) && (xx < x + sprite_width-22))
{
show_message("your charge worked");
} else show_message("you missed your shot");
instance_destroy();
}
it works. it works well but its disgusting.
Ideally id like to draw everything in code. The bar, a green bar within and make some things tweakable so that it can eventually be called from a script. Has anyone programmed something similar?