Changeset 1046
- Timestamp:
- Nov 1, 2011, 6:55:19 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/deushax/debugsprite.cpp
r1035 r1046 41 41 Ticker::Ref(game); 42 42 data->tileset = Tiler::Register("deushax/art/test/character-dress.png", 43 32, 0, sqrtf(2));43 ivec2(32), ivec2(0), sqrtf(2)); 44 44 data->pos = vec3(320, 206, 0); 45 45 } -
trunk/monsterz/board.cpp
r866 r1046 94 94 { 95 95 case GAME_HUNT: 96 data->size = 48;96 data->size = ivec2(48); 97 97 break; 98 98 } … … 102 102 data->npieces = minnpieces; 103 103 data->maxnpieces = maxnpieces; 104 data->screen = Tiler::Register(PNG_BACKGROUND, ivec2(640, 480), 0, 1.0f);105 data->board = Tiler::Register(PNG_BOARD, 384, 0, 1.0f);106 data->tiles = Tiler::Register(PNG_TILES, data->size, 0, 1.0f);107 data->icons = Tiler::Register(PNG_ICONS, 24, 0, 1.0f);104 data->screen = Tiler::Register(PNG_BACKGROUND, ivec2(640, 480), ivec2(0), 1.0f); 105 data->board = Tiler::Register(PNG_BOARD, ivec2(384), ivec2(0), 1.0f); 106 data->tiles = Tiler::Register(PNG_TILES, data->size, ivec2(0), 1.0f); 107 data->icons = Tiler::Register(PNG_ICONS, ivec2(24), ivec2(0), 1.0f); 108 108 data->click = Sampler::Register(WAV_CLICK); 109 109 data->whip = Sampler::Register(WAV_WHIP); -
trunk/monsterz/interface.cpp
r1035 r1046 57 57 data->title = NULL; 58 58 data->board = NULL; 59 data->tiles = Tiler::Register(PNG_TILES, 48, 0, 1.0f);59 data->tiles = Tiler::Register(PNG_TILES, ivec2(48), ivec2(0), 1.0f); 60 60 data->state = InterfaceData::INIT; 61 61 -
trunk/monsterz/piece.cpp
r958 r1046 93 93 { 94 94 case PIECE_HUNT: 95 data->size = 48;96 data->tileset = Tiler::Register(PNG_TILES, data->size, 0, 1.0f);95 data->size = ivec2(48); 96 data->tileset = Tiler::Register(PNG_TILES, data->size, ivec2(0), 1.0f); 97 97 data->pieceid = 80 + 20 * pieceid; 98 98 break; … … 100 100 101 101 data->pos = data->cell * data->size; 102 data->off = 0;102 data->off = ivec2(0); 103 103 } 104 104 … … 281 281 if (t >= 1.0f) 282 282 t = 1.0f; 283 data->pos = data->pos_src + (t * trip +0.5f);283 data->pos = data->pos_src + t * vec2(trip) + vec2(0.5f); 284 284 285 285 float off_time = data->off_src.len() / data->speed; -
trunk/monsterz/thumbs.cpp
r866 r1046 47 47 : data(new ThumbsData()) 48 48 { 49 data->icons = Tiler::Register(PNG_ICONS, 24, 0, 1.0f);49 data->icons = Tiler::Register(PNG_ICONS, ivec2(24), ivec2(0), 1.0f); 50 50 51 51 data->npieces = 0; -
trunk/monsterz/title.cpp
r1035 r1046 139 139 srand(rand() ^ time(NULL)); 140 140 141 data->logo = Tiler::Register(PNG_TITLE_LOGO, ivec2(380, 181), 0, 1.0f);141 data->logo = Tiler::Register(PNG_TITLE_LOGO, ivec2(380, 181), ivec2(0), 1.0f); 142 142 data->logo_sprite = new Sprite(data->logo, 0); 143 143 data->logo_sprite->position = vec3(640 / 2 - 380 / 2, 250, 10); 144 144 Ticker::Ref(data->logo_sprite); 145 145 146 data->ground = Tiler::Register(PNG_TITLE_GROUND, ivec2(384, 80), 0, 1.0f);146 data->ground = Tiler::Register(PNG_TITLE_GROUND, ivec2(384, 80), ivec2(0), 1.0f); 147 147 data->ground_pos = ivec2((bbox[1] - bbox[0]).xy() / ivec2(2, 4)) 148 148 - ivec2(192, 80); 149 149 150 data->rocks = Tiler::Register(PNG_TITLE_ROCKS, ivec2(640, 155), 0, 1.0f);150 data->rocks = Tiler::Register(PNG_TITLE_ROCKS, ivec2(640, 155), ivec2(0), 1.0f); 151 151 data->rocks_pos = ivec2((bbox[1] - bbox[0]).xy() / ivec2(2, 2)) 152 152 - ivec2(320, 240); 153 153 154 data->title = Tiler::Register(PNG_TITLE, 384, 0, 1.0f);155 data->stars = Tiler::Register(PNG_STARS, ivec2(384, 144), 0, 1.0f);156 data->clouds = Tiler::Register(PNG_CLOUDS, ivec2(160, 32), 0, 1.0f);157 data->eagle.tiles = Tiler::Register(PNG_EAGLE, 16, 0, 1.0f);154 data->title = Tiler::Register(PNG_TITLE, ivec2(384), ivec2(0), 1.0f); 155 data->stars = Tiler::Register(PNG_STARS, ivec2(384, 144), ivec2(0), 1.0f); 156 data->clouds = Tiler::Register(PNG_CLOUDS, ivec2(160, 32), ivec2(0), 1.0f); 157 data->eagle.tiles = Tiler::Register(PNG_EAGLE, ivec2(16), ivec2(0), 1.0f); 158 158 for (int n = 0; n < 6; n++) 159 159 data->anim[n] = Tiler::Register(PNG_TITLEANIM[n], 160 animsize[n], 0, 1.0f);160 animsize[n], ivec2(0), 1.0f); 161 161 for (int n = 0; n < 7; n++) 162 162 data->event[n] = Tiler::Register(PNG_TITLEEVENT[n], 163 eventsize[n], 0, 1.0f);163 eventsize[n], ivec2(0), 1.0f); 164 164 data->state = TitleData::IDLE; 165 165 data->period = TitleData::DAY; … … 174 174 data->cloudpos[n] = vec2(RandF((bbox[1] - bbox[0]).x), 175 175 RandF(80) + (bbox[1] - bbox[0]).y - 300); 176 data->cloudspeed[n] = RandF(-0.01f, 0.01f);176 data->cloudspeed[n] = vec2(RandF(-0.01f, 0.01f)); 177 177 } 178 178 … … 362 362 TileSet *tiler = NULL; 363 363 int tileid = 0; 364 ivec2 pos = 0;364 ivec2 pos = ivec2(0); 365 365 366 366 switch (data->state) -
trunk/src/debug/record.cpp
r863 r1046 54 54 55 55 data->path = strdup(path); 56 data->size = 0;56 data->size = ivec2(0); 57 57 data->fps = (int)(fps + 0.5f); 58 58 #if defined USE_PIPI -
trunk/src/font.cpp
r866 r1046 47 47 sprintf(data->name, "<font> %s", path); 48 48 49 data->tileset = Tiler::Register(path, 0, 16, 1.0f);49 data->tileset = Tiler::Register(path, ivec2(0), ivec2(16), 1.0f); 50 50 data->size = data->tileset->GetSize(0); 51 51 -
trunk/src/image/codec/dummy-image.cpp
r962 r1046 45 45 bool DummyImageData::Open(char const *path) 46 46 { 47 size = 256;47 size = ivec2(256); 48 48 format = Image::FORMAT_RGBA; 49 49 pixels = (uint8_t *)malloc(256 * 256 * 4 * sizeof(*pixels)); -
trunk/src/input.cpp
r1037 r1046 139 139 data->entities[n]->pressed = data->buttons; 140 140 else 141 data->entities[n]->clicked = 0;141 data->entities[n]->clicked = ivec3(0); 142 142 } 143 143 else … … 145 145 data->entities[n]->mousepos = ivec2(-1); 146 146 /* FIXME */ 147 data->entities[n]->released = 0;148 data->entities[n]->pressed = 0;149 data->entities[n]->clicked = 0;147 data->entities[n]->released = ivec3(0); 148 data->entities[n]->pressed = ivec3(0); 149 data->entities[n]->clicked = ivec3(0); 150 150 } 151 151 } -
trunk/src/map.cpp
r810 r1046 136 136 { 137 137 /* This is a tileset image file. Associate it with firstgid. */ 138 data->tilesets[data->ntilers] = Tiler::Register(str, 32, 0,139 sqrtf(2));138 data->tilesets[data->ntilers] = Tiler::Register(str, ivec2(32), 139 ivec2(0), sqrtf(2)); 140 140 data->ntilers++; 141 141 //Log::Debug("new tiler %s\n", str); -
trunk/src/matrix.cpp
r1044 r1046 74 74 float norm = v.len(); 75 75 if (!norm) 76 return vec4(0 );76 return vec4(0.0f); 77 77 return v / norm; 78 78 } … … 127 127 } 128 128 129 template<> void ivec2::printf() const 130 { 131 Log::Debug("[ %i %i ]\n", x, y); 132 } 133 129 134 template<> void vec3::printf() const 130 135 { … … 132 137 } 133 138 139 template<> void ivec3::printf() const 140 { 141 Log::Debug("[ %i %i %i ]\n", x, y, z); 142 } 143 134 144 template<> void vec4::printf() const 135 145 { 136 146 Log::Debug("[ %6.6f %6.6f %6.6f %6.6f ]\n", x, y, z, w); 147 } 148 149 template<> void ivec4::printf() const 150 { 151 Log::Debug("[ %i %i %i %i ]\n", x, y, z, w); 137 152 } 138 153 -
trunk/src/matrix.h
r1044 r1046 64 64 } 65 65 66 #define OPERATORS(elems) \66 #define LINEAR_OPS(elems) \ 67 67 inline T& operator[](int n) { return *(&x + n); } \ 68 68 inline T const& operator[](int n) const { return *(&x + n); } \ … … 70 70 VECTOR_OP(elems, -) \ 71 71 VECTOR_OP(elems, +) \ 72 \ 73 BOOL_OP(elems, ==, ==, true) \ 74 BOOL_OP(elems, !=, ==, false) \ 75 \ 76 SCALAR_OP(elems, *) \ 77 SCALAR_OP(elems, /) \ 78 \ 79 inline Vec##elems<T> operator -() const \ 80 { \ 81 Vec##elems<T> ret; \ 82 for (int n = 0; n < elems; n++) \ 83 ret[n] = -(*this)[n]; \ 84 return ret; \ 85 } \ 86 \ 87 inline T sqlen() const \ 88 { \ 89 T acc = 0; \ 90 for (int n = 0; n < elems; n++) \ 91 acc += (*this)[n] * (*this)[n]; \ 92 return acc; \ 93 } \ 94 \ 95 inline float len() const \ 96 { \ 97 using namespace std; \ 98 return sqrtf((float)sqlen()); \ 99 } \ 100 \ 101 template<typename U> \ 102 friend Vec##elems<U> normalize(Vec##elems<U>); \ 103 \ 104 void printf() const; 105 106 #define OTHER_OPS(elems) \ 72 107 VECTOR_OP(elems, *) \ 73 108 VECTOR_OP(elems, /) \ 74 109 \ 75 BOOL_OP(elems, ==, ==, true) \76 BOOL_OP(elems, !=, ==, false) \77 110 BOOL_OP(elems, <=, <=, true) \ 78 111 BOOL_OP(elems, >=, >=, true) \ … … 80 113 BOOL_OP(elems, >, >, true) \ 81 114 \ 82 SCALAR_OP(elems, -) \83 SCALAR_OP(elems, +) \84 SCALAR_OP(elems, *) \85 SCALAR_OP(elems, /) \86 \87 115 template<typename U> \ 88 116 inline operator Vec##elems<U>() const \ … … 94 122 } \ 95 123 \ 96 inline Vec##elems<T> operator -() const \97 { \98 Vec##elems<T> ret; \99 for (int n = 0; n < elems; n++) \100 ret[n] = -(*this)[n]; \101 return ret; \102 } \103 \104 inline T sqlen() const \105 { \106 T acc = 0; \107 for (int n = 0; n < elems; n++) \108 acc += (*this)[n] * (*this)[n]; \109 return acc; \110 } \111 \112 inline float len() const \113 { \114 using namespace std; \115 return sqrtf((float)sqlen()); \116 } \117 \118 124 template<typename U> \ 119 friend U dot(Vec##elems<U>, Vec##elems<U>); \ 120 template<typename U> \ 121 friend Vec##elems<U> normalize(Vec##elems<U>); \ 122 \ 123 void printf() const; 125 friend U dot(Vec##elems<U>, Vec##elems<U>); 124 126 125 127 #define SWIZZLE2(e1, e2) \ 126 128 inline Vec2<T> e1##e2() const \ 127 129 { \ 128 return Vec2<T>( e1,e2); \130 return Vec2<T>(this->e1, this->e2); \ 129 131 } 130 132 … … 132 134 inline Vec3<T> e1##e2##e3() const \ 133 135 { \ 134 return Vec3<T>( e1, e2,e3); \136 return Vec3<T>(this->e1, this->e2, this->e3); \ 135 137 } 136 138 … … 138 140 inline Vec4<T> e1##e2##e3##e4() const \ 139 141 { \ 140 return Vec4<T>( e1, e2, e3,e4); \142 return Vec4<T>(this->e1, this->e2, this->e3, this->e4); \ 141 143 } 142 144 … … 195 197 { 196 198 inline Vec2() { } 197 inline Vec2(T val) { x = y = val; }199 explicit inline Vec2(T val) { x = y = val; } 198 200 inline Vec2(T _x, T _y) { x = _x; y = _y; } 199 201 200 OPERATORS(2) 202 LINEAR_OPS(2) 203 OTHER_OPS(2) 201 204 202 205 SWIZZLE22(x); SWIZZLE22(y); … … 231 234 { 232 235 inline Vec3() { } 233 inline Vec3(T val) { x = y = z = val; }236 explicit inline Vec3(T val) { x = y = z = val; } 234 237 inline Vec3(T _x, T _y, T _z) { x = _x; y = _y; z = _z; } 235 238 inline Vec3(Vec2<T> _xy, T _z) { x = _xy.x; y = _xy.y; z = _z; } 236 239 inline Vec3(T _x, Vec2<T> _yz) { x = _x; y = _yz.x; z = _yz.y; } 237 240 238 OPERATORS(3) 241 LINEAR_OPS(3) 242 OTHER_OPS(3) 239 243 240 244 SWIZZLE23(x); SWIZZLE23(y); SWIZZLE23(z); … … 273 277 { 274 278 inline Vec4() { } 275 inline Vec4(T val) { x = y = z = w = val; } 276 inline Vec4(T _x, T _y, T _z, T _w) { x = _x; y = _y; z = _z; w = _w; } 277 inline Vec4(Vec2<T> _xy, T _z, T _w) { x = _xy.x; y = _xy.y; z = _z; w = _w; } 278 inline Vec4(T _x, Vec2<T> _yz, T _w) { x = _x; y = _yz.x; z = _yz.y; w = _w; } 279 inline Vec4(T _x, T _y, Vec2<T> _zw) { x = _x; y = _y; z = _zw.x; w = _zw.y; } 280 inline Vec4(Vec2<T> _xy, Vec2<T> _zw) { x = _xy.x; y = _xy.y; z = _zw.x; w = _zw.y; } 281 inline Vec4(Vec3<T> _xyz, T _w) { x = _xyz.x; y = _xyz.y; z = _xyz.z; w = _w; } 282 inline Vec4(T _x, Vec3<T> _yzw) { x = _x; y = _yzw.x; z = _yzw.y; w = _yzw.z; } 283 284 OPERATORS(4) 279 explicit inline Vec4(T val) : x(val), y(val), z(val), w(val) { } 280 inline Vec4(T _x, T _y, T _z, T _w) : x(_x), y(_y), z(_z), w(_w) { } 281 inline Vec4(Vec2<T> _xy, T _z, T _w) : x(_xy.x), y(_xy.y), z(_z), w(_w) { } 282 inline Vec4(T _x, Vec2<T> _yz, T _w) : x(_x), y(_yz.x), z(_yz.y), w(_w) { } 283 inline Vec4(T _x, T _y, Vec2<T> _zw) : x(_x), y(_y), z(_zw.x), w(_zw.y) { } 284 inline Vec4(Vec2<T> _xy, Vec2<T> _zw) : x(_xy.x), y(_xy.y), z(_zw.x), w(_zw.y) { } 285 inline Vec4(Vec3<T> _xyz, T _w) : x(_xyz.x), y(_xyz.y), z(_xyz.z), w(_w) { } 286 inline Vec4(T _x, Vec3<T> _yzw) : x(_x), y(_yzw.x), z(_yzw.y), w(_yzw.z) { } 287 288 LINEAR_OPS(4) 289 OTHER_OPS(4) 285 290 286 291 SWIZZLE24(x); SWIZZLE24(y); SWIZZLE24(z); SWIZZLE24(w); … … 342 347 { 343 348 inline Mat4() { } 344 inline Mat4(T val)349 explicit inline Mat4(T val) 345 350 { 346 351 for (int j = 0; j < 4; j++) -
trunk/src/text.cpp
r866 r1046 88 88 { 89 89 Font *font = Forge::GetFont(data->font); 90 vec3 delta = 0;90 vec3 delta(0.0f); 91 91 if (data->align == ALIGN_RIGHT) 92 92 delta.x -= data->length * font->GetSize().x; -
trunk/src/tileset.cpp
r968 r1046 73 73 { 74 74 if (size.x <= 0 || size.y <= 0) 75 size = 32;75 size = ivec2(32, 32); 76 76 data->count.i = data->isize.x > size.i ? data->isize.x / size.i : 1; 77 77 data->count.j = data->isize.y > size.j ? data->isize.y / size.j : 1; -
trunk/src/worldentity.cpp
r735 r1046 26 26 WorldEntity::WorldEntity() 27 27 { 28 position = 0;29 rotation = 0;30 velocity = 0;31 bbox[0] = bbox[1] = 0;28 position = vec3(0); 29 rotation = vec3(0); 30 velocity = vec3(0); 31 bbox[0] = bbox[1] = vec3(0); 32 32 33 mousepos = 0;34 mousebuttons = 0;35 pressed = 0;36 clicked = 0;37 released = 0;33 mousepos = ivec2(0); 34 mousebuttons = ivec3(0); 35 pressed = ivec3(0); 36 clicked = ivec3(0); 37 released = ivec3(0); 38 38 } 39 39
Note: See TracChangeset
for help on using the changeset viewer.