本文整理汇总了C++中graphicsLib::copyArea方法的典型用法代码示例。如果您正苦于以下问题:C++ graphicsLib::copyArea方法的具体用法?C++ graphicsLib::copyArea怎么用?C++ graphicsLib::copyArea使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graphicsLib
的用法示例。
在下文中一共展示了graphicsLib::copyArea方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_dynamic_backgrounds
void classMap::draw_dynamic_backgrounds()
{
//std::cout << "classMap::draw_dynamic_backgrounds stage_number: " << stage_number << ", map_number: " << number << ", bg.r: " << game_data.stages[stage_number].maps[number].background_color.r << ", bg.g: " << game_data.stages[stage_number].maps[number].background_color.g << ", bg.b: " << game_data.stages[stage_number].maps[number].background_color.b << std::endl;
graphLib.clear_surface_area(0, 0, mapSurface.width, mapSurface.height, game_data.stages[stage_number].maps[number].background_color.r, game_data.stages[stage_number].maps[number].background_color.g, game_data.stages[stage_number].maps[number].background_color.b, graphLib.gameScreen);
if (bg1_surface.width > 0 && game_data.stages[stage_number].maps[number].backgrounds[0].speed != 0) {
int repeat_n = RES_W/bg1_surface.width+1;
if (repeat_n <= 2) {
repeat_n = 3;
}
for (int i=-1; i<repeat_n; i++) {
graphLib.copyArea(st_position(bg1_scroll+i*bg1_surface.width, game_data.stages[stage_number].maps[number].backgrounds[0].adjust_y), &bg1_surface, &graphLib.gameScreen);
}
}
if (bg2_surface.width > 0 && game_data.stages[stage_number].maps[number].backgrounds[1].speed != 0) {
int repeat_n = RES_W/bg2_surface.width+1;
if (repeat_n <= 2) {
repeat_n = 3;
}
//std::cout << "classmap::loadMap - showing bg2 as DYNAMIC - repeat_n: " << repeat_n << std::endl;
for (int i=-1; i<repeat_n; i++) {
//int pos_x = bg2_scroll+i*bg2_surface.width;
//std::cout << "classMap::draw_dynamic_backgrounds - draw bg2 YES - bg2_scroll: " << bg2_scroll << ", pos_x: " << (bg2_scroll+i*bg2_surface.width) << ", width: " << bg2_surface.width << std::endl;
graphLib.copyArea(st_position(bg2_scroll+i*bg2_surface.width, game_data.stages[stage_number].maps[number].backgrounds[1].adjust_y), &bg2_surface, &graphLib.gameScreen);
}
}
}
示例2: drawMap
// ********************************************************************************************** //
// //
// ********************************************************************************************** //
void classMap::drawMap()
{
if (bg1_surface.width > 0 && game_data.stages[stage_number].maps[number].backgrounds[0].speed == 0.0) {
for (int i=0; i<mapSurface.width/bg1_surface.width+1; i++) {
graphLib.copyArea(st_position(i*bg1_surface.width, game_data.stages[stage_number].maps[number].backgrounds[0].adjust_y), &bg1_surface, &mapSurface);
}
bg1_surface.freeGraphic();
}
if (bg2_surface.width > 0 && game_data.stages[stage_number].maps[number].backgrounds[1].speed == 0.0) {
std::cout << "classmap::loadMap - showing bg2 as static" << std::endl;
for (int i=0; i<mapSurface.width/bg2_surface.width+1; i++) {
graphLib.copyArea(st_position(i*bg2_surface.width, game_data.stages[stage_number].maps[number].backgrounds[1].adjust_y), &bg2_surface, &mapSurface);
}
bg2_surface.freeGraphic();
}
struct st_position pos_origin;
struct st_position pos_destiny;
for (int i=0; i<MAP_W; i++) {
for (int j=0; j<MAP_H; j++) {
// level 1
pos_origin.x = map_tiles.tiles[i][j].tile1.x;
pos_origin.y = map_tiles.tiles[i][j].tile1.y;
pos_destiny.x = i*TILESIZE;
pos_destiny.y = j*TILESIZE;
graphLib.placeTile(pos_origin, pos_destiny, &mapSurface);
// level 2
pos_origin.x = map_tiles.tiles[i][j].tile2.x;
pos_origin.y = map_tiles.tiles[i][j].tile2.y;
graphLib.placeTile(pos_origin, pos_destiny, &mapSurface);
}
}
}
示例3: set_player_ref
void class_config::set_player_ref(classPlayer* set_player_ref)
{
player_ref = set_player_ref;
if (_player_surface.width == 0) {
graphLib.initSurface(st_size(player_ref->get_char_frame(ANIM_DIRECTION_RIGHT, ANIM_TYPE_ATTACK, 0)->width, player_ref->get_char_frame(ANIM_DIRECTION_RIGHT, ANIM_TYPE_ATTACK, 0)->height), &_player_surface);
graphLib.copyArea(st_position(0, 0), player_ref->get_char_frame(ANIM_DIRECTION_RIGHT, ANIM_TYPE_ATTACK, 0), &_player_surface);
}
}
示例4: show_leave_game_dialog
bool dialogs::show_leave_game_dialog() const
{
bool res = false;
bool repeat_menu = true;
int picked_n = -1;
timer.pause();
std::cout << ">>>>>>> show_leave_game_dialog::START" << std::endl;
graphicsLib_gSurface bgCopy;
graphLib.initSurface(st_size(RES_W, RES_H), &bgCopy);
graphLib.copyArea(st_position(0, 0), &graphLib.gameScreen, &bgCopy);
graphLib.show_dialog(0, false);
st_position dialog_pos = graphLib.get_dialog_pos();
graphLib.draw_text(dialog_pos.x+30, dialog_pos.y+16, "QUIT GAME?");
std::vector<std::string> item_list;
item_list.push_back("YES");
item_list.push_back("NO");
option_picker main_picker(false, st_position(dialog_pos.x+40, dialog_pos.y+16+11), item_list, false);
draw_lib.update_screen();
while (repeat_menu == true) {
picked_n = main_picker.pick();
std::cout << "picked_n: " << picked_n << std::endl;
if (picked_n == 0) {
res = true;
repeat_menu = false;
} else if (picked_n == 1) {
res = false;
repeat_menu = false;
} else {
main_picker.draw();
}
}
input.clean();
input.waitTime(200);
graphLib.copyArea(st_position(0, 0), &bgCopy, &graphLib.gameScreen);
draw_lib.update_screen();
timer.unpause();
std::cout << ">>>>>>> show_leave_game_dialog::END" << std::endl;
return res;
}
示例5: show_boss_intro_sprites
void draw::show_boss_intro_sprites(short boss_id, bool show_fall)
{
UNUSED(show_fall);
unsigned int intro_frames_n = 0;
//int intro_frames_rollback = 0;
st_position boss_pos(20, -37);
st_position sprite_size;
graphicsLib_gSurface bgCopy, boss_graphics;
std::string graph_filename = FILEPATH + "data/images/sprites/enemies/" + std::string(game_data.game_npcs[boss_id].graphic_filename);
sprite_size.x = game_data.game_npcs[boss_id].frame_size.width;
sprite_size.y = game_data.game_npcs[boss_id].frame_size.height;
graphLib.surfaceFromFile(graph_filename.c_str(), &boss_graphics);
graphLib.initSurface(st_size(RES_W, RES_H), &bgCopy);
graph_filename = FILEPATH + "data/images/backgrounds/stage_boss_intro.png";
graphLib.surfaceFromFile(graph_filename.c_str(), &bgCopy);
st_position bg_pos(0, (RES_H/2)-(bgCopy.height/2));
graphLib.copyArea(bg_pos, &bgCopy, &graphLib.gameScreen);
update_screen();
int sprite_pos_y = RES_H/2 - sprite_size.y/2;
for (int i=0; i<ANIM_FRAMES_COUNT; i++) {
if (game_data.game_npcs[boss_id].sprites[ANIM_TYPE_INTRO][i].used == true) {
intro_frames_n++;
}
}
// fall into position
while (boss_pos.y < sprite_pos_y) {
boss_pos.y += 4;
graphLib.copyArea(bg_pos, &bgCopy, &graphLib.gameScreen);
graphLib.copyArea(st_rectangle(0, 0, sprite_size.x, sprite_size.y), st_position(boss_pos.x, boss_pos.y), &boss_graphics, &graphLib.gameScreen);
graphLib.wait_and_update_screen(5);
}
graphLib.wait_and_update_screen(500);
// show intro sprites
if (intro_frames_n > 1) {
for (int i=0; i<ANIM_FRAMES_COUNT; i++) {
if (game_data.game_npcs[boss_id].sprites[ANIM_TYPE_INTRO][i].used == true) {
//std::cout << "i: " << i << ", used: " << game_data.game_npcs[boss_id].sprites[ANIM_TYPE_INTRO][i].used << ", duration: " << game_data.game_npcs[boss_id].sprites[ANIM_TYPE_INTRO][i].duration << std::endl;
graphLib.copyArea(bg_pos, &bgCopy, &graphLib.gameScreen);
graphLib.copyArea(st_rectangle(sprite_size.x * game_data.game_npcs[boss_id].sprites[ANIM_TYPE_INTRO][i].sprite_graphic_pos_x, 0, sprite_size.x, sprite_size.y), st_position(boss_pos.x, boss_pos.y), &boss_graphics, &graphLib.gameScreen);
graphLib.wait_and_update_screen(game_data.game_npcs[boss_id].sprites[ANIM_TYPE_INTRO][i].duration);
}
}
} else { // just frow first sprite
graphLib.copyArea(bg_pos, &bgCopy, &graphLib.gameScreen);
graphLib.copyArea(st_rectangle(0, 0, sprite_size.x, sprite_size.y), st_position(boss_pos.x, boss_pos.y), &boss_graphics, &graphLib.gameScreen);
graphLib.wait_and_update_screen(200);
}
}
示例6: show_credits
void draw::show_credits()
{
int line_n=0;
unsigned int scrolled=0;
int posY = -RES_H;
st_rectangle dest;
graphicsLib_gSurface credits_surface;
graphLib.initSurface(st_size(RES_W, RES_H+12), &credits_surface);
graphLib.blank_surface(credits_surface);
graphLib.blank_screen();
// add the initial lines to screen
create_credits_text(credits_surface);
update_screen();
// scroll the lines
while (scrolled < (credits_list.size()*12)+RES_H/2+46) {
graphLib.copyArea(st_rectangle(0, posY, RES_W, RES_H), st_position(0, 0), &credits_surface, &graphLib.gameScreen);
update_screen();
timer.delay(60);
posY++;
scrolled++;
if (posY > 12) {
graphLib.copyArea(st_rectangle(0, posY, credits_surface.width, RES_H), st_position(0, 0), &credits_surface, &credits_surface);
// scroll the lines
dest.x = 0;
dest.y = RES_H;
dest.w = RES_W;
dest.h = 12;
graphLib.blank_area(dest.x, dest.y, dest.w, dest.h, credits_surface);
draw_credit_line(credits_surface, line_n+21);
posY = 0;
line_n++;
}
}
update_screen();
}
示例7: change_player_frame_color
void class_config::change_player_frame_color()
{
short int selected_weapon = convert_menu_pos_to_weapon_n(ingame_menu_pos);
CURRENT_FILE_FORMAT::file_weapon_colors colors = player_ref->get_weapon_colors(selected_weapon);
if (colors.color1.r != -1) {
graphLib.change_surface_color(0, colors.color1, &_player_surface);
}
if (colors.color2.r != -1) {
graphLib.change_surface_color(1, colors.color2, &_player_surface);
}
if (colors.color3.r != -1) {
graphLib.change_surface_color(2, colors.color3, &_player_surface);
}
graphLib.copyArea(st_position(26, 190), &_player_surface, &graphLib.gameScreen);
}
示例8: show_ready
void draw::show_ready()
{
st_position dest_pos((RES_W/2)-26, (RES_H/2)-6);
graphLib.copyArea(dest_pos, &ready_message, &graphLib.gameScreen);
graphLib.updateScreen();
}