Skip to content

Commit

Permalink
- adicionar opção performance mode
Browse files Browse the repository at this point in the history
    OK # HIGH: habilita background2 (que vira foreground)
    OK # HIGH: tiles de água ganham uma transparência azul por cima
    OK # LOW: desabilita background com autoscroll
    OK # LOW: target FPS setado para 30, velocidade de movimento x2 (criar global)
- fazer valkyrie ir no chão para soltar raio
  • Loading branch information
protoman@upperland.net authored and protoman@upperland.net committed Jan 17, 2017
1 parent e13000c commit a860c4f
Show file tree
Hide file tree
Showing 33 changed files with 671 additions and 251 deletions.
10 changes: 5 additions & 5 deletions Rockbot.pro
Expand Up @@ -11,9 +11,9 @@ QT -= gui



#CONFIG += linux
CONFIG += linux
#CONFIG += win32
CONFIG += android
#CONFIG += android
#CONFIG += playstation2
#CONFIG += dingux
#CONFIG += open_pandora
Expand Down Expand Up @@ -291,7 +291,8 @@ TEMPLATE = app


SOURCES += main.cpp \
character/character.cpp \
aux_tools/fps_control.cpp \
character/character.cpp \
graphicslib.cpp \
inputlib.cpp \
game.cpp \
Expand Down Expand Up @@ -325,12 +326,12 @@ SOURCES += main.cpp \
aux_tools/stringutils.cpp \
file/fio_common.cpp \
game_mediator.cpp \
aux_tools/fps_control.cpp \
docs/game_manual.cpp \
collision_detection.cpp \
graphic/gfx_sin_wave.cpp

HEADERS += \
aux_tools/fps_control.h \
character/character.h \
graphicslib.h \
defines.h \
Expand Down Expand Up @@ -385,7 +386,6 @@ HEADERS += \
file/v4/file_map.h \
file/fio_common.h \
game_mediator.h \
aux_tools/fps_control.h \
file/v4/file_anim_block.h \
ports/android/rockbot_android.h \
docs/game_manual.h \
Expand Down
31 changes: 29 additions & 2 deletions aux_tools/fps_control.cpp
@@ -1,16 +1,20 @@
#include "fps_control.h"

#define FPS_MAX 60
#include <iostream>

#define DEFULT_PLAYER_SPEED 1.2
#define DEFAULT_FPS_MAX 60

fps_control::fps_control()
{
fps_max = DEFAULT_FPS_MAX;
fps_speed_multiplier = 1.0;
}


void fps_control::initialize()
{
max_frame_ticks = (1000.0/(float)FPS_MAX)+0.00001;
max_frame_ticks = (1000.0/(float)fps_max)+0.00001;
frame_count = 0;
last_second_ticks = SDL_GetTicks();
}
Expand Down Expand Up @@ -57,3 +61,26 @@ bool fps_control::limit()

return false;
}

void fps_control::set_max_fps(unsigned short max)
{
fps_max = max;
float percent = (100 * fps_max) / DEFAULT_FPS_MAX;

std::cout << "FPS_CONTROL.set_max_fps[" << max << "], percent[" << percent << "]" << std::endl;

if (fps_max < DEFAULT_FPS_MAX) {
fps_speed_multiplier = 1.0 + (percent / 100);
} else if (fps_max == DEFAULT_FPS_MAX) {
fps_speed_multiplier = 1.0;
} else {
fps_speed_multiplier = 1.0 - (percent / 100);
}
max_frame_ticks = (1000.0/(float)fps_max)+0.00001;
}

float fps_control::get_fps_speed_multiplier()
{
//std::cout << "FPS_CONTROL::get_fps_speed_multiplier[" << fps_speed_multiplier << "]" << std::endl;
return fps_speed_multiplier;
}
5 changes: 5 additions & 0 deletions aux_tools/fps_control.h
Expand Up @@ -20,6 +20,8 @@ class fps_control
fps_control();
void initialize();
bool limit();
void set_max_fps(unsigned short max);
float get_fps_speed_multiplier();


private:
Expand All @@ -35,6 +37,9 @@ class fps_control

unsigned int current_ticks;
unsigned int target_ticks;

unsigned short fps_max;
float fps_speed_multiplier;
};

#endif // FPS_CONTROL_H
1 change: 1 addition & 0 deletions build/shared/strings_ingame.dat
Expand Up @@ -99,3 +99,4 @@ CLASSIC
GAMECUBE
PLATFORM SPECIFIC
PLEASE SET
PERFORMANCE MODE
21 changes: 13 additions & 8 deletions character/character.cpp
Expand Up @@ -2,6 +2,7 @@
#include "game.h"
#include "timerlib.h"


extern game gameControl;
#include "timerlib.h"
extern timerLib timer;
Expand Down Expand Up @@ -33,6 +34,7 @@ extern int freeze_weapon_id;

extern CURRENT_FILE_FORMAT::st_game_config game_config;


// initialize static member
static std::map<std::string, graphicsLib_gSurface> _character_frames_surface;

Expand Down Expand Up @@ -115,7 +117,9 @@ void character::charMove() {

int mapLock = 0;
bool moved = false;
float temp_move_speed = move_speed;
float temp_move_speed = move_speed * gameControl.get_fps_speed_multiplier();

//std::cout << "move_speed[" << move_speed << "], multi[" << gameControl.get_fps_speed_multiplier() << "], temp_move_speed[" << temp_move_speed << "]" << std::endl;;

if (timer.is_paused() == true) {
std::cout << "# CHAR::MOVE::PAUSED" << std::endl;
Expand All @@ -127,7 +131,7 @@ void character::charMove() {

if (_dashed_jump == true) {
if (state.animation_type == ANIM_TYPE_JUMP || state.animation_type == ANIM_TYPE_JUMP_ATTACK) {
temp_move_speed = move_speed*2;
temp_move_speed = move_speed * 2 * gameControl.get_fps_speed_multiplier();
if (did_hit_ground == true) {
_dashed_jump = false;
}
Expand Down Expand Up @@ -1135,7 +1139,7 @@ bool character::gravity(bool boss_demo_mode=false)
}
if (can_fly == false || gameControl.is_showing_boss_intro == true) {
bool is_moved = false;
short int limit_speed = move_speed;
short int limit_speed = move_speed * gameControl.get_fps_speed_multiplier();
if (boss_demo_mode == true) {
limit_speed = gravity_max_speed;
}
Expand Down Expand Up @@ -1580,7 +1584,8 @@ bool character::slide(st_float_position mapScrolling)
_obj_jump.finish();

// reduce progressively the jump-move value in oder to deal with collision
for (float i=move_speed*2; i>0.0; i--) {
int max_speed = move_speed * 2 * gameControl.get_fps_speed_multiplier();
for (float i=max_speed; i>0.0; i--) {

int temp_i;
if (state.direction == ANIM_DIRECTION_LEFT) {
Expand Down Expand Up @@ -1823,7 +1828,7 @@ void character::check_platform_move(short map_lock)
if (_moving_platform_timer < timer.getTimer()) {
int pos_y = (position.y + frameSize.height/2) / TILESIZE;
if (map_lock == TERRAIN_MOVE_LEFT) {
move = (move_speed-0.5)*-1;
move = ((move_speed-0.5)*-1) * gameControl.get_fps_speed_multiplier();
int pos_x = (position.x + move) / TILESIZE;
if (is_player() && state.direction == ANIM_DIRECTION_RIGHT) { // add a few pixels because of graphic when turned right
pos_x = (position.x + 5 + move) / TILESIZE;
Expand All @@ -1833,7 +1838,7 @@ void character::check_platform_move(short map_lock)
can_move = false;
}
} else if (map_lock == TERRAIN_MOVE_RIGHT) {
move = move_speed-0.5;
move = (move_speed-0.5) * gameControl.get_fps_speed_multiplier();
int pos_x = (position.x + frameSize.width - 10 + move) / TILESIZE;
int point_terrain = gameControl.getMapPointLock(st_position(pos_x, pos_y));
if (point_terrain != TERRAIN_UNBLOCKED && point_terrain != TERRAIN_WATER) {
Expand Down Expand Up @@ -2525,9 +2530,9 @@ Uint8 character::get_projectile_max_shots()

void character::push_back(short direction)
{
int xinc = -(move_speed-0.2);
int xinc = -(move_speed-0.2) * gameControl.get_fps_speed_multiplier();
if (direction == ANIM_DIRECTION_LEFT) {
xinc = move_speed-0.2;
xinc = (move_speed-0.2) * gameControl.get_fps_speed_multiplier();
}

//std::cout << "CHAR::PUSH_BACK - xinc: " << xinc << std::endl;
Expand Down
1 change: 1 addition & 0 deletions character/character.h
Expand Up @@ -16,6 +16,7 @@
#include "character/movement/jump.h"
#include "character/movement/inertia.h"


extern graphicsLib graphLib;

class object; // forward declaration
Expand Down
3 changes: 1 addition & 2 deletions character/classplayer.cpp
Expand Up @@ -51,11 +51,11 @@ classPlayer::classPlayer(int playerNumber) : teleporter_n(-1), selected_weapon(W
hitPoints.current = hitPoints.total;
shield_type = SHIELD_FRONT; /// @TODO: from editor
// load items from save
move_speed = PLAYER_MOVE_SPEED;
selected_weapon = 0;
char temp_name[30];
sprintf(temp_name, "PLAYER_%d", _number);
name = std::string(temp_name);
move_speed = PLAYER_MOVE_SPEED;
reset_charging_shot();
}

Expand Down Expand Up @@ -232,7 +232,6 @@ bool classPlayer::shoryuken()
// is executing
} else if (state.animation_type == ANIM_TYPE_SPECIAL_ATTACK) {
std::cout << ">>>>>>>>>>>>>>>>>>>> SHORYUKEN::EXECUTE" << std::endl;
//position.y -= move_speed;
_obj_jump.execute(TERRAIN_UNBLOCKED);
int jump_speed = _obj_jump.get_speed();
bool jump_moved = false;
Expand Down
6 changes: 5 additions & 1 deletion character/movement/jump.cpp
Expand Up @@ -8,6 +8,9 @@

#define JUMP_INITIAL_SPEED 5.375

#include "game.h"
extern game gameControl;


classjump::classjump() : started(false)
{
Expand All @@ -34,6 +37,7 @@ void classjump::start(bool bigjump_mode, int terrain_type)
} else {
acceleration = JUMP_ACCELERATION;
}
acceleration = acceleration * gameControl.get_fps_speed_multiplier();
jumps_number++;
speed = -JUMP_INITIAL_SPEED;

Expand Down Expand Up @@ -116,7 +120,7 @@ void classjump::finish()

float classjump::get_speed()
{
return speed;
return speed * gameControl.get_fps_speed_multiplier();
}

short classjump::get_jumps_number()
Expand Down

0 comments on commit a860c4f

Please sign in to comment.