Changeset 295


Ignore:
Timestamp:
Jan 26, 2011, 5:48:40 PM (10 years ago)
Author:
sam
Message:

Fix a few warnings here and there, and try to use the vector classes.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/deushax/debugsprite.cpp

    r294 r295  
    2525    Game *game;
    2626    int tiler;
    27     float x, y, z;
     27    float3 pos;
    2828};
    2929
     
    3939    data->tiler = Tiler::Register("art/test/character-dress.png",
    4040                                  32, 32, sqrtf(2));
    41     data->x = 320;
    42     data->y = 206;
    43     data->z = 0;
     41    data->pos = float3(320, 206, 0);
    4442}
    4543
     
    4846    Entity::TickGame(deltams);
    4947
    50     float2 axis = Input::GetAxis(0);
    51     data->x += 0.1f * sqrtf(2.0f) * deltams * axis.x;
    52     data->y += 0.1f * deltams * axis.y;
     48    float3 move = deltams * 0.1f * (float3)Input::GetAxis(0);
     49    data->pos = data->pos + move * float3(sqrtf(2.0f), 1.0f, 1.0f);
    5350}
    5451
     
    5754    Entity::TickDraw(deltams);
    5855
    59     int x = data->x;
    60     int y = data->y;
    61     int z = data->z;
     56    int3 pos = (int3)data->pos;
    6257
    6358    Scene::GetDefault()->AddTile((data->tiler << 16) | 31,
    64                                  x - 16, y, z, 1);
     59                                 pos.x - 16, pos.y, pos.z, 1);
    6560    Scene::GetDefault()->AddTile((data->tiler << 16) | 15,
    66                                  x - 16, y, z + 32, 1);
     61                                 pos.x - 16, pos.y, pos.z + 32, 1);
    6762}
    6863
  • trunk/monsterz/board.cpp

    r294 r295  
    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.0003f, 0));
    7373    Ticker::Ref(data->emitter);
    7474
     
    113113        int id = 110 + 20 * (rand() % 7);
    114114        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);
     115        float3 vel(RandF(-0.1f, 0.1f), RandF(0.05f, 0.1f), 0.0f);
    116116        data->emitter->AddParticle(id, pos, vel);
    117117    }
  • trunk/src/input.cpp

    r294 r295  
    5858    f.y += up;
    5959    if (left && up)
    60     {
    61         f.x *= invsqrt2;
    62         f.y *= invsqrt2;
    63     }
     60        f = f * invsqrt2;
    6461
    6562    return f;
  • trunk/src/matrix.h

    r294 r295  
    4747    }
    4848
     49#define CAST_OP(elems, dest) \
     50    inline operator Vec##dest<T>() const \
     51    { \
     52        Vec##dest<T> ret; \
     53        for (int n = 0; n < elems && n < dest; n++) \
     54            ret[n] = (*this)[n]; \
     55        return ret; \
     56    }
     57
    4958#define OPERATORS(elems) \
    5059    inline T& operator[](int n) { return *(&x + n); } \
     
    6372    SCALAR_OP(elems, *) \
    6473    SCALAR_OP(elems, /) \
     74    \
     75    CAST_OP(elems, 2) \
     76    CAST_OP(elems, 3) \
     77    CAST_OP(elems, 4) \
    6578    \
    6679    template<typename U> \
     
    8598        return sqrtf((float)sqlen()); \
    8699    }
     100
     101template <typename T> struct Vec2;
     102template <typename T> struct Vec3;
     103template <typename T> struct Vec4;
    87104
    88105template <typename T> struct Vec2
Note: See TracChangeset for help on using the changeset viewer.