Changeset 294


Ignore:
Timestamp:
Jan 26, 2011, 3:49:51 PM (12 years ago)
Author:
sam
Message:

Rename Float3 to float3, Int3 to int3 etc. and add the 4-member versions.

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/deushax/debugsprite.cpp

    r289 r294  
    4848    Entity::TickGame(deltams);
    4949
    50     Float2 axis = Input::GetAxis(0);
     50    float2 axis = Input::GetAxis(0);
    5151    data->x += 0.1f * sqrtf(2.0f) * deltams * axis.x;
    5252    data->y += 0.1f * deltams * axis.y;
  • trunk/monsterz/board.cpp

    r293 r294  
    4040    Mash *mashes;
    4141    Emitter *emitter;
    42     Int2 src_cell, dst_cell;
    43 
    44     Int2 mouse;
    45     Int3 buttons;
     42    int2 src_cell, dst_cell;
     43
     44    int2 mouse;
     45    int3 buttons;
    4646    float nextblink, whipdelay;
    4747
     
    7070    data->whip = Sampler::Register(WAV_WHIP);
    7171
    72     data->emitter = new Emitter(data->tiles, Float3(0, -0.0003, 0));
     72    data->emitter = new Emitter(data->tiles, float3(0, -0.0003, 0));
    7373    Ticker::Ref(data->emitter);
    7474
     
    8080        {
    8181            int id = 100 + 20 * (rand() % 7);
    82             data->pieces[i][j] = new Piece(game, Int2(i, j), id);
     82            data->pieces[i][j] = new Piece(game, int2(i, j), id);
    8383            if (j)
    8484                data->pieces[i][j]->SetBelow(data->pieces[i][j - 1]);
     
    112112    {
    113113        int id = 110 + 20 * (rand() % 7);
    114         Float3 pos(RandF(500.0f), RandF(500.0f), 8.0f);
    115         Float3 vel(RandF(-0.1, 0.1f), RandF(0.05f, 0.1f), 0.0f);
     114        float3 pos(RandF(500.0f), RandF(500.0f), 8.0f);
     115        float3 vel(RandF(-0.1, 0.1f), RandF(0.05f, 0.1f), 0.0f);
    116116        data->emitter->AddParticle(id, pos, vel);
    117117    }
    118118
    119     Int2 mouse = Input::GetMousePos();
    120     Int3 buttons = Input::GetMouseButtons();
     119    int2 mouse = Input::GetMousePos();
     120    int3 buttons = Input::GetMouseButtons();
    121121
    122122    /* If possible, make a random monster blink */
     
    152152            if (x >= 0 && x < 8 * 48 && y >= 0 && y < 8 * 48)
    153153            {
    154                 if (data->pieces[x / 48][y / 48]->Grab(Int2(0, 0)))
     154                if (data->pieces[x / 48][y / 48]->Grab(int2(0, 0)))
    155155                {
    156156                    Sampler::PlaySample(data->click);
    157157                    data->grabbed = data->pieces[x / 48][y / 48];
    158                     data->src_cell = Int2(x / 48, y / 48);
    159                     data->dst_cell = Int2(-1);
     158                    data->src_cell = int2(x / 48, y / 48);
     159                    data->dst_cell = int2(-1);
    160160                    data->state = BoardData::GRAB;
    161161                }
     
    172172            /* Mouse is still in the window, keep grabbing */
    173173            data->grabbed->Grab(mouse - data->mouse);
    174             Int2 cur_pos = data->grabbed->GetPos();
    175             Int2 cur_cell = (cur_pos + 24) / 48;
     174            int2 cur_pos = data->grabbed->GetPos();
     175            int2 cur_cell = (cur_pos + 24) / 48;
    176176            if (cur_cell.i < 0 || cur_cell.i >= 8
    177177                 || cur_cell.j < 0 || cur_cell.j >= 8
    178178                 || (cur_pos - cur_cell * 48).sqlen() > 24 * 24
    179179                 || (cur_cell - data->src_cell).sqlen() != 1)
    180                 cur_cell = Int2(-1);
     180                cur_cell = int2(-1);
    181181            /* If potential target changed, update our cache. */
    182182            if (cur_cell != data->dst_cell)
     
    187187                    data->whipdelay = DELAY_WHIP;
    188188                }
    189                 if (data->dst_cell != Int2(-1))
     189                if (data->dst_cell != int2(-1))
    190190                    data->pieces[data->dst_cell.i]
    191191                                [data->dst_cell.j]->Ungrab(data->dst_cell * 48);
    192                 if (cur_cell != Int2(-1))
     192                if (cur_cell != int2(-1))
    193193                    data->pieces[cur_cell.i]
    194194                                [cur_cell.j]->Ungrab(data->src_cell * 48);
     
    202202            /* Mouse released, or exited window, or dragged too far. */
    203203            data->grabbed->Ungrab(data->grabbed->GetCell() * 48);
    204             if (data->dst_cell != Int2(-1))
     204            if (data->dst_cell != int2(-1))
    205205                Switch(data->src_cell, data->dst_cell);
    206206            data->state = BoardData::IDLE;
     
    232232}
    233233
    234 void Board::Switch(Int2 cell_a, Int2 cell_b)
     234void Board::Switch(int2 cell_a, int2 cell_b)
    235235{
    236236    Piece *a = data->pieces[cell_a.i][cell_a.j];
     
    310310            {
    311311                data->pieces[i][j2 - 1] = data->pieces[i][j2];
    312                 data->pieces[i][j2 - 1]->SetCell(Int2(i, j2 - 1));
    313                 data->pieces[i][j2 - 1]->Move(Int2(i, j2 - 1) * 48);
     312                data->pieces[i][j2 - 1]->SetCell(int2(i, j2 - 1));
     313                data->pieces[i][j2 - 1]->Move(int2(i, j2 - 1) * 48);
    314314                list[i][j2 - 1] = list[i][j2];
    315315            }
     
    317317            /* Spawn a new piece above all the others and attach it to
    318318             * the board. */
    319             Int2 newpos = Int2(i * 48, below->GetPos().y + 48);
     319            int2 newpos = int2(i * 48, below->GetPos().y + 48);
    320320            int id = 100 + 20 * (rand() % 7);
    321             data->pieces[i][7] = new Piece(data->game, Int2(i, 7), id);
     321            data->pieces[i][7] = new Piece(data->game, int2(i, 7), id);
    322322            data->pieces[i][7]->SetBelow(below);
    323323            data->pieces[i][7]->SetPos(newpos);
    324             data->pieces[i][7]->Move(Int2(i, 7) * 48);
     324            data->pieces[i][7]->Move(int2(i, 7) * 48);
    325325            Ticker::Ref(data->pieces[i][7]);
    326326            list[i][7] = 0;
  • trunk/monsterz/board.h

    r258 r294  
    2727    virtual void TickDraw(float deltams);
    2828
    29     void Switch(Int2 cell_a, Int2 cell_b);
     29    void Switch(int2 cell_a, int2 cell_b);
    3030    int ListMashes(int list[8][8]);
    3131
  • trunk/monsterz/mash.cpp

    r287 r294  
    3333    int duh, pop;
    3434    Piece *pieces[8 * 8];
    35     Int2 cells[8 * 8];
     35    int2 cells[8 * 8];
    3636    int npieces;
    3737    float timer;
     
    8686        for (int n = 0; n < data->npieces && allready; n++)
    8787        {
    88             Int2 dest = data->pieces[n]->GetCell() * 48;
    89             Int2 cur = data->pieces[n]->GetPos();
     88            int2 dest = data->pieces[n]->GetCell() * 48;
     89            int2 cur = data->pieces[n]->GetPos();
    9090
    9191            /* If piece is still too high, don't start the animation */
  • trunk/monsterz/piece.cpp

    r289 r294  
    3232    Piece *above, *below;
    3333    int tiler;
    34     Int2 cell, pos, src, dst;
     34    int2 cell, pos, src, dst;
    3535    int id;
    3636    float speed, timer;
     
    5353 */
    5454
    55 Piece::Piece(Game *game, Int2 cell, int id)
     55Piece::Piece(Game *game, int2 cell, int id)
    5656  : data(new PieceData())
    5757{
     
    6767}
    6868
    69 void Piece::SetCell(Int2 cell)
     69void Piece::SetCell(int2 cell)
    7070{
    7171    data->cell = cell;
    7272}
    7373
    74 Int2 Piece::GetCell() const
     74int2 Piece::GetCell() const
    7575{
    7676    return data->cell;
    7777}
    7878
    79 void Piece::SetPos(Int2 pos)
     79void Piece::SetPos(int2 pos)
    8080{
    8181    data->pos = pos;
    8282}
    8383
    84 Int2 Piece::GetPos() const
     84int2 Piece::GetPos() const
    8585{
    8686    return data->pos;
     
    176176}
    177177
    178 int Piece::Grab(Int2 dir)
     178int Piece::Grab(int2 dir)
    179179{
    180180    switch (data->state)
     
    197197}
    198198
    199 int Piece::Ungrab(Int2 pos)
     199int Piece::Ungrab(int2 pos)
    200200{
    201201    switch (data->state)
     
    217217}
    218218
    219 int Piece::Move(Int2 pos)
     219int Piece::Move(int2 pos)
    220220{
    221221    switch (data->state)
     
    254254    {
    255255        data->timer += deltams;
    256         Int2 trip = data->dst - data->src;
     256        int2 trip = data->dst - data->src;
    257257        float moving_time = trip.len() / data->speed;
    258258        float t = moving_time ? data->timer / moving_time : 1.0f;
  • trunk/monsterz/piece.h

    r276 r294  
    2020{
    2121public:
    22     Piece(Game *game, Int2 cell, int id);
     22    Piece(Game *game, int2 cell, int id);
    2323    virtual ~Piece();
    2424
    25     void SetCell(Int2 cell);
    26     Int2 GetCell() const;
    27     void SetPos(Int2 pos);
    28     Int2 GetPos() const;
     25    void SetCell(int2 cell);
     26    int2 GetCell() const;
     27    void SetPos(int2 pos);
     28    int2 GetPos() const;
    2929    int GetId() const;
    3030
     
    3838    int Blink();
    3939    int Pop();
    40     int Grab(Int2 dir);
    41     int Ungrab(Int2 pos);
    42     int Move(Int2 pos);
     40    int Grab(int2 dir);
     41    int Ungrab(int2 pos);
     42    int Move(int2 pos);
    4343
    4444protected:
  • trunk/src/debugfps.cpp

    r282 r294  
    4040    {
    4141        data->lines[i] = new Text(NULL, "gfx/font/ascii.png");
    42         data->lines[i]->SetPos(Int3(x, y + (i ? 8 : 0) + 16 * i, 0));
     42        data->lines[i]->SetPos(int3(x, y + (i ? 8 : 0) + 16 * i, 0));
    4343        Ticker::Ref(data->lines[i]);
    4444    }
  • trunk/src/emitter.cpp

    r290 r294  
    2828private:
    2929    int tiler;
    30     Float3 gravity;
     30    float3 gravity;
    3131    int particles[100];
    32     Float3 positions[100];
    33     Float3 velocities[100];
     32    float3 positions[100];
     33    float3 velocities[100];
    3434    int nparticles;
    3535};
     
    3939 */
    4040
    41 Emitter::Emitter(int tiler, Float3 gravity)
     41Emitter::Emitter(int tiler, float3 gravity)
    4242  : data(new EmitterData())
    4343{
     
    7676}
    7777
    78 void Emitter::AddParticle(int id, Float3 pos, Float3 vel)
     78void Emitter::AddParticle(int id, float3 pos, float3 vel)
    7979{
    8080    if (data->nparticles >= 100)
  • trunk/src/emitter.h

    r290 r294  
    2424{
    2525public:
    26     Emitter(int tiler, Float3 gravity);
     26    Emitter(int tiler, float3 gravity);
    2727    virtual ~Emitter();
    2828
    29     void AddParticle(int id, Float3 pos, Float3 vel);
     29    void AddParticle(int id, float3 pos, float3 vel);
    3030
    3131protected:
  • trunk/src/input.cpp

    r236 r294  
    3535    { }
    3636
    37     Int2 mouse;
    38     Int3 buttons;
     37    int2 mouse;
     38    int3 buttons;
    3939}
    4040inputdata;
     
    4646 */
    4747
    48 Float2 Input::GetAxis(int axis)
     48float2 Input::GetAxis(int axis)
    4949{
    5050    float invsqrt2 = sqrtf(0.5f);
    51     Float2 f;
     51    float2 f;
    5252
    5353    /* Simulate a joystick using the keyboard. This SDL call is free. */
     
    6666}
    6767
    68 void Input::SetMousePos(Int2 coord)
     68void Input::SetMousePos(int2 coord)
    6969{
    7070    data->mouse = coord;
    7171}
    7272
    73 Int2 Input::GetMousePos()
     73int2 Input::GetMousePos()
    7474{
    7575    return data->mouse;
     
    8686}
    8787
    88 Int3 Input::GetMouseButtons()
     88int3 Input::GetMouseButtons()
    8989{
    9090    return data->buttons;
  • trunk/src/input.h

    r236 r294  
    2222{
    2323public:
    24     static Float2 GetAxis(int axis);
    25     static void SetMousePos(Int2 coord);
    26     static Int2 GetMousePos();
     24    static float2 GetAxis(int axis);
     25    static void SetMousePos(int2 coord);
     26    static int2 GetMousePos();
    2727    static void SetMouseButton(int index);
    2828    static void UnsetMouseButton(int index);
    29     static Int3 GetMouseButtons();
     29    static int3 GetMouseButtons();
    3030};
    3131
  • trunk/src/matrix.h

    r293 r294  
    9898};
    9999
    100 typedef Vec2<float> Float2;
    101 typedef Vec2<int> Int2;
     100typedef Vec2<float> float2;
     101typedef Vec2<int> int2;
    102102
    103103template <typename T> struct Vec3
     
    114114};
    115115
    116 typedef Vec3<float> Float3;
    117 typedef Vec3<int> Int3;
     116typedef Vec3<float> float3;
     117typedef Vec3<int> int3;
     118
     119template <typename T> struct Vec4
     120{
     121    inline Vec4() { x = y = z = w = 0; }
     122    inline Vec4(T val) { x = y = z = w = val; }
     123    inline Vec4(T _x, T _y, T _z, T _w) { x = _x; y = _y; z = _z; w = _w; }
     124
     125    OPERATORS(4)
     126
     127    union { T x; T a; T i; };
     128    union { T y; T b; T j; };
     129    union { T z; T c; T k; };
     130    union { T w; T d; T l; };
     131};
     132
     133typedef Vec4<float> float4;
     134typedef Vec4<int> int4;
    118135
    119136#define SCALAR_GLOBAL(elems, op, U) \
     
    140157GLOBALS(2)
    141158GLOBALS(3)
     159GLOBALS(4)
    142160
    143161#endif // __DH_MATRIX_H__
  • trunk/src/sdlinput.cpp

    r259 r294  
    4949
    5050    /* Handle mouse input */
    51     Int2 mouse;
     51    int2 mouse;
    5252    if (SDL_GetAppState() & SDL_APPMOUSEFOCUS)
    5353    {
  • trunk/src/text.cpp

    r282 r294  
    3030    int font;
    3131    char *text;
    32     Int3 pos;
     32    int3 pos;
    3333};
    3434
     
    4242    data->font = Forge::Register(font);
    4343    data->text = text ? strdup(text) : NULL;
    44     data->pos = Int3(0, 0, 0);
     44    data->pos = int3(0, 0, 0);
    4545
    4646    drawgroup = DRAWGROUP_HUD;
     
    5454}
    5555
    56 void Text::SetPos(Int3 pos)
     56void Text::SetPos(int3 pos)
    5757{
    5858    data->pos = pos;
  • trunk/src/text.h

    r282 r294  
    2828
    2929    void SetText(char const *text);
    30     void SetPos(Int3 pos);
     30    void SetPos(int3 pos);
    3131
    3232protected:
Note: See TracChangeset for help on using the changeset viewer.