本文整理汇总了C++中draw_map函数的典型用法代码示例。如果您正苦于以下问题:C++ draw_map函数的具体用法?C++ draw_map怎么用?C++ draw_map使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了draw_map函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: grab_key4
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);
}
示例2: launch
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();
}
}
}
}
示例3: grab_key5
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);
}
示例4: draw_editor
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();
}
}
示例5: draw_world
void draw_world(
WORLD *world
)
{
draw_map(0, 0, window_width, window_height, 1,
world->map, world->x, world->y, world->tiles);
}
示例6: kaboom
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;
}
示例7: main
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;
}
示例8: get_map_key
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;
}
示例9: player_init
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;
}
示例10: expose_hook
int expose_hook(t_mlx *mlx)
{
mlx_key_hook(mlx->win, key_hook2, mlx);
if (mlx->init == 1)
draw_map(mlx);
return (0);
}
示例11: grab_key2
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);
}
示例12: wclear
void Lib_Ncurses::fresh()
{
wclear(this->window);
draw_map();
draw_snake();
wrefresh(this->window);
}
示例13: key_hook
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);
}
示例14: draw_readout
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");
}
示例15: Handle_Update
void Handle_Update() {
redraw_screen(REFRESH_NONE);
if(map_visible) draw_map(false);
else mini_map.setVisible(false);
}