• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ timerLib类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中timerLib的典型用法代码示例。如果您正苦于以下问题:C++ timerLib类的具体用法?C++ timerLib怎么用?C++ timerLib使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了timerLib类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:DavidKnight247,项目名称:Rockbot-GCW0-port,代码行数:30,代码来源:dialogs.cpp


示例2: waitScapeTime

// ********************************************************************************************** //
//                                                                                                //
// ********************************************************************************************** //
int inputLib::waitScapeTime(int wait_period) {
	int now_time = 0;

	waitTime(50);
	now_time = timer.getTimer();
	wait_period = now_time + wait_period;

	while (now_time < wait_period) {
		readInput();
		if (p1_input[BTN_START] == 1 || p2_input[BTN_START] == 1) {
			return 1;
        } else if (p1_input[BTN_QUIT] == 1 || p2_input[BTN_QUIT] == 1) {
#if !defined(PLAYSTATION2) && !defined(PSP) && !defined(WII) && !defined(DREAMCAST)
            std::cout << "LEAVE #2" << std::endl;
            std::fflush(stdout);
            gameControl.leave_game();
#endif
		}
		now_time = timer.getTimer();
		#ifdef PLAYSTATION
			RotateThreadReadyQueue(_MIXER_THREAD_PRIORITY);
		#endif
        SDL_Delay(5);
	}
	return 0;
}
开发者ID:DavidKnight247,项目名称:Rockbot-GCW0-port,代码行数:29,代码来源:inputlib.cpp


示例3: 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();
}
开发者ID:protoman,项目名称:rockbot,代码行数:31,代码来源:sceneshow.cpp


示例4: 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();
}
开发者ID:protoman,项目名称:rockbot,代码行数:30,代码来源:sceneshow.cpp


示例5: boss_move

void classboss::boss_move() {
	if (state.move_timer > timer.getTimer()) {
		return;
	}

	if (_initialized == 0) { /// @TODO: move this logic to map (player should not move while boss is presenting)
		_initialized++;
		gameControl.boss_intro();
		return;
	} else if (_initialized == 1) {
		if (position.x > RES_H/2 && gravity(true) == false) {
			_initialized++;
		}
		state.move_timer = timer.getTimer()+100;
		return;
	}


	//std::cout << "classboss::move [" << name << "]" << std::endl;
	/*
	int mapScrollX = map->getMapScrolling().x;
	int lock_point = map->getMapPointLock(st_position(position.x/16, position.y/16));
	struct struct_player_dist dist_players = dist_npc_players();
	*/

	if (first_run == 0) {
		// show boss dialogs here
		first_run = 1;
		//boss_energy = temp_npc;
		//play_boss_music();
		//show_dialog(STAGE_N, 1);
	}
	if (name == "Daisie Bot") {
		exec_daisiebot();
		//npc_gravity(temp_npc);
		return;
	} else if (name == "Ape Bot") {
		//exec_IA_Apebot(temp_npc);
        //exec_daisiebot();
		return;
	} else {
		gravity(false);
		return;
	}
}
开发者ID:DavidKnight247,项目名称:Rockbot-GCW0-port,代码行数:45,代码来源:classboss.cpp


示例6: 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;
}
开发者ID:farleyknight,项目名称:rockbot,代码行数:45,代码来源:dialogs.cpp


示例7: waitTime

// ********************************************************************************************** //
//                                                                                                //
// ********************************************************************************************** //
void inputLib::waitTime(int wait_period) const {
    /*
#ifdef PLAYSTATION2
    if (wait_period < 20) {
        return;
    }
#endif
    */
	int now_time=0;
	now_time = timer.getTimer();
	wait_period = now_time + wait_period;
	while (now_time < wait_period) {
		now_time = timer.getTimer();
		SDL_Delay(1);
		#ifdef PLAYSTATION
			RotateThreadReadyQueue(_MIXER_THREAD_PRIORITY);
		#endif
        graphLib.updateScreen();
	}
}
开发者ID:DavidKnight247,项目名称:Rockbot-GCW0-port,代码行数:23,代码来源:inputlib.cpp


示例8: show_rain

void draw::show_rain()
{
    if (rain_obj.gSurface == NULL) {
        // load rain
        std::string filename = FILEPATH + "/data/images/tilesets/rain.png";
        graphLib.surfaceFromFile(filename, &rain_obj);
    }
    for (int i=0; i<MAP_W; i++) {
        for (int j=0; j<MAP_H; j++) {
            graphLib.showSurfaceRegionAt(&rain_obj, st_rectangle(_rain_pos*TILESIZE, 0, TILESIZE, TILESIZE), st_position(i*TILESIZE, j*TILESIZE));
        }
    }
    if (timer.getTimer() > _rain_timer) {
        _rain_pos++;
        if (_rain_pos > 2) {
            _rain_pos = 0;
        }
        _rain_timer = timer.getTimer() + RAIN_DELAY;
    }
}
开发者ID:DavidKnight247,项目名称:Rockbot-GCW0-port,代码行数:20,代码来源:draw.cpp


示例9: show_animation

void sceneShow::show_animation(int n, int repeat_n, int repeat_mode)
{
    int frame_n = 0;
    CURRENT_FILE_FORMAT::file_scene_show_animation scene = animation_list.at(n);
    long frame_timer = timer.getTimer() + scene.frame_delay;
    long started_timer = timer.getTimer();
    int repeat_times = 0;

    graphicsLib_gSurface image;
    graphLib.surfaceFromFile(FILEPATH + "images/scenes/animations/" + scene.filename, &image);
    int max_frames = image.width / scene.frame_w;

    graphicsLib_gSurface bg_image;
    graphLib.initSurface(st_size(scene.frame_w, scene.frame_h), &bg_image);
    graphLib.copy_gamescreen_area(st_rectangle(scene.x, scene.y, scene.frame_w, scene.frame_h), st_position(0, 0), &bg_image);

    while (true) {

        std::cout << "sceneShow::show_animation::LOOP" << std::endl;

        //graphLib.showSurfaceAt(&bg_image, st_position(scene.x, scene.y), false);

        int x = frame_n*scene.frame_w;
        std::cout << "origin.x: " << x << ", dest.x: " << scene.x << ", frame.w: " << scene.frame_w << ", frame.h: " << scene.frame_h << std::endl;

        graphLib.showSurfaceRegionAt(&image, st_rectangle(x, 0, scene.frame_w, scene.frame_h), st_position(scene.x, scene.y));


        graphLib.updateScreen();

        if (frame_timer < timer.getTimer()) {
            frame_n++;
            if (frame_n > max_frames) {
                frame_n = 0;
                repeat_times++;
            }
            frame_timer = timer.getTimer() + scene.frame_delay;
        }

        // stop condition
        if (repeat_times > 0 && repeat_n <= 1) {
            std::cout << "sceneShow::show_animation::LEAVE#1" << std::endl;
            return;
        } else {
            if (repeat_mode == 0) { // time-mode
                if ((timer.getTimer() - started_timer) > repeat_n) {
                    std::cout << "sceneShow::show_animation::LEAVE#2" << std::endl;
                    return;
                }
            } else { // repeat number mode
                if (repeat_times > repeat_n) {
                    std::cout << "sceneShow::show_animation::LEAVE#3" << std::endl;
                    return;
                }
            }
        }
        timer.delay(10);
    }
}
开发者ID:eduardok,项目名称:rockbot,代码行数:59,代码来源:sceneshow.cpp


示例10: show

void gfx_sin_wave::show(int x, int y)
{
    float angle_max = 3.14 * SIN_STEPS;
    float angle_step = angle_max / surface->width;
    float angle = 0;
    for (int j=0; j<max_amplitude; j++) {
        graphLib.clear_area(x, y, surface->width, surface->height, 0, 0, 0);
        for (int i=0; i<surface->height; i++) {
            float pos_x = (sin(angle) + x)*amplitude;
            int pos_y = i + y;
            angle += angle_step;
            //std::cout << "i[" << i << "], pos_x[" << pos_x << "], pos_y[" << pos_y << "]" << std::endl;
            graphLib.showSurfacePortion(surface, st_rectangle(0, i, surface->width, 1), st_rectangle(pos_x, pos_y, surface->width, 1));
        }
        amplitude--;
        graphLib.updateScreen();
        timer.delay(40);
    }
}
开发者ID:protoman,项目名称:rockbot,代码行数:19,代码来源:gfx_sin_wave.cpp


示例11: 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();
}
开发者ID:DavidKnight247,项目名称:Rockbot-GCW0-port,代码行数:40,代码来源:draw.cpp


示例12: show_scene

void sceneShow::show_scene(int n)
{
    if (scene_list.size() <= n) {
        std::cout << "ERROR: Scene List[" << n << "] invalid. List size is " << image_scenes.size() << "." << std::endl;
        exit(-1);
    }
    CURRENT_FILE_FORMAT::file_scene_list scene = scene_list.at(0);
    for (int i=0; i<SCENE_OBJECTS_N; i++) {
        int scene_seek_n = scene.objects[i].seek_n;
        if (scene_seek_n != -1) {
            int scene_type = scene.objects[i].type;
            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) {
                /// @TODO
            } 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);
            }
            timer.delay(scene.objects[i].delay_after);
        }
    }
}
开发者ID:eduardok,项目名称:rockbot,代码行数:36,代码来源:sceneshow.cpp


示例13: readInput

void inputLib::readInput()
{
    _used_keyboard = false;
    while (SDL_PollEvent(&event)) {

        if (_show_btn_debug == false) {
            _show_btn_debug = true;
        }

        if (game_config.input_type == INPUT_TYPE_DOUBLE || game_config.input_type == INPUT_TYPE_KEYBOARD) {
            if (event.type == SDL_KEYDOWN) {
                for (int i=0; i<BTN_COUNT; i++) {
                    if (game_config.keys_codes[i] != -1 && game_config.keys_codes[i] == event.key.keysym.sym) {
                        p1_input[i] = 1;
                        _used_keyboard = true;
                        if (i == BTN_JUMP) {
                            p1_input[BTN_JUMP_TIMER] = timer.getTimer();
                        }
                    }
                }
            } else if (event.type == SDL_KEYUP) {
                for (int i=0; i<BTN_COUNT; i++) {
                    if (game_config.keys_codes[i] != -1 && game_config.keys_codes[i] == event.key.keysym.sym) {
                        p1_input[i] = 0;
                        _used_keyboard = true;
                        if (i == BTN_JUMP) {
                            p1_input[BTN_JUMP_TIMER] = 0;
                        }
                    }
                }
            }
            SDL_PumpEvents(); // check keyboard events
#if !defined(PLAYSTATION2) && !defined(PSP) && !defined(WII) && !defined(DREAMCAST)
            if (event.type == SDL_QUIT) {
                std::cout << "LEAVE #1" << std::endl;
                std::fflush(stdout);
                gameControl.leave_game();
            }
#endif
        }
        if (_used_keyboard == true) { // next commands are all joystick only
            return;
        }
        if (game_config.input_type == INPUT_TYPE_DOUBLE || game_config.input_type == INPUT_TYPE_JOYSTICK) {
            if (event.type == SDL_JOYBUTTONDOWN) {
                //std::cout << "#1 INPUT::readInput - joystick button[" << (int)event.jbutton.button << "] pressed." << std::endl;
                for (int i=0; i<BTN_COUNT; i++) {
                    //std::cout << "#1 INPUT::readInput - button_codes[" << i << "]: " << game_config.button_codes[i] << std::endl;
                    if (game_config.button_codes[i] != -1 && game_config.button_codes[i] == event.jbutton.button) {
                        //std::cout << "#1 INPUT::readInput - FOUND ACTION for i: " << i << std::endl;
                        p1_input[i] = 1;
                        if (i == BTN_JUMP) {
                            p1_input[BTN_JUMP_TIMER] = timer.getTimer();
                        }
                        //break;
                    }
                }
            } else if (event.type == SDL_JOYBUTTONUP) {
                //std::cout << "#2 INPUT::readInput - joystick button[" << event.jbutton.button << "] released" << std::endl;
                for (int i=0; i<BTN_COUNT; i++) {
                    if (game_config.button_codes[i] != -1 && game_config.button_codes[i] == event.jbutton.button) {
                        p1_input[i] = 0;
                        if (i == BTN_JUMP) {
                            p1_input[BTN_JUMP_TIMER] = 0;
                        }
                        break;
                    }
                }
            }
        }
        if ((game_config.input_mode == INPUT_MODE_ANALOG || game_config.input_mode == INPUT_MODE_DOUBLE) && event.type == SDL_JOYAXISMOTION) {
            if (event.jaxis.axis == 0) {
                if (event.jaxis.value < -JOYVAL) {
                    p1_input[BTN_RIGHT] = 0;
                    p1_input[BTN_LEFT] = 1;
                    _used_keyboard = false;
                } else if (event.jaxis.value > JOYVAL) {
                    p1_input[BTN_RIGHT] = 1;
                    p1_input[BTN_LEFT] = 0;
                    _used_keyboard = false;
                } else if ((event.jaxis.value < JOYVAL || event.jaxis.value > -JOYVAL) && _used_keyboard == false) {
                    p1_input[BTN_RIGHT] = 0;
                    p1_input[BTN_LEFT] = 0;
                }
            }
            if (event.jaxis.axis == 1) {
                if (event.jaxis.value < -JOYVAL) {
                    p1_input[BTN_DOWN] = 0;
                    p1_input[BTN_UP] = 1;
                    _used_keyboard = false;
                } else if (event.jaxis.value > JOYVAL) {
                    p1_input[BTN_DOWN] = 1;
                    p1_input[BTN_UP] = 0;
                    _used_keyboard = false;
                } else if ((event.jaxis.value < JOYVAL || event.jaxis.value > -JOYVAL) && _used_keyboard == false) {
                    p1_input[BTN_DOWN] = 0;
                    p1_input[BTN_UP] = 0;
                }
            }
        }
//.........这里部分代码省略.........
开发者ID:DavidKnight247,项目名称:Rockbot-GCW0-port,代码行数:101,代码来源:inputlib.cpp


示例14: exec_daisiebot

void classboss::exec_daisiebot()
{
	unsigned short int shot_type = IA_STATE_SHOT_RAINBOW;

	std::cout << "classboss::exec_daisiebot" << std::endl;

	if (IA_state == IA_STATE_WAIT_TIME) {
		IA_state = IA_STAND;
	}

	// stand -> shot rainbow -> cross screen -> use flowers
	if (IA_state == IA_STAND) {
		IA_state = IA_STATE_CROSS_SCREEN;
		state.animation_type = ANIM_TYPE_WALK;
		return;
	}

	if (IA_state == IA_STATE_SHOT_RAINBOW) {
		state.animation_type = ANIM_TYPE_STAND;
		/// @TODO (use attacks/weapons system) shot_rainbow();
		IA_state = IA_STATE_CROSS_SCREEN;

		initial_position.x = position.x;
		initial_position.y = position.y;
		IA_state = IA_STATE_WAIT_TIME;
		state.move_timer = timer.getTimer()+300;
	}

	if (IA_state == IA_STATE_SHOT_FLOWER) {
		state.animation_type = ANIM_TYPE_STAND;
		/// @TODO (use attacks/weapons system) shot_flower(temp_npc);
		/// temp_npc->projectile.timer = getTimer()+60;
		initial_position.x = position.x;
		initial_position.y = position.y;
		IA_state = IA_STATE_WAIT_TIME;
		state.move_timer = timer.getTimer()+3000;
	}

	// TODO: move to generic npc, once more will use it
	if (IA_state == IA_STATE_CROSS_SCREEN) {
		// check if must stop/invert
		state.move_timer = timer.getTimer() + 10;
		if (state.direction == ANIM_DIRECTION_LEFT) {
			int map_tile_x = (position.x-move_speed)/16;
			int map_tile_y = position.y/16;
			if (distance.width < 18*TILESIZE && (position.x-move_speed > 0 && (map->getMapPointLock(st_position(map_tile_x, map_tile_y)) == 0 || map->getMapPointLock(st_position(map_tile_x, map_tile_y)) == TERRAIN_WATER))) {
				position.x-= move_speed;
				distance.width += move_speed;
			} else {
				distance.width = 0;
				invert_direction();
				if (shot_type == IA_STATE_SHOT_RAINBOW) {
					shot_type = IA_STATE_SHOT_FLOWER;
				} else {
					shot_type = IA_STATE_SHOT_RAINBOW;
				}
				IA_state = shot_type;
			}
		} else { // ANIM_RIGHT
			int map_tile_x = (position.x+frameSize.width+move_speed)/16;
			int map_tile_y = position.y/16;
			//map->getMapPointLock(st_position(map_tile_x, map_tile_y))
			if (distance.width < 18*TILESIZE && (map->getMapPointLock(st_position(map_tile_x, map_tile_y)) == 0 || map->getMapPointLock(st_position(map_tile_x, map_tile_y)) == TERRAIN_WATER)) {
				position.x+= move_speed;
				distance.width += move_speed;
			} else {
				distance.width = 0;
				invert_direction();
				IA_state = shot_type;
			}
		}
	}

}
开发者ID:DavidKnight247,项目名称:Rockbot-GCW0-port,代码行数:74,代码来源:classboss.cpp


示例15: main

int main(int argc, char *argv[])
#endif
{


#ifdef PSP
    SetupCallbacks();
    scePowerSetClockFrequency(333, 333, 166);
#endif

    for (int i=0; i<FLAG_COUNT; i++) {
		GAME_FLAGS[i] = false;
	}
	UNUSED(argc);

    string argvString = "";
#ifndef WII
    argvString = string(argv[0]);
#else
    if (!fatInitDefault()) {
        printf("fatInitDefault ERROR #1");
        std::fflush(stdout);
        timer.delay(500);
        exit(-1);
    }
#endif


    get_filepath();
    // fallback in case getcwd returns null
    if (FILEPATH.size() == 0) {
        std::cout << "Could not read path, fallback to using argv" << std::endl;
        FILEPATH = argvString.substr(0, argvString.size()-EXEC_NAME.size());
    }
    std::cout << "main - argvString: '" << argvString << "', FILEPATH: '" << FILEPATH << "'" << std::endl; std::fflush(stdout);



#ifdef PLAYSTATION2
    std::cout << "PS2.DEBUG #1" << std::endl; std::fflush(stdout);

    #ifndef PS2LINK
    SifIopReset(NULL, 0); // clean previous loading of irx by apps like ulaunchElf. Comment this line to get cout on ps2link
    #endif

    printf("DEBUG.PS2 #1.1\n");

	/* SP193: Being creative (Do something while waiting for the slow IOP to be reset). =D */
	int main_id = GetThreadId();
    ChangeThreadPriority(main_id, 72);
    std::cout << "PS2.DEBUG #1.1" << std::endl; std::fflush(stdout);
    printf("DEBUG.PS2 #1.2\n");

    #ifndef PS2LINK
    while(SifIopSync()) {
        std::cout << "PS2.SifIopSync()" << std::endl;
    }
    #endif
	/* Initialize and connect to all SIF services on the IOP. */
	SifInitRpc(0);
	SifInitIopHeap();
	SifLoadFileInit();
	fioInit();
    printf("DEBUG.PS2 #1.3\n");

	/* Apply the SBV LMB patch to allow modules to be loaded from a buffer in EE RAM. */
	sbv_patch_enable_lmb();

    // --- DEBUG --- //
    //FILEPATH = "cdfs:/";
    // --- DEBUG --- //

    std::cout << "PS2.DEBUG #2" << std::endl; std::fflush(stdout);

    if (FILEPATH.find("mass:") != std::string::npos) {
        printf("DEBUG.PS2 #1.4\n");
        std::cout << "PS2.DEBUG Load USB" << std::endl; std::fflush(stdout);
        PS2_load_USB();
    }

    if (FILEPATH.find("cdfs") != std::string::npos || FILEPATH.find("cdrom") != std::string::npos) {
        printf("DEBUG.PS2 #1.5\n");
        std::cout << "PS2.DEBUG Load CDROM" << std::endl; std::fflush(stdout);
        FILEPATH = "cdfs:";
        PS2_load_CDROM();
    }
    printf("DEBUG.PS2 #2\n");




    std::cout << "PS2.DEBUG #3" << std::endl; std::fflush(stdout);
#endif




	// check command-line paramethers
	if (argc > 1) {
		for (int i=1; i<argc; i++) {
//.........这里部分代码省略.........
开发者ID:DavidKnight247,项目名称:Rockbot-GCW0-port,代码行数:101,代码来源:main.cpp


示例16: show_animation

void sceneShow::show_animation(int n, int repeat_n, int repeat_mode)
{
    int frame_n = 0;
    CURRENT_FILE_FORMAT::file_scene_show_animation scene = animation_list.at(n);
    long frame_timer = timer.getTimer() + scene.frame_delay;
    long started_timer = timer.getTimer();
    int repeat_times = 0;

    graphicsLib_gSurface image;
    graphLib.surfaceFromFile(FILEPATH + "images/scenes/animations/" + scene.filename, &image);
    int max_frames = image.width / scene.frame_w;

    graphicsLib_gSurface bg_image;
    graphLib.initSurface(st_size(scene.frame_w, scene.frame_h), &bg_image);
    graphLib.copy_gamescreen_area(st_rectangle(scene.x, scene.y, scene.frame_w, scene.frame_h), st_position(0, 0), &bg_image);


    std::cout << "max_frames[" << max_frames << "], image.w[" << image.width << "], scene.frame_w[" << scene.frame_w << "]" << std::endl;

    while (true) {
        input.read_input();
        int x = frame_n*scene.frame_w;


        // stop condition
        if (repeat_times > 0 && repeat_n <= 1) {
            std::cout << "sceneShow::show_animation::LEAVE#1" << std::endl;
            break;
        } else {
            if (repeat_mode == 0) { // time-mode
                if ((timer.getTimer() - started_timer) > repeat_n) {
                    std::cout << "sceneShow::show_animation::LEAVE#2" << std::endl;
                    break;
                }
            } else { // repeat number mode
                if (repeat_times > repeat_n) {
                    std::cout << "sceneShow::show_animation::LEAVE#3" << std::endl;
                    break;
                }
            }
        }
        graphLib.showSurfaceAt(&bg_image, st_position(scene.x, scene.y), false);
        std::cout << "x[" << x << "], img.w[" << image.width << "], frame.w[" << scene.frame_w << "]" << std::endl;
        graphLib.showSurfaceRegionAt(&image, st_rectangle(x, 0, scene.frame_w, scene.frame_h), st_position(scene.x, scene.y));
        graphLib.updateScreen();
        timer.delay(scene.frame_delay);


        if (frame_timer < timer.getTimer()) {
            frame_n++;
            if (frame_n >= max_frames) {
                frame_n = 0;
                repeat_times++;
            }
            frame_timer = timer.getTimer() + scene.frame_delay;
        }

    }
    // avoid leaving animation image trail if it is a repeating one
    if (repeat_n > 1) {
        graphLib.showSurfaceAt(&bg_image, st_position(scene.x, scene.y), false);
        graphLib.updateScreen();
        timer.delay(scene.frame_delay);
    }
}
开发者ID:protoman,项目名称:rockbot,代码行数:65,代码来源:sceneshow.cpp



注:本文中的timerLib类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ timer_queue类代码示例发布时间:2022-05-31
下一篇:
C++ timer类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap