KungFuChowder
Member
Hello guys. It's been a little while since I've posted.
I got this minimap for free off of this page here: Github Location and it's been a nice addition to the project. However, I'm stepping out in hopes that I may find a way to convert this system that uses the bbox of each object to draw a rectangle to instead draw a desired sprite in it's place. I've made up a variety of sprites that I want to represent each different class of ship and I've been making changes to the code to try and get this to work. The problem is that it's not finding the sprite and I get an error. My intuition with the code in the drawGUI event isn't properly grabbing the sprite from the list on the create event. Any ideas of what I could do to get this to work for me?
Create:
Draw GUI:
I got this minimap for free off of this page here: Github Location and it's been a nice addition to the project. However, I'm stepping out in hopes that I may find a way to convert this system that uses the bbox of each object to draw a rectangle to instead draw a desired sprite in it's place. I've made up a variety of sprites that I want to represent each different class of ship and I've been making changes to the code to try and get this to work. The problem is that it's not finding the sprite and I get an error. My intuition with the code in the drawGUI event isn't properly grabbing the sprite from the list on the create event. Any ideas of what I could do to get this to work for me?
Create:
GML:
x = 1130;
y = 495;
scale = 0.05;
width = round(room_width * scale);
height = round(room_height * scale);
objects_to_draw = [
Obj_Swarmer, c_lime, spr_alien,
obj_pun, c_lime, spr_alien,
obj_outrider, c_lime, spr_alien,
obj_scout, c_lime, spr_alien,
obj_Aura, c_white, spr_cruiser,
obj_une, c_white, spr_cruiser,
obj_aegis, c_white, spr_battleship,
obj_wasp, c_white, spr_miner,
obj_judgement, c_white, spr_dreadnought,
obj_sentinel, c_white, spr_battleship,
obj_base, c_blue, spr_basesquare,
obj_frion, c_purple, spr_planet,
obj_une_base, c_ltgray, spr_basesquare,
Object2, c_orange, spr_planet,
obj_comminer, c_white, spr_miner,
obj_levi, c_white, spr_dreadnought,
obj_drake, c_ltgray, spr_cruiser,
obj_omen, c_ltgray, spr_battleship,
]
background_color = c_black;
global.map_on = false;
Code:
if instance_exists(global.target){
if (global.map_on = true){
if (global.target != obj_une_base){
if (global.target != obj_base){
draw_sprite_stretched(spr_waybutt, 0, 1045, 408, 550, 550);
draw_set_color(c_white);
draw_set_font(fnt_digital);
draw_text(1147, 471, string(round(global.target.x))+"/"+string(round(global.target.y)));
draw_set_color(background_color);
draw_rectangle(x, y, x + width, y + height, false);
//Drawing Instances
for(var i = 0; i < array_length_1d(objects_to_draw); i += 2) {
var map_object_index = objects_to_draw[i],
map_object_color = objects_to_draw[i + 1],
map_object_sprite = objects_to_draw[i + 2];
draw_set_color(map_object_color);
for(var j = 0; j < instance_number(map_object_index); j++) {
var instance = instance_find(map_object_index, j),
current_left = instance.bbox_left * scale,
current_top = instance.bbox_top * scale,
current_right = instance.bbox_right * scale,
current_bottom = instance.bbox_bottom * scale,
current_imageangle = instance.image_angle;
draw_rectangle(x + current_left, y + current_top, x + current_right, y + current_bottom, false);
draw_sprite_ext(map_object_sprite, 0, map_object_index.x, map_object_index.y, scale, scale, current_imageangle, c_white, 1);
}
}
}
}
}
}