Luke Pierson
Member
Hey everyone! So I have yet another question. I'm prepping for a game jam by trying to figure out how to do things before actually making the game. I'm trying to implement a compass item that points towards the level exit.
When you pick up the item, it draws the compass in the GUI. The compass sprite has multiple frames, each pointing in a different direction, so I figured setting the image_speed to 0 and the image_index to whatever frame has the direction I want it to point, but that doesn't seem to work...
Here's the code for one of the inventory slots filled with a compass:
The inventory system works just fine, but I have no idea how to make the compass look like it's pointing towards the exit.
When you pick up the item, it draws the compass in the GUI. The compass sprite has multiple frames, each pointing in a different direction, so I figured setting the image_speed to 0 and the image_index to whatever frame has the direction I want it to point, but that doesn't seem to work...
Here's the code for one of the inventory slots filled with a compass:
Code:
if (room != rm_win || room != rm_start) && (slotfull1 = true) && (compass1 = true) {
draw_set_halign(fa_center);
draw_set_valign(fa_bottom);
draw_sprite(spr_compass_inventory, 600, 590, 950);
if (obj_hero.x > instance_nearest(x, y, obj_exit_1).x) && (obj_hero.y < instance_nearest(x, y, obj_exit_1).y) {
image_index = 3;
image_speed = 0;
}
if (obj_hero.x < instance_nearest(x, y, obj_exit_1).x) && (obj_hero.y < instance_nearest(x, y, obj_exit_1).y) {
image_index = 2;
image_speed = 0;
}
if (obj_hero.x > instance_nearest(x, y, obj_exit_1).x) && (obj_hero.y > instance_nearest(x, y, obj_exit_1).y) {
image_index = 0;
image_speed = 0;
}
if (obj_hero.x < instance_nearest(x, y, obj_exit_1).x) && (obj_hero.y > instance_nearest(x, y, obj_exit_1).y) {
image_index = 0;
image_speed = 0;
}
if (obj_hero.x = instance_nearest(x, y, obj_exit_1).x) && (obj_hero.y > instance_nearest(x, y, obj_exit_1).y) {
image_index = 0;
image_speed = 0;
}
if (obj_hero.x = instance_nearest(x, y, obj_exit_1).x) && (obj_hero.y < instance_nearest(x, y, obj_exit_1).y) {
image_index = 1;
image_speed = 0;
}
}