mapVec mapvec_rotate(mapVec p, mapVec center, float rads, int aboutZ) { //if(fabs(rads) < 0.00001) { return p; } mapVec opt = mapvec_subtract(p, center); if(aboutZ) { float mag = sqrt(opt.x*opt.x+opt.y*opt.y); float baseRad = mapvec_facing_to_radians(opt, 1); float finalRad = baseRad + rads; mapVec rot = (mapVec){cos(finalRad)*mag, sin(finalRad)*mag, opt.z}; return mapvec_add(center, rot); } return p; }
void drawstimuli(Map m, Sensor s) { TCOD_list_t stims = sensor_consume_stimuli(s); unsigned char *tiles; mapVec pos, size, oldPt, delta; unsigned char visflags; if(TCOD_list_size(stims) > 0) { TCOD_console_print_left(NULL, 0, 10, TCOD_BKGND_NONE, " "); } for(int i = 0; i < TCOD_list_size(stims); i++) { //this is a very naive approach that completely ignores the possibility of overdraw and 'forgets' object positions Stimulus st = TCOD_list_get(stims, i); stimtype type = stimulus_type(st); TCOD_console_print_left(NULL, i*2, 10, TCOD_BKGND_NONE, "s%i", type); switch(type) { case StimTileLitChange: case StimTileVisChange: //redraw all tiles tiles = stimulus_tile_sight_change_get_new_tiles(st); pos = stimulus_tile_sight_change_get_position(st); size = stimulus_tile_sight_change_get_size(st); drawtiles(m, tiles, s, pos, size); break; case StimObjLitChange: case StimObjVisChange: //redraw object draw_object(st); break; case StimObjMoved: visflags = stimulus_obj_sight_change_get_new_flags(st); pos = stimulus_obj_sight_change_get_position(st); delta = stimulus_obj_moved_get_dir(st); oldPt = mapvec_subtract(pos, delta); TCOD_console_print_left(NULL, oldPt.x*2, oldPt.y, TCOD_BKGND_NONE, "x"); draw_object(st); TCOD_console_print_left(NULL, 0, 15, TCOD_BKGND_NONE, "got move"); break; case StimGeneric: default: TCOD_console_print_left(NULL, i*9, 16, TCOD_BKGND_NONE, "generic %d", i); break; } stimulus_free(st); } TCOD_list_delete(stims); }