Ignore:
Timestamp:
Apr 29, 2012, 11:55:32 PM (9 years ago)
Author:
sam
Message:

core: tick methods now use seconds, like any sane system.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mrpigeon/player.cpp

    r1300 r1310  
    2323#include "enemy.h"
    2424
    25 #define GRAVITY 0.0007f
    26 #define JUMPVEL 0.43f
    27 
    28 #define LEN_KICKAIR 500.0f
    29 #define LEN_KICKFLOOR 300.0f
     25#define GRAVITY 700.f
     26#define JUMPVEL 430.f
     27
     28#define LEN_KICKAIR .5f
     29#define LEN_KICKFLOOR .3f
    3030
    3131Player::Player(MrPigeon *in_game) :
     
    9595}
    9696
    97 void Player::TickGame(float deltams)
    98 {
    99     WorldEntity::TickGame(deltams);
    100 
    101     deltams *= game->GetSpeed();
    102 
    103     flytime = fmod(deltams + flytime, 400.0f);;
     97void Player::TickGame(float seconds)
     98{
     99    WorldEntity::TickGame(seconds);
     100
     101    seconds *= game->GetSpeed();
     102
     103    flytime = fmod(seconds + flytime, .4f);;
    104104
    105105    vec3 oldvel = m_velocity;
     
    108108    case WALKING:
    109109    case FUNKING:
    110         walktime = fmod(deltams + walktime, 700.0f);;
     110        walktime = fmod(seconds + walktime, .7f);;
    111111        break;
    112112    case KICKFLOOR:
    113         walktime += deltams;
     113        walktime += seconds;
    114114        if (walktime > LEN_KICKFLOOR)
    115115            state = WALKING;
    116116        break;
    117117    case FALLING:
    118         m_velocity.y -= deltams * GRAVITY;
    119         m_position += (oldvel + m_velocity) * (0.5 * deltams);
     118        m_velocity.y -= seconds * GRAVITY;
     119        m_position += (oldvel + m_velocity) * (0.5 * seconds);
    120120        if (m_position.y < 81.0f)
    121121        {
     
    125125        break;
    126126    case JUMPING:
    127         m_velocity.y -= deltams * GRAVITY;
    128         m_position += (oldvel + m_velocity) * (0.5 * deltams);
     127        m_velocity.y -= seconds * GRAVITY;
     128        m_position += (oldvel + m_velocity) * (0.5 * seconds);
    129129        if (m_velocity.y < 0.0f)
    130130            state = FALLING;
    131131        break;
    132132    case KICKAIR:
    133         walktime += deltams;
     133        walktime += seconds;
    134134        if (walktime >= LEN_KICKAIR)
    135135        {
     
    139139        break;
    140140    case DASHDOWN:
    141         m_velocity.y -= deltams * GRAVITY;
    142         m_position += (oldvel + m_velocity) * (0.5 * deltams);
     141        m_velocity.y -= seconds * GRAVITY;
     142        m_position += (oldvel + m_velocity) * (0.5 * seconds);
    143143        if (m_position.y < 81.0f)
    144144        {
     
    153153    case WALKING:
    154154        active_set = player_walk;
    155         active_frame = (int)(walktime * 8 / 700.0f);
     155        active_frame = (int)(walktime * 8 / .7f);
    156156        break;
    157157    case FUNKING:
    158158        active_set = player_walkraisefist;
    159         active_frame = (int)(walktime * 8 / 700.0f);
     159        active_frame = (int)(walktime * 8 / .7f);
    160160        break;
    161161    case KICKFLOOR:
     
    182182}
    183183
    184 void Player::TickDraw(float deltams)
    185 {
    186     WorldEntity::TickDraw(deltams);
    187 
    188     Scene::GetDefault()->AddTile(pigeon_flying, (int)(flytime * 2 / 400.0f), ivec3(81, 147, 5), 0, vec2(3.0f));
     184void Player::TickDraw(float seconds)
     185{
     186    WorldEntity::TickDraw(seconds);
     187
     188    Scene::GetDefault()->AddTile(pigeon_flying, (int)(flytime * 2 / .4f), ivec3(81, 147, 5), 0, vec2(3.0f));
    189189
    190190    Scene::GetDefault()->AddTile(active_set, active_frame, ivec3(m_position), 0, vec2(3.0f));
Note: See TracChangeset for help on using the changeset viewer.