本文整理汇总了C++中inputLib类的典型用法代码示例。如果您正苦于以下问题:C++ inputLib类的具体用法?C++ inputLib怎么用?C++ inputLib使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了inputLib类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: show_timed_dialog
void dialogs::show_timed_dialog(std::string face_file, bool is_left, std::string lines[], short delay, bool show_btn=true)
{
UNUSED(is_left);
std::string temp_text;
char temp_char;
timer.pause();
draw_dialog_bg(show_btn);
draw_lib.update_screen();
st_position dialog_pos = graphLib.get_dialog_pos();
graphLib.place_face(face_file, st_position(dialog_pos.x+16, dialog_pos.y+16));
draw_lib.update_screen();
/// @TODO: usar show_config_bg e hide_config_bg da graphLib - modificar para aceitar centered (que é o atual) ou top ou bottom
for (int i=0; i<3; i++) {
for (unsigned int j=0; j<lines[i].size(); j++) {
temp_char = lines[i].at(j);
temp_text = "";
temp_text += temp_char;
graphLib.draw_text(j*9+(dialog_pos.x+52), i*11+(dialog_pos.y+16), temp_text);
//graphLib.draw_text(j*9+53, i*11+9, "A");
draw_lib.update_screen();
input.waitTime(15);
}
}
input.waitTime(delay);
timer.unpause();
}
示例2: show_scene
void sceneShow::show_scene(int n)
{
if (n < 0) {
return;
}
if (scene_list.size() <= n) {
std::cout << "ERROR: Scene List[" << n << "] invalid. List size is " << image_scenes.size() << "." << std::endl;
return;
}
CURRENT_FILE_FORMAT::file_scene_list scene = scene_list.at(n);
input.clean();
for (int i=0; i<SCENE_OBJECTS_N; i++) {
input.read_input();
int scene_seek_n = scene.objects[i].seek_n;
//std::cout << ">> sceneShow::show_scene - i: " << i << ", scene_seek_n: " << scene_seek_n << std::endl;
if (_interrupt_scene == true || input.p1_input[BTN_START] == 1) {
scene_seek_n = -1;
break;
}
if (scene_seek_n != -1) {
int scene_type = scene.objects[i].type;
//std::cout << "### scene_type[" << scene_type << "]" << std::endl;
if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_SHOW_TEXT) {
show_text(scene_seek_n);
} else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_CLEAR_AREA) {
clear_area(scene_seek_n);
} else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_CLEAR_SCREEN) {
graphLib.clear_area(0 ,0, RES_W, RES_H, 0, 0, 0);
} else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_MOVE_IMAGE) {
show_image(scene_seek_n);
} else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_MOVE_VIEWPOINT) {
show_viewpoint(scene_seek_n);
} else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_PLAY_MUSIC) {
play_music(scene_seek_n);
} else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_PLAY_SFX) {
play_sfx(scene_seek_n);
} else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_SHOW_ANIMATION) {
show_animation(scene_seek_n, scene.objects[i].repeat_value, scene.objects[i].repeat_type);
} else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_STOP_MUSIC) {
soundManager.stop_music();
} else if (scene_type == CURRENT_FILE_FORMAT::SCENETYPE_SUBSCENE) {
show_scene(scene_seek_n);
} else {
std::cout << ">> sceneShow::show_scene - unknown scene_type[" << scene_type << "]" << std::endl;
}
std::cout << "show_scene::DELAY[" << i << "][" << scene.objects[i].delay_after << "]" << std::endl;
if (input.waitScapeTime(scene.objects[i].delay_after) == 1) {
_interrupt_scene = true;
}
} else {
break;
}
}
std::cout << "show_scene::DONE" << std::endl;
}
示例3: show_ingame_warning
void draw::show_ingame_warning(std::vector<std::string> message)
{
graphLib.show_dialog(0, true);
st_position dialog_pos = graphLib.get_dialog_pos();
for (unsigned int i=0; i<message.size(); i++) {
graphLib.draw_text(dialog_pos.x+20, dialog_pos.y+16+(12*i), message[i]);
}
input.clean();
input.wait_keypress();
}
示例4: redraw_boss_door
/// @TODO: fix animation. investigate a better way for drawing it (code is way too confusing)
void classMap::redraw_boss_door(bool is_close, int nTiles, int tileX, short player_number) {
int k, tileCount;
//is_close = false; // THIS IS A TEMPORARY FIX
//std::cout << "classMap::redraw_boss_door - is_close: " << is_close << std::endl;
input.waitTime(10);
//for (k=0; k<tilePieces; k++) {
for (k=0; k<nTiles; k++) {
tileCount = nTiles;
//if (is_close == false) { std::cout << "classMap::redraw_boss_door - nTiles: " << nTiles << ", tilePieces: " << tilePieces << ", tileCount: " << tileCount << std::endl; }
// redraw screen
showMap();
graphLib.updateScreen();
int tiles_showed;
if (is_close == false) {
tiles_showed = k;
} else {
tiles_showed = 0;
}
for (int i=0; i<MAP_W; i++) {
for (int j=0; j<MAP_H; j++) {
if (map_tiles.tiles[i][j].tile3.x != -1 && map_tiles.tiles[i][j].tile3.y != -1) {
if (i == tileX && map_tiles.tiles[i][j].locked == TERRAIN_DOOR) {
//std::cout << "****** redraw_boss_door - k: " << k << ", tiles_showed: " << tiles_showed << ", nTiles: " << nTiles << std::endl;
if (is_close == false) {
if (tiles_showed < nTiles) {
graphLib.placeTile(st_position(map_tiles.tiles[i][j].tile3.x, map_tiles.tiles[i][j].tile3.y), st_position((i*TILESIZE)-scroll.x, (j*TILESIZE)-scroll.y), &graphLib.gameScreen);
graphLib.updateScreen();
tiles_showed++;
}
} else {
if (tiles_showed < k) {
graphLib.placeTile(st_position(map_tiles.tiles[i][j].tile3.x, map_tiles.tiles[i][j].tile3.y), st_position((i*TILESIZE)-scroll.x, (j*TILESIZE)-scroll.y), &graphLib.gameScreen);
graphLib.updateScreen();
tiles_showed++;
}
}
} else {
graphLib.placeTile(st_position(map_tiles.tiles[i][j].tile3.x, map_tiles.tiles[i][j].tile3.y), st_position((i*TILESIZE)+scroll.x, (j*TILESIZE)-scroll.y), &graphLib.gameScreen);
}
}
}
}
_player_list.at(0)->show();
graphLib.draw_hp_bar(_player_list.at(0)->get_current_hp(), player_number, WEAPON_DEFAULT);
//show_sprite(p1Obj->sprite, game_screen);
//draw_hp_bar(p1Obj);
graphLib.updateScreen();
input.waitTime(100);
}
input.waitTime(100);
}
示例5: main
int main(int argc, char *argv[])
{
quick_load = false;
UNUSED(argc);
gameControl.currentStage = TECHNOBOT;
game_config.selected_player = 1;
//strncpy (FILEPATH, argv[0], strlen(argv[0])-11);
string argvString = string(argv[0]);
FILEPATH = argvString.substr(0, argvString.size()-EXEC_NAME.size());
//std::cout << "main - FILEPATH: " << FILEPATH << std::endl;
format_v_2_0_1::file_io fio;
fio.read_game(game_data);
// INIT GRAPHICS
if (graphLib.initGraphics() != true) {
exit(-1);
}
// INIT GAME
if (quick_load == false) {
if (gameControl.showIntro() == false) {
return 0;
}
} else {
gameControl.quick_load_game();
//ending game_ending;
//game_ending.start();
}
input.clean();
input.p1_input[BTN_START] = 0;
input.waitTime(200);
input.clean();
while (true) {
input.readInput();
if (input.p1_input[BTN_QUIT] == 1) {
exit(-1);
}
gameControl.showGame();
graphLib.updateScreen();
}
/// @TODO: sdl quit sub-systems
SDL_Quit();
return 1;
}
示例6: run_viewpoint_scene
void sceneShow::run_viewpoint_scene(CURRENT_FILE_FORMAT::file_scene_show_viewpoint viewpoint)
{
std::cout << "** sceneShow::run_image_scene::START" << std::endl;
float x = viewpoint.ini_x;
float y = viewpoint.ini_y;
graphicsLib_gSurface image;
graphLib.surfaceFromFile(FILEPATH + "images/scenes/" + viewpoint.filename, &image);
//std::cout << "** sceneShow::run_image_scene::total_dist: " << total_dist << std::endl;
while (total_dist > 0) {
input.read_input();
//std::cout << "total_dist: " << total_dist << std::endl;
timer.delay(viewpoint.move_delay);
std::cout << "rect - x[" << x << "], .y[" << y << "], w[" << viewpoint.w << "], h[" << viewpoint.h << "]" << std::endl;
//void graphicsLib::showSurfacePortion(graphicsLib_gSurface *surfaceOrigin, const st_rectangle origin_rect, st_rectangle destiny_rect)
graphLib.showSurfacePortion(&image, st_rectangle(x, y, viewpoint.w, viewpoint.h), st_rectangle(viewpoint.pos_x, viewpoint.pos_y, viewpoint.w, viewpoint.h));
graphLib.updateScreen();
x += speed_x;
y += speed_y;
total_dist--;
}
graphLib.showSurfacePortion(&image, st_rectangle(x, y, viewpoint.w, viewpoint.h), st_rectangle(viewpoint.pos_x, viewpoint.pos_y, viewpoint.w, image.height));
timer.delay(viewpoint.move_delay);
graphLib.updateScreen();
}
示例7: run_image_scene
// @TODO - this should only set some variables in a global and the drawinbg should be handled my show_scene()
// That way we can move the run_XXX methods into threads to run in paralel
void sceneShow::run_image_scene(CURRENT_FILE_FORMAT::file_scene_show_image scene_image)
{
std::cout << "** sceneShow::run_image_scene::START" << std::endl;
float x = scene_image.ini_x;
float y = scene_image.ini_y;
graphicsLib_gSurface image;
graphicsLib_gSurface bg_image;
graphLib.initSurface(st_size(RES_W, RES_H), &bg_image);
graphLib.copy_gamescreen_area(st_rectangle(0, 0, RES_W, RES_H), st_position(0, 0), &bg_image);
graphLib.surfaceFromFile(FILEPATH + "images/scenes/" + scene_image.filename, &image);
std::cout << "** sceneShow::run_image_scene::total_dist: " << total_dist << std::endl;
while (total_dist > 0) {
input.read_input();
//std::cout << "total_dist: " << total_dist << std::endl;
timer.delay(scene_image.move_delay);
// @TODO - copy background, but should be done in a smarter way as there can be several moving elements
graphLib.showSurfaceAt(&bg_image, st_position(0, 0), false);
graphLib.showSurfaceAt(&image, st_position(x, y), false);
graphLib.updateScreen();
x += speed_x;
y += speed_y;
total_dist--;
}
graphLib.showSurfaceAt(&image, st_position(x, y), false);
graphLib.updateScreen();
}
示例8: 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;
}
示例9: execute
void classPlayer::execute()
{
if (freeze_weapon_effect != FREEZE_EFFECT_PLAYER) {
move();
} else {
clear_move_commands();
input.clean();
}
charMove();
}
示例10: draw_config_keys
int key_map::draw_config_keys() const
{
st_position config_text_pos;
config_text_pos.x = graphLib.get_config_menu_pos().x + 74;
config_text_pos.y = graphLib.get_config_menu_pos().y + 40;
input.clean();
input.waitTime(100);
input.clean();
input.waitTime(100);
graphLib.clear_area(config_text_pos.x, config_text_pos.y, 180, 180, 0, 0, 0);
std::vector<std::string> options;
options.push_back("RESET TO DEFAULT");
options.push_back("SET JUMP");
options.push_back("SET ATTACK");
options.push_back("SET SHIELD");
options.push_back("SET DASH");
options.push_back("SET L");
options.push_back("SET R");
options.push_back("SET START");
// -- NEW -- //
if (game_config.input_mode == INPUT_MODE_DIGITAL) {
options.push_back("DIRECTIONAL: DIGITAL");
} else {
options.push_back("DIRECTIONAL: ANALOG");
}
// -- NEW --//
if (game_config.input_mode == INPUT_MODE_DIGITAL) {
options.push_back("SET UP");
options.push_back("SET DOWN");
options.push_back("SET LEFT");
options.push_back("SET RIGHT");
}
short selected_option = 0;
option_picker main_config_picker(false, config_text_pos, options, true);
selected_option = main_config_picker.pick();
std::cout << "key_map::draw_config_keys - selected_option: " << selected_option << std::endl;
return selected_option;
}
示例11: main
int main(int argc, char *argv[])
{
get_filepath();
fio.read_game(game_data);
soundManager.init_audio_system();
if (graphLib.initGraphics() != true) {
printf("ERROR intializing graphic\n");
return -1;
}
sceneShow show;
show.show_scene(0);
input.wait_keypress();
return 1;
}
示例12: teleport_stand
void classPlayer::teleport_stand()
{
unsigned int waitTimer = timer.getTimer()+500;
state.animation_state = ANIM_TYPE_TELEPORT;
/*
if (p2Obj) {
p2Obj->sprite->anim_type = ANIM_TELEPORT;
}
*/
soundManager.play_sfx(SFX_TELEPORT);
while (waitTimer > timer.getTimer()) {
draw_lib.update_screen();
show();
/*
if (p2Obj) {
show_sprite(p2Obj->sprite, game_screen);
}
*/
//drawMap3rdLevel(game_screen);
//updateScreen(game_screen);
input.waitTime(20);
}
}
示例13: death
void classPlayer::death()
{
std::cout << "PLAYER::death" << std::endl;
map->print_objects_number();
reset_charging_shot();
map->clear_animations();
map->print_objects_number();
map->reset_objects();
map->print_objects_number();
dead = true;
state.jump_state = NO_JUMP;
freeze_weapon_effect = FREEZE_EFFECT_NONE;
clear_move_commands();
input.clean();
state.direction = ANIM_DIRECTION_RIGHT;
gameControl.draw_explosion(realPosition.x, realPosition.y, false);
if (game_save.items.lifes == 0) {
game_save.items.lifes = 3;
std::cout << "GAME OVER" << std::endl;
gameControl.game_over();
return;
}
game_save.items.lifes--;
}
示例14: draw_screen
void key_map::draw_screen()
{
bool finished = false;
st_position config_text_pos;
st_position cursor_pos;
short _pick_pos = 0;
config_text_pos.x = graphLib.get_config_menu_pos().x + 74;
config_text_pos.y = graphLib.get_config_menu_pos().y + 40;
cursor_pos = config_text_pos;
graphLib.clear_area(config_text_pos.x-1, config_text_pos.y-1, 180, 180, 0, 0, 0);
input.clean();
input.waitTime(300);
for (unsigned int i=0; i<_keys_list.size(); i++) {
graphLib.draw_text(config_text_pos.x, config_text_pos.y + i*CURSOR_SPACING, _keys_list[i].c_str());
redraw_line(i);
}
graphLib.draw_text(config_text_pos.x, config_text_pos.y + _keys_list.size()*CURSOR_SPACING, "RETURN");
draw_lib.update_screen();
//cout << "scenesLib::option_picker::START\n";
graphLib.drawCursor(st_position(cursor_pos.x-CURSOR_SPACING, cursor_pos.y+(_pick_pos*CURSOR_SPACING)));
while (finished == false) {
input.readInput();
if (input.p1_input[BTN_START]) {
if (_pick_pos == (short)_keys_list.size()) {
std::cout << "key_map::draw_screen - FINISHED #1" << std::endl;
finished = true;
} else {
graphLib.draw_text(config_text_pos.x, config_text_pos.y + _keys_list.size()*CURSOR_SPACING+CURSOR_SPACING*2, "PRESS NEW KEY/BUTTON"); //input code (number)
draw_lib.update_screen();
//format_v_2_1_1::st_key_config new_key = input.get_pressed_key();
graphLib.clear_area(config_text_pos.x, config_text_pos.y + _keys_list.size()*CURSOR_SPACING+CURSOR_SPACING*2-1, 180, CURSOR_SPACING+1, 0, 0, 0);
///@TODO - key_config[_pick_pos].key_type = new_key.key_type;
///@TODO - key_config[_pick_pos].key_number = new_key.key_number;
redraw_line(_pick_pos);
draw_lib.update_screen();
}
}
if (input.p1_input[BTN_DOWN]) {
soundManager.play_sfx(SFX_CURSOR);
graphLib.eraseCursor(st_position(cursor_pos.x-CURSOR_SPACING, cursor_pos.y+(_pick_pos*CURSOR_SPACING)));
_pick_pos++;
if (_pick_pos >= (short)_keys_list.size()+1) {
_pick_pos = 0;
}
graphLib.drawCursor(st_position(cursor_pos.x-CURSOR_SPACING, cursor_pos.y+(_pick_pos*CURSOR_SPACING)));
}
if (input.p1_input[BTN_UP]) {
soundManager.play_sfx(SFX_CURSOR);
graphLib.eraseCursor(st_position(cursor_pos.x-CURSOR_SPACING, cursor_pos.y+(_pick_pos*CURSOR_SPACING)));
_pick_pos--;
if (_pick_pos < 0) {
_pick_pos = _keys_list.size();
}
graphLib.drawCursor(st_position(cursor_pos.x-CURSOR_SPACING, cursor_pos.y+(_pick_pos*CURSOR_SPACING)));
}
if (input.p1_input[BTN_QUIT]) {
std::cout << "key_map::draw_screen - FINISHED #2" << std::endl;
finished = true;
}
input.clean();
input.waitTime(10);
draw_lib.update_screen();
}
}
示例15: config_input
void key_map::config_input()
{
CURRENT_FILE_FORMAT::st_game_config game_config_copy = game_config;
int selected_option = 0;
while (selected_option != -1) {
selected_option = draw_config_keys();
std::cout << "key_map::config_input - selected_option: " << selected_option << std::endl;
if (selected_option == 0) {
game_config.set_default_keys();
std::cout << "key_map::config_input - LEAVE #1" << std::endl;
} else if (selected_option == -1) {
std::cout << "key_map::config_input - LEAVE #2" << std::endl;
// apply changes to game-config
apply_key_codes_changes(game_config_copy);
return;
// -- NEW -- //
} else if (selected_option == 8) {
if (game_config.input_mode == INPUT_MODE_DIGITAL) {
game_config.input_mode = INPUT_MODE_ANALOG;
} else {
game_config.input_mode = INPUT_MODE_DIGITAL;
}
// -- NEW -- //
} else {
std::cout << "key_map::config_input - PICK KEY #1" << std::endl;
INPUT_COMMANDS selected_key = BTN_JUMP;
if (selected_option == 1) {
selected_key = BTN_JUMP;
} else if (selected_option == 2) {
selected_key = BTN_ATTACK;
} else if (selected_option == 3) {
selected_key = BTN_SHIELD;
} else if (selected_option == 4) {
selected_key = BTN_DASH;
} else if (selected_option == 5) {
selected_key = BTN_L;
} else if (selected_option == 6) {
selected_key = BTN_R;
} else if (selected_option == 7) {
selected_key = BTN_START;
} else if (selected_option == 9) {
selected_key = BTN_UP;
} else if (selected_option == 10) {
selected_key = BTN_DOWN;
} else if (selected_option == 11) {
selected_key = BTN_LEFT;
} else if (selected_option == 12) {
selected_key = BTN_RIGHT;
}
st_position menu_pos(graphLib.get_config_menu_pos().x + 74, graphLib.get_config_menu_pos().y + 40);
graphLib.clear_area(menu_pos.x, menu_pos.y, 180, 180, 0, 0, 0);
graphLib.draw_text(menu_pos.x, menu_pos.y, "PRESS A KEY OR BUTTON");
input.clean();
input.waitTime(20);
bool is_joystick = input.pick_key_or_button(game_config_copy, selected_key);
check_key_duplicates(game_config_copy, selected_key, is_joystick);
}
}
// apply changes to game-config
apply_key_codes_changes(game_config_copy);
}