Changeset 1404


Ignore:
Timestamp:
May 20, 2012, 2:30:46 PM (9 years ago)
Author:
sam
Message:

orbital: fix uninitialised variables and allow to shoot with RCtrl.

Location:
trunk/orbital
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/orbital/player.h

    r1398 r1404  
    1616      : m_type(type),
    1717        m_stick(0),
     18        m_damped_stick(0),
     19        m_move_rotation(0),
     20        m_exhaust_rotation(0),
     21        move_rotation_timer(0),
    1822        m_ready(false)
    1923    {
     
    5357        m_options.Push(m_position, vec3(0.f, 0.f, 0.f));
    5458        m_options.Push(m_position, vec3(0.f, 0.f, 0.f));
    55 
    56         move_rotation_timer = 0.0f;
    5759    }
    5860
     
    9698        }
    9799
    98         damped_stick.x = damped_stick.x + (seconds / (seconds + 0.18f)) * (rightleft - damped_stick.x);
    99         damped_stick.z = damped_stick.z + (seconds / (seconds + 0.18f)) * (updown - damped_stick.z);
    100         vec3 applied_stick = vec3(abs(damped_stick.x), 0.0f, damped_stick.z);
    101         vec3 offset = vec3(((damped_stick.x < 0.0f)?(abs(damped_stick.x) * 30.f):(0.f)), 0.0f, 0.0f);
     100        m_damped_stick.x = m_damped_stick.x + (seconds / (seconds + 0.18f)) * (rightleft - m_damped_stick.x);
     101        m_damped_stick.z = m_damped_stick.z + (seconds / (seconds + 0.18f)) * (updown - m_damped_stick.z);
     102        vec3 applied_stick = vec3(abs(m_damped_stick.x), 0.0f, m_damped_stick.z);
     103        vec3 offset = vec3(((m_damped_stick.x < 0.0f)?(abs(m_damped_stick.x) * 30.f):(0.f)), 0.0f, 0.0f);
    102104
    103105        for (int i = 0; i < m_options.Count(); i++)
     
    124126            vec3 target_pos = m_position + pos[i] + (move_pos[i] - pos[i]) * applied_stick + offset;
    125127            m_options[i].m1 = m_options[i].m1 + (seconds / (seconds + 0.1f)) * (target_pos - m_options[i].m1);
    126             m_options[i].m2[0] = rot[i][0] + (((damped_stick.x < 0.0f)?(20.0f):(-20.0f)) - rot[i][0]) * abs(damped_stick.x);
    127 
    128             if (damped_stick.x < 0.3f && damped_stick.x > -0.3f)
     128            m_options[i].m2[0] = rot[i][0] + (((m_damped_stick.x < 0.0f)?(20.0f):(-20.0f)) - rot[i][0]) * abs(m_damped_stick.x);
     129
     130            if (m_damped_stick.x < 0.3f && m_damped_stick.x > -0.3f)
    129131                m_options[i].m2[2] += seconds * (i & 1 ? 600.f : -600.f);
    130132            else
    131                 m_options[i].m2[2] += seconds * ((damped_stick.x < 0.0f)?(600.0f):(-600.0f));
    132         }
    133 
    134         if (damped_stick.x > 0.5f || damped_stick.x < -0.5f)
     133                m_options[i].m2[2] += seconds * ((m_damped_stick.x < 0.0f)?(600.0f):(-600.0f));
     134        }
     135
     136        if (m_damped_stick.x > 0.5f || m_damped_stick.x < -0.5f)
    135137        {
    136138            if (move_rotation_timer > 0.8f)
    137                 move_rotation.z += damped_stick.x * -420.f * seconds;
     139                m_move_rotation.z += m_damped_stick.x * -420.f * seconds;
    138140            else
    139141                move_rotation_timer += seconds;
     
    142144        {
    143145            move_rotation_timer = 0.0f;
    144             move_rotation.z -= move_rotation.z * (seconds / (seconds + 0.2f));
    145         }
    146 
    147         exhaust_rotation.z += 600.0f * seconds;
    148 
    149         if (move_rotation.z > 180.f)
    150             move_rotation.z -= 360.f;
    151         else if (move_rotation.z < -180.f)
    152             move_rotation.z += 360.f;
    153 
    154         if (exhaust_rotation.z > 180.f)
    155             exhaust_rotation.z -= 360.f;
    156         else if (exhaust_rotation.z < -180.f)
    157             exhaust_rotation.z += 360.f;
    158 
    159         m_rotation = quat::fromeuler_xyz(vec3(((damped_stick.z <= 0.0f)?(damped_stick.z):(0.0f)) * -60.0f, 0.f, damped_stick.x * -50.0f) + move_rotation);
     146            m_move_rotation.z -= m_move_rotation.z * (seconds / (seconds + 0.2f));
     147        }
     148
     149        m_exhaust_rotation.z += 600.0f * seconds;
     150
     151        if (m_move_rotation.z > 180.f)
     152            m_move_rotation.z -= 360.f;
     153        else if (m_move_rotation.z < -180.f)
     154            m_move_rotation.z += 360.f;
     155
     156        if (m_exhaust_rotation.z > 180.f)
     157            m_exhaust_rotation.z -= 360.f;
     158        else if (m_exhaust_rotation.z < -180.f)
     159            m_exhaust_rotation.z += 360.f;
     160
     161        m_rotation = quat::fromeuler_xyz(vec3(((m_damped_stick.z <= 0.0f)?(m_damped_stick.z):(0.0f)) * -60.0f, 0.f, m_damped_stick.x * -50.0f) + m_move_rotation);
    160162
    161163        if (m_type == 0)
     
    184186        if (m_type == 0)
    185187        {
    186             m_exhaust_mesh.Render(model * mat4::translate(vec3(-4.f,0.f,0.f)) * mat4::fromeuler_xyz(exhaust_rotation * -1.0f));
    187             m_exhaust_mesh.Render(model * mat4::translate(vec3( 4.f,0.f,0.f)) * mat4::fromeuler_xyz(exhaust_rotation));
    188         }
    189         else
    190             m_exhaust_mesh.Render(model * mat4::fromeuler_xyz(exhaust_rotation));
     188            m_exhaust_mesh.Render(model * mat4::translate(vec3(-4.f,0.f,0.f)) * mat4::fromeuler_xyz(m_exhaust_rotation * -1.0f));
     189            m_exhaust_mesh.Render(model * mat4::translate(vec3( 4.f,0.f,0.f)) * mat4::fromeuler_xyz(m_exhaust_rotation));
     190        }
     191        else
     192            m_exhaust_mesh.Render(model * mat4::fromeuler_xyz(m_exhaust_rotation));
    191193
    192194        for (int i = 0; i < m_options.Count(); i++)
    193195        {
    194196            mat4 t = mat4::translate(m_options[i].m1);
    195             if (m_stick && m_stick->GetButtonCount() >= 4
    196                  && m_stick->GetButton(12))
     197
     198            bool fire = m_stick && m_stick->GetButtonCount() >= 4
     199                                && m_stick->GetButton(12);
     200            fire = fire || Input::GetButtonState(305 /* Right Ctrl */);
     201            if (fire)
    197202                m_laser_mesh.Render(t);
     203
    198204            t *= mat4::fromeuler_yxz(m_options[i].m2);
    199205            m_option_mesh.Render(t);
     
    208214    Array<vec3, vec3> m_options;
    209215
    210     vec3 damped_stick;
    211     vec3 move_rotation;
    212     vec3 exhaust_rotation;
     216    vec3 m_damped_stick;
     217    vec3 m_move_rotation;
     218    vec3 m_exhaust_rotation;
    213219    float move_rotation_timer;
    214220
  • trunk/orbital/snake.h

    r1397 r1404  
    7373        if (!m_stick)
    7474            m_stick = Input::TrackStick();
    75         if (m_stick && m_stick->GetButtonCount() >= 4
    76              && m_stick->GetButton(12)
    77              && (int)m_steer != (int)(m_steer - 2.f * seconds))
     75        bool fire = m_stick && m_stick->GetButtonCount() >= 4
     76                            && m_stick->GetButton(12);
     77        fire = fire || Input::GetButtonState(305 /* Right Ctrl */);
     78        if (fire && (int)m_steer != (int)(m_steer - 2.f * seconds))
    7879        {
    7980            int tohit = (int)RandF(m_nodes.Count() - 2);
     
    128129
    129130            /* Apply damage */
    130             float damage = std::min(m_nodes[i].m4, 30.f * seconds);
     131            float damage = std::min(m_nodes[i].m4, 80.f * seconds);
    131132            m_nodes[i].m3 -= damage;
    132133            m_nodes[i].m4 -= damage;
Note: See TracChangeset for help on using the changeset viewer.