Skip to content

Commit 509eb58

Browse files
committed
Stop using the weird coord struct and add a hit method
1 parent d348051 commit 509eb58

4 files changed

Lines changed: 35 additions & 25 deletions

File tree

objects/obj_enunit/Create_0.gml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ composition_string="";
2020
pos = 880;
2121
centerline_offset = 0;
2222
draw_size = 0;
23-
23+
x1 = pos + (centerline_offset * 2);
24+
y1 = 450 - (draw_size / 2);
25+
x2 = pos + (centerline_offset * 2) + 10;
26+
y2 = 450 + (draw_size / 2);
2427

2528
enemy=0;
2629
enemy2=0;
@@ -79,3 +82,7 @@ if (obj_ncombat.enemy=1) then alarm[6]=10;
7982

8083
// if (obj_ncombat.enemy=1){alarm[1]=8;alarm[5]=10;}
8184

85+
86+
hit = function() {
87+
return scr_hit(x1, y1, x2, y2) && obj_ncombat.fadein <= 0;
88+
};

objects/obj_enunit/Draw_0.gml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,18 @@ if (draw_size > 0){
88
centerline_offset=x-obj_centerline.x;
99
}
1010

11-
var _draw_coords = {
12-
x1: pos + (centerline_offset * 2),
13-
y1: 450 - (draw_size / 2),
14-
x2: pos + (centerline_offset * 2) + 10,
15-
y2: 450 + (draw_size / 2)
16-
};
11+
x1 = pos + (centerline_offset * 2);
12+
y1 = 450 - (draw_size / 2);
13+
x2 = pos + (centerline_offset * 2) + 10;
14+
y2 = 450 + (draw_size / 2);
1715

18-
var _hit = scr_hit(_draw_coords.x1, _draw_coords.y1, _draw_coords.x2, _draw_coords.y2) && obj_ncombat.fadein <= 0;
19-
20-
if (_hit) {
16+
if (hit()) {
2117
draw_set_alpha(0.8);
2218
}
23-
draw_rectangle(_draw_coords.x1, _draw_coords.y1, _draw_coords.x2, _draw_coords.y2, 0);
2419

25-
if (_hit) {
20+
draw_rectangle(x1, y1, x2, y2, 0);
21+
22+
if (hit()) {
2623
if (unit_count != unit_count_old) {
2724
unit_count_old = unit_count;
2825
if (obj_ncombat.enemy!=1){
@@ -74,7 +71,7 @@ if (draw_size > 0){
7471
}
7572
}
7673

77-
draw_block_composition(_draw_coords.x1, composition_string);
74+
draw_block_composition(x1, composition_string);
7875
}
7976

8077
draw_block_fadein();

objects/obj_pnunit/Create_0.gml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ column_size = 0;
2020
centerline_offset = 0;
2121
pos = 880;
2222
draw_size = 0;
23+
x1 = pos + (centerline_offset * 2);
24+
y1 = 450 - (draw_size / 2);
25+
x2 = pos + (centerline_offset * 2) + 10;
26+
y2 = 450 + (draw_size / 2);
27+
2328
// let="";let=string_delete(obj_ini.psy_powers,2,string_length(obj_ini.psy_powers)-1);let=string_upper(let);
2429
// LET might be different for each marine; need a way of determining this
2530

@@ -117,3 +122,7 @@ hostile_splash=0;
117122
alarm[1]=4;
118123

119124
action_set_alarm(1, 3);
125+
126+
hit = function() {
127+
return scr_hit(x1, y1, x2, y2) && obj_ncombat.fadein <= 0;
128+
};

objects/obj_pnunit/Draw_0.gml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,23 @@ if (draw_size > 0){
1515
draw_set_color(c_gray);
1616
}
1717

18-
var _draw_coords = {
19-
x1: pos + (centerline_offset * 2),
20-
y1: 450 - (draw_size / 2),
21-
x2: pos + (centerline_offset * 2) + 10,
22-
y2: 450 + (draw_size / 2)
23-
};
18+
x1 = pos + (centerline_offset * 2);
19+
y1 = 450 - (draw_size / 2);
20+
x2 = pos + (centerline_offset * 2) + 10;
21+
y2 = 450 + (draw_size / 2);
2422

25-
var _hit = scr_hit(_draw_coords.x1, _draw_coords.y1, _draw_coords.x2, _draw_coords.y2) && obj_ncombat.fadein <= 0;
26-
27-
if (_hit) {
23+
if (hit()) {
2824
draw_set_alpha(0.8);
2925
}
30-
draw_rectangle(_draw_coords.x1, _draw_coords.y1, _draw_coords.x2, _draw_coords.y2, 0);
3126

32-
if (_hit) {
27+
draw_rectangle(x1, y1, x2, y2, 0);
28+
29+
if (hit()) {
3330
if (unit_count != unit_count_old) {
3431
unit_count_old = unit_count;
3532
composition_string = block_composition_string();
3633
}
37-
draw_block_composition(_draw_coords.x1, composition_string);
34+
draw_block_composition(x1, composition_string);
3835
}
3936

4037
draw_block_fadein()

0 commit comments

Comments
 (0)