void map_flare_add(int index, int player, unsigned int duration, unsigned int radius) { int w=map->layer[map->layers-2].tilemap->w; int h=map->layer[map->layers-2].tilemap->h; int tile_w=map->layer[map->layers-2].tile_w; int tile_h=map->layer[map->layers-2].tile_h; int x=index%w; int y=index/w; struct MAP_FLARE_LIST **l; for(l=&map_flares; *l; l=&((*l)->next)); *l=malloc(sizeof(struct MAP_FLARE_LIST)); (*l)->circle[0]=d_render_circle_new(16, 1); d_render_circle_move((*l)->circle[0], x*tile_w+tile_w/2, y*tile_h+tile_h/2, radius/4); (*l)->circle[1]=d_render_circle_new(16, 1); d_render_circle_move((*l)->circle[1], x*tile_w+tile_w/2, y*tile_h+tile_h/2, radius/2); (*l)->circle[2]=d_render_circle_new(24, 1); d_render_circle_move((*l)->circle[2], x*tile_w+tile_w/2, y*tile_h+tile_h/2, 3*radius/4); (*l)->circle[3]=d_render_circle_new(24, 1); d_render_circle_move((*l)->circle[3], x*tile_w+tile_w/2, y*tile_h+tile_h/2, radius); (*l)->minimap_circle=d_render_circle_new(6, 1); d_render_circle_move((*l)->minimap_circle, game_sidebar_minimap->x+(x*(game_sidebar_minimap->w))/(w), game_sidebar_minimap->y+(y*(game_sidebar_minimap->h))/(h), 3); (*l)->index=0; (*l)->player=player; (*l)->duration=duration; (*l)->created=d_time_get(); (*l)->next=NULL; }
void map_select_building(int index) { map_selected.index=index; int selected_building=(map->layer[map->layers-2].tilemap->data[index]&0xFFFF); map_selected.owner=selected_building/tilesx-1; map_selected.building=selected_building%tilesx+1; if(map_selected.owner<0||map_selected.owner>players-1) { map_selected.building=0; map_selected.index=-1; map_selected.owner=-1; } if(map_selected.building&&building[map_selected.building].range) { map_selected.circle=d_render_circle_new(32, 1); int w=map->layer[map->layers-2].tilemap->w; //int h=map->layer[map->layers-2].tilemap->h; int tile_w=map->layer[map->layers-2].tile_w; int tile_h=map->layer[map->layers-2].tile_h; int x=index%w; int y=index/w; d_render_circle_move(map_selected.circle, x*tile_w+tile_w/2, y*tile_h+tile_h/2, building[map_selected.building].range*tile_w); } else map_selected.circle=d_render_circle_free(map_selected.circle); game_update_building_status(); }
void draw_graph(struct GRAPH *g) { int i, j; int a, b; struct EDGE *e; vertices=edges=0; if(!g) return; for(i=0, j=0; g; g=g->next, i++) { d_render_circle_move(circle[i], g->vertex->point.x, g->vertex->point.y, 10); for(e=g->vertex->neighbour; e; e=e->next, j++) { d_render_line_move(line[j], 0, g->vertex->point.x, g->vertex->point.y, e->vertex->point.x, e->vertex->point.y); a=MAX(g->vertex->point.x, e->vertex->point.x)-MIN(g->vertex->point.x, e->vertex->point.x); b=MAX(g->vertex->point.y, e->vertex->point.y)-MIN(g->vertex->point.y, e->vertex->point.y); length[i]=(a+b)/4; printf("length %i\n", length[i]); } } vertices=i; edges=j; }