int grab_key4(int keycode, t_img *img) { if (keycode == 78) { img->plan.x_a -= img->plan.step_x * WIDTH / 2; img->plan.y_a -= img->plan.step_y * HEIGHT / 2; img->plan.x_b += img->plan.step_x * WIDTH / 2; img->plan.y_b += img->plan.step_y * HEIGHT / 2; img->plan.step_x = (img->plan.x_b - img->plan.x_a) / WIDTH; img->plan.step_y = (img->plan.y_b - img->plan.y_a) / HEIGHT; clear_map(img); draw_map(img); mlx_put_image_to_window(img->mlx_ptr, img->win_ptr, img->img_ptr, 0, 0); } if (keycode == 9) { if (img->c_value == 0) img->c_value = 1; else if (img->c_value == 1) img->c_value = 0; clear_map(img); draw_map(img); mlx_put_image_to_window(img->mlx_ptr, img->win_ptr, img->img_ptr, 0, 0); } return (0); }
void launch() { // This will be hard eventually, as we have to make a map that I haven't done // yet, and figure out how to encode the information. However, for now, I'll // just list ALL the planets, and you can decide which one to jump to. if(player_ship.fuel == 0) { draw_map(current_system); draw_no_fuel(10, 10); getch(); return; } int fuel_usage; int select = current_system; int input; while(true) { draw_map(select); fuel_usage = draw_launch_menu(2, 19, select); refresh(); input = getch(); if(input == 27 || input == 'X' || input == 'x') { return; } if(input >= 'A' && input < 'A' + NUM_OF_STARS) { select = input - 'A'; } if(input >= 'a' && input < 'a' + NUM_OF_STARS) { select = input - 'a'; } if(input == '\t') { select++; if(select == NUM_OF_STARS) select = 0; } if(input == '\n' || input == KEY_ENTER || input == '\r')// '\n works on my machine but the others are // here in case it works on others { if(player_ship.fuel >= fuel_usage) { player_ship.fuel = player_ship.fuel - fuel_usage; current_system = select; return; } else { draw_not_enough_fuel(15, 10); getch(); } } } }
int grab_key5(int keycode, t_img *img) { if (keycode == 15) { set_plan(img); img->zoom = 1; img->flou = 0; img->nb_i = 50; clear_map(img); draw_map(img); mlx_put_image_to_window(img->mlx_ptr, img->win_ptr, img->img_ptr, 0, 0); } if (keycode == 69) { img->plan.x_a += img->plan.step_x * WIDTH / 4; img->plan.y_a += img->plan.step_y * HEIGHT / 4; img->plan.x_b -= img->plan.step_x * WIDTH / 4; img->plan.y_b -= img->plan.step_y * HEIGHT / 4; img->plan.step_x = (img->plan.x_b - img->plan.x_a) / WIDTH; img->plan.step_y = (img->plan.y_b - img->plan.y_a) / HEIGHT; clear_map(img); draw_map(img); mlx_put_image_to_window(img->mlx_ptr, img->win_ptr, img->img_ptr, 0, 0); } if (keycode == 3) img->flou = (img->flou) ? 0 : 1; return (0); }
void draw_editor( char map[MAP_HSIZE][MAP_WSIZE], int delay ){ if( delay ){ timespec req; req.tv_sec = 0; req.tv_nsec = delay; nanosleep( &req, 0 ); draw_map( map, MAP_Y, MAP_X ); refresh(); } else { draw_map( map, MAP_Y, MAP_X ); refresh(); } }
void draw_world( WORLD *world ) { draw_map(0, 0, window_width, window_height, 1, world->map, world->x, world->y, world->tiles); }
int kaboom( char map[MAP_HSIZE][MAP_WSIZE] ){ timespec req; req.tv_sec = 0; req.tv_nsec = 50000000; int die = 0; int i, ii, move; int iy, ix; char obj; for(i = 0; i < MAP_HSIZE; i++) for(ii = 0; ii < MAP_WSIZE; ii++){ if( map[i][ii] == BOMB ){ map[i][ii] = EMPTY; for( move = 0; move < MAX_MV; move++ ){ iy = i + dy[ move ]; ix = ii + dx[ move ]; if( ix >= 0 && iy >= 0 && ix < MAP_WSIZE && iy < MAP_HSIZE ){ obj = map[iy][ix]; if( obj == DIRT || obj == STONE || obj == MONSTER ) map[iy][ix] = EMPTY; if( obj == PLAYER ) die = 1; } } // for move draw_map( map, MAP_Y, MAP_X ); refresh(); nanosleep( &req, 0 ); } // if map == BOMB } // for MAP_WSIZE flushinp(); return die; }
int main(void) { int i; LOGFONT f; int where_table[] = {2, 3, 4, 6, 8, 10, 12, 15, 16, 20}; initgraph(640, 480); loadimage(&welcome_bk, "images/welcome_bk.jpg"); getfont(&f); f.lfHeight = 16; strcpy(f.lfFaceName, "宋体"); f.lfQuality = ANTIALIASED_QUALITY; setfont(&f); // 设置字体样式 welcome(); for(i = 0; i < 10; i++) { cleardevice(); draw_map(where_table[i]); game(where_table[i], i); fflush(stdin); getch(); } cleardevice(); f.lfHeight = 72; setfont(&f); outtextxy(150, 180, "通关训练!"); f.lfHeight = 12; setfont(&f); outtextxy(180, 400, "恭喜您获得了“点灯”挑战资格,敬请期待后序内容!"); Sleep(5000); closegraph(); return 0; }
int get_map_key(int place_cursor) { int key = ERR; if (settings.blink) wtimeout(mapwin, 666); /* wait 2/3 of a second before switching */ if (player.x && place_cursor) { /* x == 0 is not a valid coordinate */ wmove(mapwin, player.y, player.x - 1); curs_set(1); } while (1) { key = nh_wgetch(mapwin); draw_map(player.x, player.y); doupdate(); if (key != ERR) break; }; wtimeout(mapwin, -1); return key; }
struct state_t* player_init( int map_height, int map_width, const square *map, const struct program_t *prg) { struct state_t* state = new struct state_t; init_ncurses(); getmaxyx(stdscr, state->map_height, state->map_width); if ((state->map_height < max(map_height, 7)) || (state->map_width < map_width * 2 + 12 + 2)) { delete state; return NULL; } state->map = map; state->prg = prg; state->pc = 0; state->coord.x = 0; state->coord.y = 0; state->dir = N; state->map_height = map_height; state->map_width = map_width; state->cmd_window = newwin(7, 12, 0, map_width * 2 + 2); state->map_window = newwin(map_height, map_width * 2, 0, 0); arrows[0] = ACS_DARROW; arrows[1] = ACS_RARROW; arrows[2] = ACS_UARROW; arrows[3] = ACS_LARROW; refresh(); draw_program(state); draw_map(state); return state; }
int expose_hook(t_mlx *mlx) { mlx_key_hook(mlx->win, key_hook2, mlx); if (mlx->init == 1) draw_map(mlx); return (0); }
int grab_key2(int keycode, t_img *img) { if (keycode == 53) { free(img); exit(0); } if (keycode == 8) { if (img->type == 's') img->type = 'm'; else if (img->type == 'm') img->type = 'j'; else if (img->type == 'j') img->type = 's'; set_plan(img); clear_map(img); draw_map(img); mlx_put_image_to_window(img->mlx_ptr, img->win_ptr, img->img_ptr, 0, 0); } if (keycode == 36) { img->start = 1; clear_map(img); grab_expose(img); } return (0); }
void Lib_Ncurses::fresh() { wclear(this->window); draw_map(); draw_snake(); wrefresh(this->window); }
int key_hook(int keycode, t_mlx *mlx) { if (keycode == 53) { if (mlx->init == 1) free(mlx->map); mlx_destroy_image(mlx->mlx, mlx->img); mlx_destroy_window(mlx->mlx, mlx->win); free(mlx); exit(0); } if (keycode >= 83 && keycode <= 86) { switch_map(mlx, keycode); if (mlx->init == 0 || (mlx->init == -1 && keycode == 83)) { mlx->map = map_select(mlx); draw_map(mlx); } } if (mlx->init == 1) move(mlx, keycode); if (keycode == 17) respawn(mlx); return (0); }
void CarGPS::draw() { logger->log(DEBUG, "CarGPS::draw", "start"); struct gpf_data data; if (sensor->is_connected()) { sensor->get_data(&data); if (display_type == SENSOR_READOUT) draw_readout(&data); else draw_map(&data); return; } // sensor is not connected draw_string(0, 0, width, height-100, gdTrueColor(250,250,250), conf->get_value("font"), 18, "GPS Receiver not connected"); gdImageCopy(img, graphic, 0, img->sy - graphic->sy, 0, 0, graphic->sx, graphic->sy); update(); logger->log(DEBUG, "CarGPS::draw", "end"); }
void Handle_Update() { redraw_screen(REFRESH_NONE); if(map_visible) draw_map(false); else mini_map.setVisible(false); }
void player_set_dir(struct state_t *state, enum direction dir) { state->dir = dir; draw_map(state); refresh(); usleep(100000); }
void key_s3c(void) { int which_key,i; while((rPDATG & 0xf0)==0xf0); which_key=rPDATG&0xf0; switch(which_key) { case 0xe0: Led_Display(0x1); point.y_point-=20; if(point.y_point<20) point.y_point=200; break; case 0xd0: Led_Display(0x2); point.x_point-=20; if(point.x_point<20) point.x_point=200; break; case 0xb0: Led_Display(0x4); if( map[point.y_map][point.x_map]==0 ) { change_color(); map[point.y_map][point.x_map]=point.color; draw_map(); if( if_won(point.y_map,point.x_map,point.color) ) { GUI_SetTextMode(GUI_DM_TRANS); //设置为透明 GUI_SetFont(&GUI_Font8x16x1x2); GUI_DispStringAt("win!",250,90); for(i=0;i<20;i++) GUI_Delay(1000); map_initial(); GUI_SetDrawMode(GUI_DM_NORMAL); GUI_SetColor(GUI_GREEN); GUI_FillRect(0,0,320,240); draw_net(); draw_point(); } } break; case 0x70: Led_Display(0x7); /* point.x_point+=20; if(point.x_point>200) point.x_point-=20;*/ break; default : break; } }
void draw_reload(t_env *e) { e->img = mlx_new_image(e->mlx, WINDOW_SIZE_W + 100, WINDOW_SIZE_H + 100); e->pixel_img = mlx_get_data_addr(e->img, &(e->bpp), &(e->s_line), &(e->ed)); draw_map(e); mlx_put_image_to_window(e->mlx, e->win, e->img, -50, -50); mlx_destroy_image(e->mlx, e->img); }
void MapPanelLogic::on_paint(wxPaintEvent& wx_paint_event) { wxPaintDC dc(_map_scrolled_window); _map_scrolled_window->PrepareDC(dc); draw_map(wx_paint_event, dc); }
void draw(World * w) { memset(screen_buffer, 0, sizeof(CHAR_INFO) * BUFFER_CX * BUFFER_CY); draw_map(w); draw_system(w); draw_fps(); write_scr((CHAR_INFO *) screen_buffer, BUFFER_CX, BUFFER_CY); }
int main() { std::string input_file = "~/Dropbox/mapper_proj/toronto.osm.bin"; draw_map(input_file); return 0; }
void player_set_coord(struct state_t *state, struct coord_t coord) { (void)mvwaddch(state->map_window, state->coord.y, state->coord.x * 2 + 1, ' '); state->coord = coord; draw_map(state); refresh(); usleep(100000); }
void move_player(enum direction direction){ int x, y, ele; int xx, yy; struct square *from, *to; struct tile *tilefrom, *tileto; x = xx = player.x; y = yy = player.y; ele = player.ele; switch(direction){ case(NW): xx = x - 1; case(N): yy = y - 1; break; case(SW): yy = y + 1; case(W): xx = x - 1; break; case(SE): xx = x + 1; case(S): yy = y + 1; break; case(NE): yy = y - 1; case(E): xx = x + 1; break; } tilefrom = get_tile(pos_div(x, TILESIZE), pos_div(y, TILESIZE), 0); if(pos_div(x, TILESIZE) == pos_div(xx, TILESIZE) && pos_div(y, TILESIZE) == pos_div(yy, TILESIZE)) tileto = tilefrom; else tileto = get_tile(pos_div(xx, TILESIZE), pos_div(yy, TILESIZE), 0); from = tilefrom->type == Array? SQUARE(tilefrom->tile.sq, pos_mod(x, TILESIZE), pos_mod(y, TILESIZE)) : tilefrom->tile.fill; to = tileto->type == Array? SQUARE(tileto->tile.sq, pos_mod(xx, TILESIZE), pos_mod(yy, TILESIZE)) : tileto->tile.fill; // TODO handle elevation / going to adjacent layers if(to->c){ // TODO FIGHT or do other things I guess hit(to->c,&player); } else { // try moving switch(to->terrain){ case(TERRAIN_ROCK_WALL): putmsg("You bump into a wall."); break; default: from->c = 0; player.x = xx; player.y = yy; to->c = &player; draw_map(xx, yy, ele); } } }
void car_facing_up(int startx, int starty, int finy) { startx -= 10; starty -= 15; finy -= 10; int i; XClearWindow(dis, win); XFlush(dis); //draw triangle if (starty == finy) { i = starty; XPoint points[] = { {(startx), (i + 30)}, {(startx + 10), (i + 45)}, {(startx + 20), (i + 30)}, }; int npoints = sizeof (points) / sizeof (XPoint); //draw background first XClearWindow(dis, win); draw_map(); grid_map(); //draw the car XDrawRectangle(dis, win, green_gc, startx, i, 20, 30); XDrawLines(dis, win, green_gc, points, npoints, CoordModeOrigin); XFlush(dis); } else { for (i = starty; i > finy; i -= 10) { XPoint points[] = { {(startx), (i)}, {(startx + 10), (i - 15)}, {(startx + 20), (i)}, }; int npoints = sizeof (points) / sizeof (XPoint); //draw background first XClearWindow(dis, win); draw_map(); grid_map(); //draw the car XDrawRectangle(dis, win, green_gc, startx, i, 20, 30); XDrawLines(dis, win, green_gc, points, npoints, CoordModeOrigin); XFlush(dis); } } }
int expose_listener(void *param) { t_world *world; world = (t_world*)param; draw_reset(world); draw_map(world); draw_stats(world); return (0); }
int main(int argc, char *argv[]) { char filename[128]; snprintf(filename, sizeof(filename), "%s/images/krmap.png", getenv("HOME")); draw_map(filename); printf("It worked!\n"); return 0; }
void GameArea::drawArea() { _game_area->fill(_area_color); if (_grid) draw_grid(); draw_map(); update(); }
int gfx_engine() { test_function();// used for debug commands and stuff. draw_ui(); // draws the ui and compress all buffers down to the screen_buffer, so only one draw to the screen is made. draw_map();// draws the individual tiles that correspond to the tile numbers in the map array. blit (screen_buffer, screen, 0,0,0,0,1024,768); rectfill (screen_buffer, 0,0,1024,768,makecol(0,0,0)); return 0; }
void car_facing_right(int startx, int starty, int finx) { startx -= 15; starty -= 10; finx -= 15; int i; XClearWindow(dis, win); XFlush(dis); //draw triangle if (finx == startx) { i = startx; XPoint points[] = { {(i + 30), (starty)}, {(i + 45), (starty + 10)}, {(i + 30), (starty + 20)}, }; int npoints = sizeof (points) / sizeof (XPoint); //draw background first XClearWindow(dis, win); draw_map(); grid_map(); //draw the car XDrawRectangle(dis, win, green_gc, i, starty, 30, 20); XDrawLines(dis, win, green_gc, points, npoints, CoordModeOrigin); XFlush(dis); } else { for (i = startx; i < finx; i += 10) { XPoint points[] = { {(i + 30), (starty)}, {(i + 45), (starty + 10)}, {(i + 30), (starty + 20)}, }; int npoints = sizeof (points) / sizeof (XPoint); //draw background first XClearWindow(dis, win); draw_map(); grid_map(); //draw the car XDrawRectangle(dis, win, green_gc, i, starty, 30, 20); XDrawLines(dis, win, green_gc, points, npoints, CoordModeOrigin); XFlush(dis); } } }
//@@@@@@@@@@@@@@@@@@@@ 覆盖背景,重画方格 @@@@@@@@@@@@@@@@@@@@@@ void display_all(void) { GUI_SetColor(GUI_GREEN); GUI_FillRect(0,0,320,240); draw_net(); draw_map(); draw_point(); }