Changeset 1717 for trunk/games


Ignore:
Timestamp:
Aug 11, 2012, 3:29:19 AM (7 years ago)
Author:
Jnat
Message:

added "player" controlled by sticks...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/games/demo-jnat/player.h

    r1716 r1717  
    3232        WorldEntity::TickGame(seconds);
    3333
     34        float updown = (float)(Input::GetButtonState(273 /*SDLK_UP*/) - Input::GetButtonState(274 /*SDLK_DOWN*/));
     35        float rightleft = (float)(Input::GetButtonState(275 /*SDLK_RIGHT*/) - Input::GetButtonState(276 /*SDLK_LEFT*/));
     36                if (!m_stick)
     37            m_stick = Input::TrackStick(0);
     38        if (!m_stick)
     39            m_stick = Input::TrackStick(0);
     40        if (m_stick && m_stick->GetAxisCount() >= 4)
     41        {
     42            rightleft += 1.f * m_stick->GetAxis(0);
     43            updown += -1.f * m_stick->GetAxis(1);
     44        }
     45
     46                //Rotate
     47                /*
    3448        float test = lol::sin(0.5f) * 200.f + 60.f;
    3549        m_rotation *= quat::rotate(seconds * test, vec3(0, 1, 0));
     
    3751        m_velocity = 120.f * m_rotation.transform(vec3(0, 0, 1));
    3852        vec3 deltapos = seconds * m_velocity;
    39         m_position += deltapos;
     53                */
     54
     55                //Player control
     56                if (rightleft * rightleft + updown * updown > 0.2f){
     57                        m_velocity = vec3(-rightleft,0,updown);//120.f * m_rotation.transform(vec3(0, 0, 1));
     58                        vec3 deltapos = 50.f* seconds * m_velocity;
     59
     60                        m_position += deltapos;
     61                }
     62
    4063    }
    4164
Note: See TracChangeset for help on using the changeset viewer.