【GAMEMAKER】 Rotating Mini Map


// draw_minimap(map_x, map_y, map_range, vis_x, vis_y, vis_range, angle)
var vx, vy, vm;
// push current transformation state into stack:
d3d_transform_stack_push();
// add transformations to rotate and translate the minimap:
d3d_transform_add_rotation_z(argument6);
d3d_transform_add_translation(argument3, argument4, 0);
// distance multiplier:;
vm = argument5 / argument2;
// draw map border:
draw_set_color(c_white);
draw_circle(0, 0, argument5 + 5, 1);
// draw player:
draw_circle(0, 0, 4, 1);
// draw units:
with (obj_unit) {
// find 'offset' from center:
vx = x - argument0;
vy = y - argument1;
// skip if too far from center:
if (sqrt(vx * vx + vy * vy) > argument2) continue
// draw actual icon:
draw_set_color(c_red);
draw_circle(vx * vm, vy * vm, 4, 1);
}
// restore transformation to what was before running this
d3d_transform_stack_pop(); 


Information about object: obj_center
Sprite: spr_center
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Step Event:
execute code:


if distance_to_point(mouse_x,mouse_y)>2
{   
dir=point_direction(x,y,mouse_x,mouse_y);//get direction to mouse
motion_set(dir,4);//mouse to mouse
}
else speed=0;

if !mouse_check_button(mb_left) speed=0;//if no mouse button pressed don't move


Information about object: map
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Draw Event:
execute code:

draw_set_color(c_red);
draw_line(obj_center.x, obj_center.y, mouse_x, mouse_y);
draw_minimap(obj_center.x, obj_center.y, 320,
60, 60, 50,
90 - point_direction(obj_center.x, obj_center.y, mouse_x, mouse_y));

No comments:

When Bad People Make Good Art

I offer six guidelines on cancel culture ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏...

Contact Form

Name

Email *

Message *