10 #include "interface.h"
14 static image_t
*g_radar
;
15 static list_t
*listRadar
;
17 typedef struct radar_item_struct
{
23 static radar_item_t
*newRadarItem(int id
, int x
, int y
, int type
)
27 new = malloc(sizeof(radar_item_t
));
36 static void destroyRadarItem(radar_item_t
*p
)
42 void radar_add(int id
, int x
, int y
, int type
)
46 for (i
= 0; i
< listRadar
->count
; i
++) {
47 radar_item_t
*thisRadarItem
;
49 thisRadarItem
= (radar_item_t
*) listRadar
->list
[i
];
51 if (thisRadarItem
->id
== id
) {
54 thisRadarItem
->type
= type
;
59 list_add(listRadar
, newRadarItem(id
, x
, y
, type
));
62 void radar_del(int id
)
66 for (i
= 0; i
< listRadar
->count
; i
++) {
67 radar_item_t
*thisRadarItem
;
69 thisRadarItem
= (radar_item_t
*) listRadar
->list
[i
];
71 if (thisRadarItem
->id
== id
) {
72 list_del_item(listRadar
, i
, destroyRadarItem
);
80 assert(image_is_inicialized() == TRUE
);
81 assert(interface_is_inicialized() == TRUE
);
83 g_radar
= image_add("radar.png", IMAGE_NO_ALPHA
, "radar", IMAGE_GROUP_USER
);
84 listRadar
= list_new();
87 void radar_draw(arena_t
*arena
)
91 image_draw(g_radar
, RADAR_LOCATION_X
, RADAR_LOCATION_Y
, 0, 0, RADAR_SIZE_X
+ 2, RADAR_SIZE_Y
+ 2);
93 for (i
= 0; i
< listRadar
->count
; i
++) {
94 radar_item_t
*thisRadarItem
;
97 thisRadarItem
= (radar_item_t
*) listRadar
->list
[i
];
99 x
= (((float) RADAR_SIZE_X
) / ((float) arena
->w
)) * ((float) thisRadarItem
->x
);
101 y
= (((float) RADAR_SIZE_Y
) / ((float) arena
->h
)) * ((float) thisRadarItem
->y
);
103 if (x
>= 0 && x
<= RADAR_SIZE_X
&& y
>= 0 && y
<= RADAR_SIZE_Y
) {
104 image_draw(g_radar
, RADAR_LOCATION_X
+ 1 + x
, RADAR_LOCATION_Y
+ 1 + y
,
105 2 * thisRadarItem
->type
, RADAR_SIZE_Y
+ 2, 2, 2);
112 list_destroy_item(listRadar
, destroyRadarItem
);