Changeset 1367


Ignore:
Timestamp:
May 12, 2012, 12:44:31 AM (9 years ago)
Author:
sam
Message:

orbital: make the snake even more beautiful.

Location:
trunk/orbital
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/orbital/orbital.cpp

    r1366 r1367  
    113113    }
    114114
    115     m_snake = new Snake();
    116     Ticker::Ref(m_snake);
     115    m_snakes.Push(new Snake(3));
     116    Ticker::Ref(m_snakes.Last());
     117    m_snakes.Push(new Snake(15));
     118    Ticker::Ref(m_snakes.Last());
    117119
    118120    /* Add player */
     
    206208    for (int i = 0; i < m_players.Count(); i++)
    207209        Ticker::Unref(m_players[i]);
    208     Ticker::Unref(m_snake);
     210    for (int i = 0; i < m_snakes.Count(); i++)
     211        Ticker::Unref(m_snakes[i]);
    209212    //Ticker::Unref(m_particlesystem);
    210213    Ticker::Unref(m_small_stars);
  • trunk/orbital/orbital.h

    r1366 r1367  
    3838    Array<Player *> m_players;
    3939    Array<Tank *> m_tanks;
    40     Snake *m_snake;
     40    Array<Snake *> m_snakes;
    4141
    4242    bool m_ready;
  • trunk/orbital/snake.h

    r1366 r1367  
    1313{
    1414public:
    15     Snake()
     15    Snake(int nodes)
    1616      : m_steer(0.f),
    1717        m_ready(false)
    1818    {
    19         m_head.SendCommand("sc1,1,1,1,afcb10,10,10,1,sc.9,.6,.1,1,afcb3,3,30,.8,fl");
    20         m_head.SendCommand("sc1,1,1,1,afcb12,.4,.4,.4,tx-3,tz8,mz,fl");
    21         m_head.SendCommand("sc1,1,1,1,afcb12,.4,.4,.4,tx-3,tz12,mz,fl");
     19        m_head.SendCommand("sc1,1,1,1,afcb10,10,10,1,sc.9,.6,.1,1,afcb30,3,3,.8,fl");
     20        m_head.SendCommand("sc1,1,1,1,afcb.4,.4,12,.4,tz3,tx8,mx,fl");
     21        m_head.SendCommand("sc1,1,1,1,afcb.4,.4,12,.4,tz3,tx12,mx,fl");
     22        m_head.SendCommand("sc.4,.6,.8,.6,afcb5,8,8,1,ty3,tz3,fl");
    2223
    23         m_body.SendCommand("sc1,1,1,1,afcb12,6,6,1,sc.9,.6,.1,1,afcb3,20,3,.8,afcb3,3,20,.8,fl");
    24         m_body.SendCommand("sc1,1,1,1,afcb8,.4,.4,.4,ty8,my,fl");
    25         m_body.SendCommand("sc1,1,1,1,afcb8,.4,.4,.4,tz8,mz,fl");
     24        m_body.SendCommand("sc1,1,1,1,afcb6,6,12,1,sc.9,.6,.1,1,afcb3,20,3,.8,afcb20,3,3,.8,fl");
     25        m_body.SendCommand("sc1,1,1,1,afcb.4,.4,7,.4,ty8,my,fl");
     26        m_body.SendCommand("sc1,1,1,1,afcb.4,.4,7,.4,tx8,mx,fl");
    2627
    27         m_position = vec3(-300.f, 20.f, 300.f);
    28         m_rotation = quat::rotate(90.f, vec3(0, 1, 0));
     28        m_position = vec3(RandF(-250.f, -350.f), 20.f, RandF(250.f, 350.f));
     29        m_rotation = quat::rotate(RandF(30.f, 70.f), 0.f, 1.f, 0.f);;
    2930
    30         for (int i = 0; i < 10; i++)
     31        for (int i = 0; i < nodes; i++)
    3132            m_nodes.Push(vec3(0.f, 0.f, 0.f), 0.f);
    3233    }
     
    4445
    4546        m_steer += 2.f * seconds;
    46         float test = sinf(m_steer) * 90.f;
     47        float test = sinf(m_steer) * 120.f;
    4748        m_rotation *= quat::rotate(seconds * test, vec3(0, 1, 0));
    4849
     
    5455        {
    5556            vec3 newdelta = m_nodes[i].m1 - deltapos;
    56             if (dot(newdelta, newdelta) > 10.f * 10.f)
    57                 newdelta = 10.f * normalize(newdelta);
     57            if (dot(newdelta, newdelta) > 12.f * 12.f)
     58                newdelta = 12.f * normalize(newdelta);
    5859            deltapos = newdelta + deltapos - m_nodes[i].m1;
    5960            m_nodes[i].m1 = newdelta;
    60             m_nodes[i].m2 += seconds * ((i & 1) ? 100.f : -100.f);
     61            m_nodes[i].m2 += seconds * ((i & 1) ? 200.f : -200.f);
    6162        }
    6263    }
     
    7475
    7576        vec3 pos = m_position;
    76         quat rot = m_rotation * quat::rotate(90.f, 0.f, 1.f, 0.f);
     77        quat rot = m_rotation;
    7778        mat4 model = mat4::translate(pos) * mat4(rot);
    7879        m_head.Render(model);
     
    8283            pos += m_nodes[i].m1;
    8384            float angle = (180.f / M_PI) * atan2(m_nodes[i].m1.x, m_nodes[i].m1.z);
    84             rot = quat::rotate(angle + 90.f, 0.f, 1.f, 0.f)
    85                 * quat::rotate(m_nodes[i].m2, 1.f, 0.f, 0.f);
     85            rot = quat::rotate(angle, 0.f, 1.f, 0.f)
     86                * quat::rotate(m_nodes[i].m2, 0.f, 0.f, 1.f);
    8687            model = mat4::translate(pos) * mat4(rot);
    8788            m_body.Render(model);
Note: See TracChangeset for help on using the changeset viewer.