fixed game_speed, now using fixed point and keeping game_speed static
This commit is contained in:
+2
-3
@@ -98,8 +98,7 @@ int get_deck_top(void);
|
||||
int get_num_discards_remaining(void);
|
||||
int get_money(void);
|
||||
|
||||
extern int game_speed; // had to do this use this it the sprites animations
|
||||
// that were not affected by game_speed, like discard
|
||||
// and draw-to-deck animations.
|
||||
int get_game_speed(void);
|
||||
void set_game_speed(int game_speed_);
|
||||
|
||||
#endif // GAME_H
|
||||
|
||||
+12
-2
@@ -32,7 +32,7 @@
|
||||
static uint rng_seed = 0;
|
||||
|
||||
static uint timer = 0; // This might already exist in libtonc but idk so i'm just making my own
|
||||
int game_speed = 1; // BY DEFAULT IS ON 1, but if changed to 2, should speed up all (or most) of the game aspects that should be sped up by speed, as in the original game.
|
||||
static int game_speed = 1; // BY DEFAULT IS SET TO 1, but if changed to 2 - 8, should speed up all (or most) of the game aspects that should be sped up by speed, as in the original game.
|
||||
static int background = 0;
|
||||
|
||||
static enum GameState game_state = GAME_SPLASH_SCREEN; // The current game state, this is used to determine what the game is doing at any given time
|
||||
@@ -182,6 +182,16 @@ int get_num_discards_remaining(void) {
|
||||
int get_money(void) {
|
||||
return money;
|
||||
}
|
||||
int get_game_speed(void)
|
||||
{
|
||||
return game_speed;
|
||||
}
|
||||
|
||||
// for the future when a menu actually lets this variable be changed.
|
||||
void set_game_speed(int game_speed)
|
||||
{
|
||||
game_speed = game_speed;
|
||||
}
|
||||
|
||||
|
||||
// Consts
|
||||
@@ -1269,7 +1279,7 @@ static void game_playing_process_input_and_state()
|
||||
if (mult > 0)
|
||||
{
|
||||
temp_score = chips * mult;
|
||||
lerped_temp_score = (float)(1.0f / game_speed) * int2fx(temp_score); // game speed affects how fast the score text increases.
|
||||
lerped_temp_score = fx2int(fxdiv(int2fx(1), int2fx(game_speed)) * int2fx(temp_score)); // game speed affects how fast the score text increases.
|
||||
lerped_score = int2fx(score);
|
||||
|
||||
display_temp_score(temp_score);
|
||||
|
||||
+7
-2
@@ -158,9 +158,14 @@ void sprite_object_reset_transform(SpriteObject* sprite_object)
|
||||
|
||||
void sprite_object_update(SpriteObject* sprite_object)
|
||||
{
|
||||
sprite_object->vx += (sprite_object->tx - sprite_object->x) / (8 / game_speed); // SPEED
|
||||
sprite_object->vy += (sprite_object->ty - sprite_object->y) / (8 / game_speed);
|
||||
sprite_object->vx += (sprite_object->tx - sprite_object->x) / (8 / get_game_speed()); // SPEED
|
||||
sprite_object->vy += (sprite_object->ty - sprite_object->y) / (8 / get_game_speed()); // this makes the game_speed not be
|
||||
// able to be more than 8, because of
|
||||
//integer division making it a divide by 0.
|
||||
// shouldn't be a problem since speed 9 or more
|
||||
// is way too much lol.
|
||||
|
||||
|
||||
sprite_object->vscale += (sprite_object->tscale - sprite_object->scale) / 8; // Scale up the card when it's played
|
||||
|
||||
sprite_object->vrotation += (sprite_object->trotation - sprite_object->rotation) / 8; // Rotate the card when it's played
|
||||
|
||||
Reference in New Issue
Block a user