Changeset 1336


Ignore:
Timestamp:
May 3, 2012, 1:54:17 PM (9 years ago)
Author:
sam
Message:

orbital: play with the tanks.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/orbital/orbital.cpp

    r1334 r1336  
    3131        for (int i = 0; i < 20; i++)
    3232        {
    33             m.SendCommand(((i + j) % 2) ? "sc.3,.7,.9,1,scb.3,.7,.9,1"
    34                                         : "sc.3,.3,.7,1,scb.3,.3,.7,1");
     33            m.SendCommand(((i + j) % 2) ? "sc.2,.6,.7,1,scb.2,.6,.7,1"
     34                                        : "sc.2,.2,.6,1,scb.2,.2,.6,1");
    3535            m.SendCommand("ac4,2,44,40,0,0,ty-1,ad4,40,0,ry45");
    3636            m.Scale(vec3(std::sqrt(0.5f)));
    37             m.Translate(vec3(i * 44 - 440, -50, j * 44 - 440));
     37            m.Translate(vec3(i * 44 - 440, 0, j * 44 - 440));
    3838            m.Flush();
    3939        }
     
    8888    Ticker::Ref(m_camera);
    8989
     90    for (int j = 0; j < 4; j++)
    9091    for (int i = 0; i < 4; i++)
    9192    {
    9293        m_tanks << new Tank();
    93         m_tanks.Last()->m_position = vec3(i * 40.f - 60.f, 0, i * 10.f + 20.f);
     94        m_tanks.Last()->m_position = vec3(i * 40.f - 60.f, 0, j * 40.f + 20.f);
     95        m_tanks.Last()->SetTarget(vec3(i * 80.f - 60.f, 0, j * 80.f - 30.f));
    9496        Ticker::Ref(m_tanks.Last());
    9597    }
     
    110112        Ticker::Shutdown();
    111113
     114#if 0
    112115    if (m_auto_cam_timer > 0.0f)
    113116        m_auto_cam_timer -= seconds;
     
    148151    quat q = quat::rotate(-90.f, 0.f, 0.f, 1.f);
    149152    mat4 anim = mat4(~q * quat::fromeuler(m_angle) * q);
    150     mat4 model = mat4::translate(vec3(0));
    151 
    152     m_model = model * anim;
     153#endif
     154
     155    m_model = mat4(1.f);
    153156}
    154157
  • trunk/orbital/tank.h

    r1335 r1336  
    1414public:
    1515    Tank()
    16       : m_angle(0.f),
     16      : m_turret_angle(0.f),
    1717        m_ready(false)
    1818    {
    19         m_body.SendCommand("sc0.1,0.1,0,1,ab6,6,15,ty-2,sc1,1,1,1,afcb4,5,16,0.4,tx4,mx,fl,sc0.2,0.7,0,1,afcb8,7,10,0.4,tz-4,fl");
    20         m_head.SendCommand("sc0.2,0.7,0,1,afcb3,6,10,0.4,tx-8,afcb3,6,10,0.4,tx4,ty10,fl,sc1,1,1,1,afcb3,6,10,0.4,rx-30,ty10,fl");
     19        m_body.SendCommand("sc0.1,0.1,0,1,ab6,6,15,ty-2,sc1,1,1,1,afcb4,5,16,0.4,tx4,ty5,mx,fl,sc0.2,0.7,0,1,afcb8,7,10,0.4,tz-4,ty5,fl");
     20        m_turret.SendCommand("sc0.2,0.7,0,1,afcb3,6,10,0.4,tx-8,afcb3,6,10,0.4,tx4,ty13,fl,sc1,1,1,1,afcb3,6,10,0.4,rx-30,ty13,fl");
    2121    }
    2222
     
    2727    char const *GetName() { return "<tank>"; }
    2828
     29    /* Set a target for the tank */
     30    void SetTarget(vec3 const &position)
     31    {
     32        m_target = position;
     33    }
     34
    2935protected:
    3036    virtual void TickGame(float seconds)
     
    3238        WorldEntity::TickGame(seconds);
    3339
    34         m_rotation *= quat::rotate(seconds * 20.f, vec3(0, 1, 0));
    35         m_angle += seconds * 50.f;
     40float test = RandF(0.f, +40.f);
     41        m_rotation *= quat::rotate(seconds * test, vec3(0, 1, 0));
     42        m_velocity = m_rotation.transform(vec3(0, 0, 1));
     43        m_position += seconds * 40.f * m_velocity;
     44
     45        m_turret_angle += seconds * 50.f;
    3646    }
    3747
     
    4353        {
    4454            m_body.SendCommand("irb");
    45             m_head.SendCommand("irb");
     55            m_turret.SendCommand("irb");
    4656            m_ready = true;
    4757        }
     
    5060        m_body.Render(model);
    5161
    52         model = model * mat4::rotate(m_angle, vec3(0, 1, 0));
    53         m_head.Render(model);
     62        model = model * mat4::rotate(m_turret_angle, vec3(0, 1, 0));
     63        m_turret.Render(model);
    5464    }
    5565
    5666private:
    57     Mesh m_body, m_head;
    58     float m_angle;
     67    Mesh m_body, m_turret;
     68    vec3 m_target;
     69    float m_turret_angle;
    5970    bool m_ready;
    6071};
  • trunk/src/camera.cpp

    r1325 r1336  
    5858    WorldEntity::TickGame(seconds);
    5959
     60    int updown = Input::GetButtonState(273 /*SDLK_UP*/)
     61               - Input::GetButtonState(274 /*SDLK_DOWN*/);
     62    int rightleft = Input::GetButtonState(275 /*SDLK_RIGHT*/)
     63                  - Input::GetButtonState(276 /*SDLK_LEFT*/);
     64    int pgupdown = Input::GetButtonState(280 /*SDLK_PAGEUP*/)
     65                 - Input::GetButtonState(281 /*SDLK_PAGEDOWN*/);
     66
     67    m_position += vec3(rightleft, pgupdown, -updown) * 200.f * seconds;
     68    m_target += vec3(rightleft, 0, -updown) * 200.f * seconds;
     69
    6070    m_view_matrix = mat4::lookat(m_position, m_target, m_up);
    61     m_proj_matrix = mat4::perspective(45.0f, 640.0f, 480.0f, 1.f, 1000.0f);
     71    m_proj_matrix = mat4::perspective(45.0f, 640.0f, 480.0f, 1.f, 10000.0f);
    6272    //m_proj_matrix = mat4::ortho(-160, 160, -120, 120, .1f, 2000.0f);
    6373}
Note: See TracChangeset for help on using the changeset viewer.