Changeset 664
- Timestamp:
- Feb 18, 2011, 1:09:28 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/deushax/debugsprite.cpp
r633 r664 25 25 Game *game; 26 26 int tiler; 27 float3 pos;27 vec3 pos; 28 28 }; 29 29 … … 39 39 data->tiler = Tiler::Register("art/test/character-dress.png", 40 40 32, 0, sqrtf(2)); 41 data->pos = float3(320, 206, 0);41 data->pos = vec3(320, 206, 0); 42 42 } 43 43 … … 46 46 Entity::TickGame(deltams); 47 47 48 float3 move = deltams * (float3)Input::GetAxis(0);49 data->pos = data->pos + move * float3(0.1f * sqrtf(2.0f), .1f, 0.1f);48 vec3 move = deltams * (vec3)Input::GetAxis(0); 49 data->pos = data->pos + move * vec3(0.1f * sqrtf(2.0f), .1f, 0.1f); 50 50 } 51 51 … … 54 54 Entity::TickDraw(deltams); 55 55 56 int3 pos = (int3)data->pos;56 vec3i pos = (vec3i)data->pos; 57 57 58 58 Scene::GetDefault()->AddTile((data->tiler << 16) | 31, -
trunk/monsterz/board.cpp
r639 r664 37 37 Board::game_t game; 38 38 39 int2dim, size;39 vec2i dim, size; 40 40 int minnpieces, npieces, maxnpieces; 41 41 … … 53 53 struct Pair grabbed; 54 54 int nmoves; 55 int2src_cell, dst_cell;55 vec2i src_cell, dst_cell; 56 56 57 57 /* Fusion */ … … 66 66 Thumbs *thumbs; 67 67 68 int2oldmouse;69 int3oldbuttons;68 vec2i oldmouse; 69 vec3i oldbuttons; 70 70 float whipdelay; 71 71 … … 84 84 */ 85 85 86 Board::Board(game_t game, int2dim, int minnpieces, int maxnpieces)86 Board::Board(game_t game, vec2i dim, int minnpieces, int maxnpieces) 87 87 : data(new BoardData()) 88 88 { … … 109 109 data->whip = Sampler::Register(WAV_WHIP); 110 110 111 data->emitter = new Emitter(data->tiles, float3(0, -0.0006f, 0));111 data->emitter = new Emitter(data->tiles, vec3(0, -0.0006f, 0)); 112 112 Ticker::Ref(data->emitter); 113 113 … … 131 131 data->current[1].id = GetRandomId(); 132 132 data->current[0].piece = new Piece(Piece::PIECE_FUSION, 133 data->emitter, int2(3, 8),133 data->emitter, vec2i(3, 8), 134 134 data->current[0].id); 135 135 data->current[1].piece = new Piece(Piece::PIECE_FUSION, 136 data->emitter, int2(4, 8),136 data->emitter, vec2i(4, 8), 137 137 data->current[1].id); 138 138 Ticker::Ref(data->current[0].piece); 139 139 Ticker::Ref(data->current[1].piece); 140 data->current[0].piece->SetPos( int2(3, 7) * data->size);141 data->current[1].piece->SetPos( int2(4, 7) * data->size);140 data->current[0].piece->SetPos(vec2i(3, 7) * data->size); 141 data->current[1].piece->SetPos(vec2i(4, 7) * data->size); 142 142 143 143 data->next[0] = GetRandomId(); … … 155 155 data->scoretext = new Text(NULL, "monsterz/gfx/font2.png"); 156 156 data->scoretext->SetAlign(Text::ALIGN_RIGHT); 157 data->scoretext->SetPos( int3(624, 432, 20));157 data->scoretext->SetPos(vec3i(624, 432, 20)); 158 158 Ticker::Ref(data->scoretext); 159 159 data->score = 0; 160 160 161 position = int3(24, 72, 1);161 position = vec3i(24, 72, 1); 162 162 bbox[0] = position; 163 bbox[1] = bbox[0] + int3(384, 384, 0);163 bbox[1] = bbox[0] + vec3i(384, 384, 0); 164 164 165 165 Input::TrackMouse(this); … … 170 170 Entity::TickGame(deltams); 171 171 172 int3buttons = Input::GetMouseButtons();172 vec3i buttons = Input::GetMouseButtons(); 173 173 174 174 /* Do not whip too often, the sound may become annoying */ … … 196 196 if (buttons[0] && !data->oldbuttons[0] && mousepos.x != -1) 197 197 { 198 int2cell = mousepos / data->size;199 if (data->pairs[cell.x][cell.y].piece->Grab( int2(0, 0)))198 vec2i cell = mousepos / data->size; 199 if (data->pairs[cell.x][cell.y].piece->Grab(vec2i(0, 0))) 200 200 { 201 201 Sampler::PlaySample(data->click); 202 202 data->grabbed = data->pairs[cell.x][cell.y]; 203 203 data->src_cell = mousepos / data->size; 204 data->dst_cell = int2(-1);204 data->dst_cell = vec2i(-1); 205 205 data->state = BoardData::HUNT_GRAB; 206 206 } … … 215 215 /* Mouse is still in the window, keep grabbing */ 216 216 data->grabbed.piece->Grab(mousepos - data->oldmouse); 217 int2cur_pos = data->grabbed.piece->GetPos();218 int2cur_cell = (cur_pos + data->size / 2) / data->size;217 vec2i cur_pos = data->grabbed.piece->GetPos(); 218 vec2i cur_cell = (cur_pos + data->size / 2) / data->size; 219 219 if (cur_cell.i < 0 || cur_cell.i >= data->dim.i 220 220 || cur_cell.j < 0 || cur_cell.j >= data->dim.j 221 221 || (cur_pos - cur_cell * data->size).sqlen() > data->size.sqlen() / 8 222 222 || (cur_cell - data->src_cell).sqlen() != 1) 223 cur_cell = int2(-1);223 cur_cell = vec2i(-1); 224 224 /* If potential target changed, update our cache. */ 225 225 if (cur_cell != data->dst_cell) … … 230 230 data->whipdelay = DELAY_WHIP; 231 231 } 232 if (data->dst_cell != int2(-1))232 if (data->dst_cell != vec2i(-1)) 233 233 data->pairs[data->dst_cell.i] 234 234 [data->dst_cell.j].piece->Ungrab(data->dst_cell * data->size); 235 if (cur_cell != int2(-1))235 if (cur_cell != vec2i(-1)) 236 236 data->pairs[cur_cell.i] 237 237 [cur_cell.j].piece->Ungrab(data->src_cell * data->size); … … 245 245 /* Mouse released, or exited window, or dragged too far. */ 246 246 data->grabbed.piece->Ungrab(data->grabbed.piece->GetCell() * data->size); 247 if (data->dst_cell != int2(-1))247 if (data->dst_cell != vec2i(-1)) 248 248 Switch(data->src_cell, data->dst_cell); 249 249 data->state = BoardData::HUNT_IDLE; … … 287 287 if (data->rotation) 288 288 { 289 data->current[0].piece->SetCell( int2(column, 6));290 data->current[1].piece->SetCell( int2(column, 7));289 data->current[0].piece->SetCell(vec2i(column, 6)); 290 data->current[1].piece->SetCell(vec2i(column, 7)); 291 291 } 292 292 else 293 293 { 294 data->current[0].piece->SetCell( int2(column, 7));295 data->current[1].piece->SetCell( int2(column + 1, 7));294 data->current[0].piece->SetCell(vec2i(column, 7)); 295 data->current[1].piece->SetCell(vec2i(column + 1, 7)); 296 296 } 297 297 … … 308 308 if (data->pairs[i][j].id == 0) 309 309 { 310 data->current[t].piece->SetCell( int2(i, j));311 data->current[t].piece->Move( int2(i, j) * data->size);310 data->current[t].piece->SetCell(vec2i(i, j)); 311 data->current[t].piece->Move(vec2i(i, j) * data->size); 312 312 data->pairs[i][j] = data->current[t]; 313 313 data->thumbs->AddCount(data->current[t].id, 1); … … 319 319 data->current[1].id = data->next[1]; 320 320 data->current[0].piece = new Piece(Piece::PIECE_FUSION, 321 data->emitter, int2(3, 7),321 data->emitter, vec2i(3, 7), 322 322 data->current[0].id); 323 323 data->current[1].piece = new Piece(Piece::PIECE_FUSION, 324 data->emitter, int2(4, 7),324 data->emitter, vec2i(4, 7), 325 325 data->current[1].id); 326 326 Ticker::Ref(data->current[0].piece); 327 327 Ticker::Ref(data->current[1].piece); 328 data->current[0].piece->SetPos( int2(3, 8) * data->size);329 data->current[1].piece->SetPos( int2(4, 8) * data->size);328 data->current[0].piece->SetPos(vec2i(3, 8) * data->size); 329 data->current[1].piece->SetPos(vec2i(4, 8) * data->size); 330 330 data->current[0].piece->Move(data->current[0].piece->GetCell() * data->size); 331 331 data->current[1].piece->Move(data->current[1].piece->GetCell() * data->size); … … 382 382 for (int i = 0; i < data->dim.i; i++) 383 383 { 384 int2 newpos = int2(i, j + data->dim.j) * data->size;384 vec2i newpos = vec2i(i, j + data->dim.j) * data->size; 385 385 int id = data->pairs[i][j].id; 386 386 data->pairs[i][j].piece = new Piece(Piece::PIECE_HUNT, 387 data->emitter, int2(i, j), id);387 data->emitter, vec2i(i, j), id); 388 388 data->pairs[i][j].piece->SetPos(newpos); 389 data->pairs[i][j].piece->Move( int2(i, j) * data->size);389 data->pairs[i][j].piece->Move(vec2i(i, j) * data->size); 390 390 if (j) 391 391 data->pairs[i][j].piece->SetBelow(data->pairs[i][j - 1].piece); … … 394 394 } 395 395 396 void Board::Switch( int2 cell_a, int2cell_b)396 void Board::Switch(vec2i cell_a, vec2i cell_b) 397 397 { 398 398 BoardData::Pair a = data->pairs[cell_a.i][cell_a.j]; … … 473 473 int id = 1 + rand() % data->npieces; 474 474 data->pairs[i][j].id = id; 475 data->pairs[i][j].piece = new Piece(Piece::PIECE_HUNT, data->emitter, int2(i, j), id);475 data->pairs[i][j].piece = new Piece(Piece::PIECE_HUNT, data->emitter, vec2i(i, j), id); 476 476 data->pairs[i][j].piece->SetBelow(old->GetBelow()); 477 477 data->pairs[i][j].piece->SetAbove(old->GetAbove()); … … 488 488 { 489 489 data->pairs[i][j2 - 1] = data->pairs[i][j2]; 490 data->pairs[i][j2 - 1].piece->SetCell( int2(i, j2 - 1));491 data->pairs[i][j2 - 1].piece->Move( int2(i, j2 - 1) * data->size);490 data->pairs[i][j2 - 1].piece->SetCell(vec2i(i, j2 - 1)); 491 data->pairs[i][j2 - 1].piece->Move(vec2i(i, j2 - 1) * data->size); 492 492 list[i][j2 - 1] = list[i][j2]; 493 493 } … … 495 495 /* Spawn a new piece above all the others and attach it to 496 496 * the board. */ 497 int2 newpos = int2(i * data->size.x,498 below->GetPos().y + data->size.y);499 int2 newcell = int2(i, data->dim.j - 1);497 vec2i newpos = vec2i(i * data->size.x, 498 below->GetPos().y + data->size.y); 499 vec2i newcell = vec2i(i, data->dim.j - 1); 500 500 int id = 1 + rand() % data->npieces; 501 501 Piece *tmp = new Piece(Piece::PIECE_HUNT, data->emitter, … … 735 735 } 736 736 data->pairs[i][j].piece = new Piece(Piece::PIECE_FUSION, 737 data->emitter, int2(i, j),737 data->emitter, vec2i(i, j), 738 738 data->pairs[i][j].id); 739 739 Ticker::Ref(data->pairs[i][j].piece); 740 data->pairs[i][j].piece->SetPos( int2(i, j) * data->size);740 data->pairs[i][j].piece->SetPos(vec2i(i, j) * data->size); 741 741 data->thumbs->AddCount(data->pairs[i][j].id, 1); 742 742 count[list[i][j]] = 0; … … 755 755 if (data->pairs[i][j2 - 1].id) 756 756 { 757 data->pairs[i][j2 - 1].piece->SetCell( int2(i, j2 - 1));758 data->pairs[i][j2 - 1].piece->Move( int2(i, j2 - 1) * data->size);757 data->pairs[i][j2 - 1].piece->SetCell(vec2i(i, j2 - 1)); 758 data->pairs[i][j2 - 1].piece->Move(vec2i(i, j2 - 1) * data->size); 759 759 } 760 760 list[i][j2 - 1] = list[i][j2]; … … 771 771 int Board::TagNeighbours(int list[MAX_PIECES][MAX_PIECES], int i, int j) 772 772 { 773 int2 const off[] = { int2(-1, 0), int2(1, 0), int2(0, -1), int2(0, 1) };773 vec2i const off[] = { vec2i(-1, 0), vec2i(1, 0), vec2i(0, -1), vec2i(0, 1) }; 774 774 775 775 int count = 1; -
trunk/monsterz/board.h
r423 r664 31 31 game_t; 32 32 33 Board(game_t, int2dim, int minnpieces, int maxnpieces);33 Board(game_t, vec2i dim, int minnpieces, int maxnpieces); 34 34 virtual ~Board(); 35 35 … … 42 42 /* Hunt mode */ 43 43 void Fill(); 44 void Switch( int2 cell_a, int2cell_b);44 void Switch(vec2i cell_a, vec2i cell_b); 45 45 int ListMashes(int list[MAX_WIDTH][MAX_HEIGHT]); 46 46 int ListMoves(int list[MAX_WIDTH][MAX_HEIGHT]); -
trunk/monsterz/interface.cpp
r639 r664 55 55 data->title = NULL; 56 56 data->board = NULL; 57 data->screen = Tiler::Register(PNG_BACKGROUND, int2(640, 480), 0, 1.0f);57 data->screen = Tiler::Register(PNG_BACKGROUND, vec2i(640, 480), 0, 1.0f); 58 58 data->tiles = Tiler::Register(PNG_TILES, 48, 0, 1.0f); 59 59 data->state = InterfaceData::INIT; 60 60 61 position = int3(0, 0, 1);61 position = vec3i(0, 0, 1); 62 62 bbox[0] = position; 63 bbox[1] = bbox[0] + int3(640, 480, 0);63 bbox[1] = bbox[0] + vec3i(640, 480, 0); 64 64 } 65 65 … … 81 81 data->title = NULL; 82 82 if (rand() & 1) 83 data->board = new Board(Board::GAME_FUSION, int2(6, 8), 3, 12);83 data->board = new Board(Board::GAME_FUSION, vec2i(6, 8), 3, 12); 84 84 else 85 data->board = new Board(Board::GAME_HUNT, int2(8, 8), 8, 8);85 data->board = new Board(Board::GAME_HUNT, vec2i(8, 8), 8, 8); 86 86 Ticker::Ref(data->board); 87 87 data->state = InterfaceData::GAME; … … 97 97 WorldEntity::TickDraw(deltams); 98 98 99 int2mouse = Input::GetMousePos();99 vec2i mouse = Input::GetMousePos(); 100 100 101 101 Scene::GetDefault()->AddTile((data->screen << 16) | 0, 0, 0, 10, 0); … … 103 103 if (mouse.x >= 0 && mouse.y >= 0) 104 104 { 105 int2 m = mouse + int2(-6, 6 - 48);105 vec2i m = mouse + vec2i(-6, 6 - 48); 106 106 Scene::GetDefault()->AddTile((data->tiles << 16) | 22, m.x, m.y, 30, 0); 107 107 } -
trunk/monsterz/mash.cpp
r384 r664 33 33 int duh, pop; 34 34 Piece *pieces[MAX_WIDTH * MAX_HEIGHT]; 35 int2cells[MAX_WIDTH * MAX_HEIGHT];35 vec2i cells[MAX_WIDTH * MAX_HEIGHT]; 36 36 int npieces; 37 37 float timer; … … 87 87 { 88 88 /* If piece is still too high, don't start the animation */ 89 int2shift = data->pieces[n]->GetShift();89 vec2i shift = data->pieces[n]->GetShift(); 90 90 if (shift.y > 2 || abs(shift.x) > 2) 91 91 allready = 0; -
trunk/monsterz/piece.cpp
r633 r664 34 34 Emitter *emitter; 35 35 Piece *above, *below; 36 int2size, cell, pos, src, dst;36 vec2i size, cell, pos, src, dst; 37 37 int id; 38 38 float speed, timer, blink, idle; … … 57 57 */ 58 58 59 Piece::Piece(piece_t piece, Emitter *emitter, int2cell, int id)59 Piece::Piece(piece_t piece, Emitter *emitter, vec2i cell, int id) 60 60 : data(new PieceData()) 61 61 { … … 96 96 } 97 97 98 void Piece::SetCell( int2cell)98 void Piece::SetCell(vec2i cell) 99 99 { 100 100 data->cell = cell; 101 101 } 102 102 103 int2Piece::GetCell() const103 vec2i Piece::GetCell() const 104 104 { 105 105 return data->cell; 106 106 } 107 107 108 void Piece::SetPos( int2pos)108 void Piece::SetPos(vec2i pos) 109 109 { 110 110 data->pos = pos; 111 111 } 112 112 113 int2Piece::GetPos() const113 vec2i Piece::GetPos() const 114 114 { 115 115 return data->pos; 116 116 } 117 117 118 int2Piece::GetSize() const118 vec2i Piece::GetSize() const 119 119 { 120 120 return data->size; 121 121 } 122 122 123 int2Piece::GetShift() const123 vec2i Piece::GetShift() const 124 124 { 125 125 return data->pos - data->cell * data->size; … … 197 197 } 198 198 199 int Piece::Grab( int2dir)199 int Piece::Grab(vec2i dir) 200 200 { 201 201 switch (data->state) … … 219 219 } 220 220 221 int Piece::Ungrab( int2pos)221 int Piece::Ungrab(vec2i pos) 222 222 { 223 223 switch (data->state) … … 239 239 } 240 240 241 int Piece::Move( int2pos)241 int Piece::Move(vec2i pos) 242 242 { 243 243 switch (data->state) … … 289 289 { 290 290 data->timer += deltams; 291 int2trip = data->dst - data->src;291 vec2i trip = data->dst - data->src; 292 292 float moving_time = trip.len() / data->speed; 293 293 float t = moving_time ? data->timer / moving_time : 1.0f; … … 315 315 if (data->timer < 0.0f) 316 316 { 317 float3 pos(data->pos.x + 24, data->pos.y + 72, 5);317 vec3 pos(data->pos.x + 24, data->pos.y + 72, 5); 318 318 int start = data->id + 12; 319 319 int stop = data->id + 15; … … 322 322 float angle = RandF(-1.2f, 1.2f); 323 323 float speed = RandF(0.3f, 0.5f); 324 float3 vel(speed * sinf(angle), speed * cosf(angle), 0.0f);324 vec3 vel(speed * sinf(angle), speed * cosf(angle), 0.0f); 325 325 data->emitter->AddParticle(id, pos, vel); 326 326 } -
trunk/monsterz/piece.h
r419 r664 31 31 piece_t; 32 32 33 Piece(piece_t, Emitter *emitter, int2cell, int id);33 Piece(piece_t, Emitter *emitter, vec2i cell, int id); 34 34 virtual ~Piece(); 35 35 36 36 virtual char const *GetName(); 37 37 38 void SetCell( int2cell);39 int2GetCell() const;40 void SetPos( int2pos);41 int2GetPos() const;38 void SetCell(vec2i cell); 39 vec2i GetCell() const; 40 void SetPos(vec2i pos); 41 vec2i GetPos() const; 42 42 43 int2GetSize() const;44 int2GetShift() const;43 vec2i GetSize() const; 44 vec2i GetShift() const; 45 45 46 46 void SetAbove(Piece *below); … … 52 52 53 53 int Pop(); 54 int Grab( int2dir);55 int Ungrab( int2pos);56 int Move( int2pos);54 int Grab(vec2i dir); 55 int Ungrab(vec2i pos); 56 int Move(vec2i pos); 57 57 58 58 protected: -
trunk/monsterz/thumbs.cpp
r639 r664 51 51 52 52 #if 0 53 position = int3(24, 72, 1);53 position = vec3i(24, 72, 1); 54 54 bbox[0] = position; 55 bbox[1] = bbox[0] + int3(384, 384, 0);55 bbox[1] = bbox[0] + vec3i(384, 384, 0); 56 56 #endif 57 57 } … … 71 71 for (int n = 0; n < data->npieces; n++) 72 72 { 73 int2 p = int2(459, 372 - 27 * n);73 vec2i p = vec2i(459, 372 - 27 * n); 74 74 Scene::GetDefault()->AddTile((data->icons << 16) | n, p.x, p.y, 11, 0); 75 75 } … … 86 86 data->text[n] = new Text(NULL, "monsterz/gfx/font1.png"); 87 87 Ticker::Ref(data->text[n]); 88 int3 p = int3(492, 374 - 27 * n, 20);88 vec3i p = vec3i(492, 374 - 27 * n, 20); 89 89 data->text[n]->SetPos(p); 90 90 } -
trunk/monsterz/title.cpp
r633 r664 58 58 period, nextperiod; 59 59 60 float2 cloudpos[5];61 float2 cloudspeed[5];60 vec2 cloudpos[5]; 61 vec2 cloudspeed[5]; 62 62 63 63 int eagley; … … 67 67 }; 68 68 69 static int2const animsize[] =70 { 71 int2(384, 384),72 int2(284, 81),73 int2(38, 146),74 int2(29, 137),75 int2(284, 82),76 int2(384, 384),77 }; 78 79 static int2const animpos[] =80 { 81 int2(0, 0),82 int2(65, 255),83 int2(239, 168),84 int2(248, 168),85 int2(63, 255),86 int2(0, 0),87 }; 88 89 static int2const eventsize[] =90 { 91 int2(143, 16),92 int2(68, 49),93 int2(17, 29),94 int2(50, 80),95 int2(237, 238),96 int2(59, 53),97 int2(140, 15),98 }; 99 100 static int2const eventpos[] =101 { 102 int2(0, 322),103 int2(316, 286),104 int2(246, 245),105 int2(279, 173),106 int2(42, 101),107 int2(231, 154),108 int2(0, 322),69 static vec2i const animsize[] = 70 { 71 vec2i(384, 384), 72 vec2i(284, 81), 73 vec2i(38, 146), 74 vec2i(29, 137), 75 vec2i(284, 82), 76 vec2i(384, 384), 77 }; 78 79 static vec2i const animpos[] = 80 { 81 vec2i(0, 0), 82 vec2i(65, 255), 83 vec2i(239, 168), 84 vec2i(248, 168), 85 vec2i(63, 255), 86 vec2i(0, 0), 87 }; 88 89 static vec2i const eventsize[] = 90 { 91 vec2i(143, 16), 92 vec2i(68, 49), 93 vec2i(17, 29), 94 vec2i(50, 80), 95 vec2i(237, 238), 96 vec2i(59, 53), 97 vec2i(140, 15), 98 }; 99 100 static vec2i const eventpos[] = 101 { 102 vec2i(0, 322), 103 vec2i(316, 286), 104 vec2i(246, 245), 105 vec2i(279, 173), 106 vec2i(42, 101), 107 vec2i(231, 154), 108 vec2i(0, 322), 109 109 }; 110 110 … … 118 118 srand(rand() ^ time(NULL)); 119 119 120 data->logo = Tiler::Register(PNG_LOGO, int2(380, 181), 0, 1.0f);120 data->logo = Tiler::Register(PNG_LOGO, vec2i(380, 181), 0, 1.0f); 121 121 data->title = Tiler::Register(PNG_TITLE, 384, 0, 1.0f); 122 data->stars = Tiler::Register(PNG_STARS, int2(384, 144), 0, 1.0f);123 data->clouds = Tiler::Register(PNG_CLOUDS, int2(160, 32), 0, 1.0f);122 data->stars = Tiler::Register(PNG_STARS, vec2i(384, 144), 0, 1.0f); 123 data->clouds = Tiler::Register(PNG_CLOUDS, vec2i(160, 32), 0, 1.0f); 124 124 data->eagle = Tiler::Register(PNG_EAGLE, 16, 0, 1.0f); 125 125 for (int n = 0; n < 6; n++) … … 137 137 for (int n = 0; n < 5; n++) 138 138 { 139 data->cloudpos[n] = float2(RandF(384), RandF(130, 190));139 data->cloudpos[n] = vec2(RandF(384), RandF(130, 190)); 140 140 data->cloudspeed[n] = RandF(-0.01f, 0.01f); 141 141 } … … 143 143 data->eagley = 140 + rand() % 40; 144 144 145 position = int3(24, 72, 1);145 position = vec3i(24, 72, 1); 146 146 bbox[0] = position; 147 bbox[1] = bbox[0] + int3(384, 384, 0);147 bbox[1] = bbox[0] + vec3i(384, 384, 0); 148 148 149 149 Input::TrackMouse(this); … … 310 310 int tiler = 0; 311 311 int id = 0; 312 int2pos;312 vec2i pos; 313 313 314 314 switch (data->state) -
trunk/src/debugfps.cpp
r646 r664 41 41 { 42 42 data->lines[i] = new Text(NULL, "gfx/font/ascii.png"); 43 data->lines[i]->SetPos( int3(x, y + (i ? 8 : 0) + 16 * i, 0));43 data->lines[i]->SetPos(vec3i(x, y + (i ? 8 : 0) + 16 * i, 0)); 44 44 Ticker::Ref(data->lines[i]); 45 45 } 46 46 #else 47 47 data->lines[0] = new Text(NULL, "gfx/font/ascii.png"); 48 data->lines[0]->SetPos( int3(x, y, 100));48 data->lines[0]->SetPos(vec3i(x, y, 100)); 49 49 Ticker::Ref(data->lines[0]); 50 50 #endif -
trunk/src/emitter.cpp
r298 r664 30 30 private: 31 31 int tiler; 32 float3 gravity;32 vec3 gravity; 33 33 int particles[MAX_PARTICLES]; 34 float3 positions[MAX_PARTICLES];35 float3 velocities[MAX_PARTICLES];34 vec3 positions[MAX_PARTICLES]; 35 vec3 velocities[MAX_PARTICLES]; 36 36 int nparticles; 37 37 }; … … 41 41 */ 42 42 43 Emitter::Emitter(int tiler, float3 gravity)43 Emitter::Emitter(int tiler, vec3 gravity) 44 44 : data(new EmitterData()) 45 45 { … … 78 78 } 79 79 80 void Emitter::AddParticle(int id, float3 pos, float3 vel)80 void Emitter::AddParticle(int id, vec3 pos, vec3 vel) 81 81 { 82 82 if (data->nparticles >= EmitterData::MAX_PARTICLES) -
trunk/src/emitter.h
r294 r664 24 24 { 25 25 public: 26 Emitter(int tiler, float3 gravity);26 Emitter(int tiler, vec3 gravity); 27 27 virtual ~Emitter(); 28 28 29 void AddParticle(int id, float3 pos, float3 vel);29 void AddParticle(int id, vec3 pos, vec3 vel); 30 30 31 31 protected: -
trunk/src/font.cpp
r639 r664 29 29 char *name; 30 30 int tiler; 31 int2size;31 vec2i size; 32 32 }; 33 33 … … 65 65 } 66 66 67 void Font::Print( int3pos, char const *str)67 void Font::Print(vec3i pos, char const *str) 68 68 { 69 69 Scene *scene = Scene::GetDefault(); … … 81 81 } 82 82 83 int2Font::GetSize() const83 vec2i Font::GetSize() const 84 84 { 85 85 return data->size; -
trunk/src/font.h
r639 r664 34 34 public: 35 35 /* New methods */ 36 void Print( int3pos, char const *str);37 int2GetSize() const;36 void Print(vec3i pos, char const *str); 37 vec2i GetSize() const; 38 38 39 39 private: -
trunk/src/input.cpp
r339 r664 38 38 39 39 private: 40 int2mouse;41 int3buttons;40 vec2i mouse; 41 vec3i buttons; 42 42 43 43 static int const MAX_ENTITIES = 100; … … 54 54 */ 55 55 56 float2 Input::GetAxis(int axis)56 vec2 Input::GetAxis(int axis) 57 57 { 58 58 float invsqrt2 = sqrtf(0.5f); 59 float2 f;59 vec2 f; 60 60 61 61 /* Simulate a joystick using the keyboard. This SDL call is free. */ … … 71 71 } 72 72 73 int2Input::GetMousePos()73 vec2i Input::GetMousePos() 74 74 { 75 75 return data->mouse; 76 76 } 77 77 78 int3Input::GetMouseButtons()78 vec3i Input::GetMouseButtons() 79 79 { 80 80 return data->buttons; … … 102 102 } 103 103 104 void Input::SetMousePos( int2coord)104 void Input::SetMousePos(vec2i coord) 105 105 { 106 106 data->mouse = coord; … … 124 124 if (data->entities[n] == best) 125 125 { 126 data->entities[n]->mousepos = ( int2)((int3)coord - best->bbox[0]);126 data->entities[n]->mousepos = (vec2i)((vec3i)coord - best->bbox[0]); 127 127 if (best != data->lastfocus) 128 128 data->entities[n]->pressed = data->buttons; … … 132 132 else 133 133 { 134 data->entities[n]->mousepos = int2(-1);134 data->entities[n]->mousepos = vec2i(-1); 135 135 /* FIXME */ 136 136 data->entities[n]->released = 0; -
trunk/src/input.h
r329 r664 25 25 public: 26 26 /* These methods are general queries */ 27 static float2 GetAxis(int axis);28 static int2GetMousePos();29 static int3GetMouseButtons();27 static vec2 GetAxis(int axis); 28 static vec2i GetMousePos(); 29 static vec3i GetMouseButtons(); 30 30 31 31 /* Entities can subscribe to events */ … … 34 34 35 35 /* These methods are called by the underlying input listeners */ 36 static void SetMousePos( int2coord);36 static void SetMousePos(vec2i coord); 37 37 static void SetMouseButton(int index); 38 38 static void UnsetMouseButton(int index); -
trunk/src/matrix.cpp
r661 r664 28 28 } 29 29 30 static inline float cofact3( float4x4 const &mat, int i, int j)30 static inline float cofact3(mat4 const &mat, int i, int j) 31 31 { 32 32 return det3(mat[(i + 1) & 3][(j + 1) & 3], … … 41 41 } 42 42 43 template<> float float4x4::det() const43 template<> float mat4::det() const 44 44 { 45 45 float ret = 0; … … 49 49 } 50 50 51 template<> float4x4 float4x4::invert() const51 template<> mat4 mat4::invert() const 52 52 { 53 float4x4 ret;53 mat4 ret; 54 54 float d = det(); 55 55 if (d) … … 63 63 } 64 64 65 template<> float4x4 float4x4::ortho(float left, float right, float bottom,66 65 template<> mat4 mat4::ortho(float left, float right, float bottom, 66 float top, float near, float far) 67 67 { 68 68 float invrl = (right != left) ? 1.0f / (right - left) : 0.0f; … … 70 70 float invfn = (far != near) ? 1.0f / (far - near) : 0.0f; 71 71 72 float4x4 ret(0.0f);72 mat4 ret(0.0f); 73 73 ret[0][0] = 2.0f * invrl; 74 74 ret[1][1] = 2.0f * invtb; … … 81 81 } 82 82 83 template<> float4x4 float4x4::frustum(float left, float right, float bottom,84 83 template<> mat4 mat4::frustum(float left, float right, float bottom, 84 float top, float near, float far) 85 85 { 86 86 float invrl = (right != left) ? 1.0f / (right - left) : 0.0f; … … 88 88 float invfn = (far != near) ? 1.0f / (far - near) : 0.0f; 89 89 90 float4x4 ret(0.0f);90 mat4 ret(0.0f); 91 91 ret[0][0] = 2.0f * near * invrl; 92 92 ret[1][1] = 2.0f * near * invtb; … … 99 99 } 100 100 101 template<> float4x4 float4x4::perspective(float theta, float width,102 101 template<> mat4 mat4::perspective(float theta, float width, 102 float height, float near, float far) 103 103 { 104 104 float t1 = tanf(theta / 2.0f); … … 108 108 } 109 109 110 template<> float4x4 float4x4::translate(float x, float y, float z)110 template<> mat4 mat4::translate(float x, float y, float z) 111 111 { 112 float4x4 ret(1.0f);112 mat4 ret(1.0f); 113 113 ret[3][0] = x; 114 114 ret[3][1] = y; … … 117 117 } 118 118 119 template<> float4x4 float4x4::rotate(float theta, float x, float y, float z)119 template<> mat4 mat4::rotate(float theta, float x, float y, float z) 120 120 { 121 121 float st = sinf(theta); … … 132 132 float mtz = (1.0f - ct) * z; 133 133 134 float4x4 ret(1.0f);134 mat4 ret(1.0f); 135 135 136 136 ret[0][0] = x * mtx + ct; -
trunk/src/matrix.h
r663 r664 279 279 typedef Mat4<int> mat4i; 280 280 281 /* Aliases for deprecated stuff */282 typedef Vec2<float> float2;283 typedef Vec2<int> int2;284 typedef Vec3<float> float3;285 typedef Vec3<int> int3;286 typedef Vec4<float> float4;287 typedef Vec4<int> int4;288 typedef Mat4<float> float4x4;289 typedef Mat4<int> int4x4;290 291 281 #endif // __DH_MATRIX_H__ 292 282 -
trunk/src/scene.cpp
r663 r664 39 39 extern Shader *stdshader; 40 40 #endif 41 extern float4x4 projection_matrix, view_matrix, model_matrix;41 extern mat4 projection_matrix, view_matrix, model_matrix; 42 42 43 43 /* … … 137 137 138 138 // XXX: debug stuff 139 model_matrix = float4x4::translate(320.0f, 240.0f, 0.0f);140 model_matrix *= float4x4::rotate(-data->angle, 1.0f, 0.0f, 0.0f);139 model_matrix = mat4::translate(320.0f, 240.0f, 0.0f); 140 model_matrix *= mat4::rotate(-data->angle, 1.0f, 0.0f, 0.0f); 141 141 #if 0 142 142 static float f = 0.0f; 143 143 f += 0.01f; 144 model_matrix *= float4x4::rotate(0.1f * sinf(f), 1.0f, 0.0f, 0.0f);145 model_matrix *= float4x4::rotate(0.3f * cosf(f), 0.0f, 0.0f, 1.0f);146 #endif 147 model_matrix *= float4x4::translate(-320.0f, -240.0f, 0.0f);144 model_matrix *= mat4::rotate(0.1f * sinf(f), 1.0f, 0.0f, 0.0f); 145 model_matrix *= mat4::rotate(0.3f * cosf(f), 0.0f, 0.0f, 1.0f); 146 #endif 147 model_matrix *= mat4::translate(-320.0f, -240.0f, 0.0f); 148 148 // XXX: end of debug stuff 149 149 -
trunk/src/sdlinput.cpp
r294 r664 49 49 50 50 /* Handle mouse input */ 51 int2mouse;51 vec2i mouse; 52 52 if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) 53 53 { -
trunk/src/text.cpp
r326 r664 30 30 int font, align, length; 31 31 char *text; 32 int3pos;32 vec3i pos; 33 33 }; 34 34 … … 43 43 data->text = text ? strdup(text) : NULL; 44 44 data->length = text ? strlen(text) : 0; 45 data->pos = int3(0, 0, 0);45 data->pos = vec3i(0, 0, 0); 46 46 47 47 drawgroup = DRAWGROUP_HUD; … … 66 66 } 67 67 68 void Text::SetPos( int3pos)68 void Text::SetPos(vec3i pos) 69 69 { 70 70 data->pos = pos; … … 83 83 { 84 84 Font *font = Forge::GetFont(data->font); 85 int3delta = 0;85 vec3i delta = 0; 86 86 if (data->align == ALIGN_RIGHT) 87 87 delta.x -= data->length * font->GetSize().x; -
trunk/src/text.h
r326 r664 29 29 void SetText(char const *text); 30 30 void SetInt(int val); 31 void SetPos( int3pos);31 void SetPos(vec3i pos); 32 32 void SetAlign(int align); 33 33 -
trunk/src/tiler.cpp
r658 r664 46 46 */ 47 47 48 int Tiler::Register(char const *path, int2 size, int2count, float dilate)48 int Tiler::Register(char const *path, vec2i size, vec2i count, float dilate) 49 49 { 50 50 int id = data->tilesets.MakeSlot(path); … … 68 68 } 69 69 70 int2Tiler::GetSize(int id)70 vec2i Tiler::GetSize(int id) 71 71 { 72 72 TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id - 1); … … 81 81 } 82 82 83 int2Tiler::GetCount(int id)83 vec2i Tiler::GetCount(int id) 84 84 { 85 85 TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id - 1); -
trunk/src/tiler.h
r645 r664 23 23 { 24 24 public: 25 static int Register(char const *path, int2 size, int2 count, float dilate); 25 static int Register(char const *path, vec2i size, vec2i count, 26 float dilate); 26 27 static void Deregister(int id); 27 28 28 static int2GetSize(int id);29 static int2GetCount(int id);29 static vec2i GetSize(int id); 30 static vec2i GetCount(int id); 30 31 static void Bind(uint32_t code); 31 32 static void BlitTile(uint32_t code, int x, int y, int z, int o, -
trunk/src/tileset.cpp
r658 r664 43 43 char *name, *path; 44 44 int *tiles, ntiles; 45 int2size, count;45 vec2i size, count; 46 46 float dilate, tx, ty; 47 47 … … 54 54 */ 55 55 56 TileSet::TileSet(char const *path, int2 size, int2count, float dilate)56 TileSet::TileSet(char const *path, vec2i size, vec2i count, float dilate) 57 57 : data(new TileSetData()) 58 58 { … … 81 81 { 82 82 data->count = count; 83 data->size = int2(data->img->w, data->img->h) / count;83 data->size = vec2i(data->img->w, data->img->h) / count; 84 84 } 85 85 else … … 158 158 } 159 159 160 int2TileSet::GetSize() const160 vec2i TileSet::GetSize() const 161 161 { 162 162 return data->size; 163 163 } 164 164 165 int2TileSet::GetCount() const165 vec2i TileSet::GetCount() const 166 166 { 167 167 return data->count; -
trunk/src/tileset.h
r645 r664 29 29 { 30 30 public: 31 TileSet(char const *path, int2 size, int2count, float dilate);31 TileSet(char const *path, vec2i size, vec2i count, float dilate); 32 32 virtual ~TileSet(); 33 33 … … 39 39 public: 40 40 /* New methods */ 41 int2GetSize() const;42 int2GetCount() const;41 vec2i GetSize() const; 42 vec2i GetCount() const; 43 43 void Bind(); 44 44 void BlitTile(uint32_t id, int x, int y, int z, int o, -
trunk/src/video.cpp
r662 r664 32 32 Shader *stdshader; 33 33 #endif 34 float4x4 projection_matrix, view_matrix, model_matrix;34 mat4 projection_matrix, view_matrix, model_matrix; 35 35 36 36 #if LOL_EXPERIMENTAL … … 93 93 #undef near /* Fuck Microsoft */ 94 94 #undef far /* Fuck Microsoft again */ 95 float4x4 proj;95 mat4 proj; 96 96 97 97 float width = GetWidth(); … … 104 104 { 105 105 /* The easy way: purely orthogonal projection. */ 106 proj = float4x4::ortho(0, width, 0, height, near, far);106 proj = mat4::ortho(0, width, 0, height, near, far); 107 107 } 108 108 else … … 124 124 } 125 125 126 proj = float4x4::frustum(-near * t1, near * t1,127 128 * float4x4::translate(-0.5f * width, -0.5f * height, -dist);126 proj = mat4::frustum(-near * t1, near * t1, 127 -near * t2, near * t2, near, far) 128 * mat4::translate(-0.5f * width, -0.5f * height, -dist); 129 129 } 130 130 131 131 #if LOL_EXPERIMENTAL 132 132 projection_matrix = proj; 133 view_matrix = float4x4(1.0f);133 view_matrix = mat4(1.0f); 134 134 #else 135 135 glMatrixMode(GL_PROJECTION); -
trunk/src/worldentity.h
r332 r664 22 22 { 23 23 public: 24 float3 position;25 float3 rotation;26 float3 velocity;27 float3 bbox[2];24 vec3 position; 25 vec3 rotation; 26 vec3 velocity; 27 vec3 bbox[2]; 28 28 29 int2mousepos;30 int3mousebuttons;31 int3pressed, clicked, released;29 vec2i mousepos; 30 vec3i mousebuttons; 31 vec3i pressed, clicked, released; 32 32 33 33 protected: -
trunk/test/matrix.cpp
r651 r664 33 33 void setUp() 34 34 { 35 identity = float4x4(1.0f);36 triangular = float4x4(float4(1.0f, 0.0f, 0.0f, 0.0f),37 float4(7.0f, 2.0f, 0.0f, 0.0f),38 float4(1.0f, 5.0f, 3.0f, 0.0f),39 float4(8.0f, 9.0f, 2.0f, 4.0f));40 invertible = float4x4(float4( 1.0f, 1.0f, 2.0f, -1.0f),41 float4(-2.0f, -1.0f, -2.0f, 2.0f),42 float4( 4.0f, 2.0f, 5.0f, -4.0f),43 float4( 5.0f, -3.0f, -7.0f, -6.0f));35 identity = mat4(1.0f); 36 triangular = mat4(vec4(1.0f, 0.0f, 0.0f, 0.0f), 37 vec4(7.0f, 2.0f, 0.0f, 0.0f), 38 vec4(1.0f, 5.0f, 3.0f, 0.0f), 39 vec4(8.0f, 9.0f, 2.0f, 4.0f)); 40 invertible = mat4(vec4( 1.0f, 1.0f, 2.0f, -1.0f), 41 vec4(-2.0f, -1.0f, -2.0f, 2.0f), 42 vec4( 4.0f, 2.0f, 5.0f, -4.0f), 43 vec4( 5.0f, -3.0f, -7.0f, -6.0f)); 44 44 } 45 45 … … 56 56 void test_mat_mul() 57 57 { 58 float4x4 m0 = identity;59 float4x4 m1 = identity;60 float4x4 m2 = m0 * m1;58 mat4 m0 = identity; 59 mat4 m1 = identity; 60 mat4 m2 = m0 * m1; 61 61 62 62 CPPUNIT_ASSERT(m2[0][0] == 1.0f); … … 83 83 void test_mat_inv() 84 84 { 85 float4x4 m0 = invertible;86 float4x4 m1 = m0.invert();85 mat4 m0 = invertible; 86 mat4 m1 = m0.invert(); 87 87 88 float4x4 m2 = m0 * m1;88 mat4 m2 = m0 * m1; 89 89 90 90 CPPUNIT_ASSERT(m2[0][0] == 1.0f); … … 110 110 111 111 private: 112 float4x4 triangular, identity, invertible;112 mat4 triangular, identity, invertible; 113 113 }; 114 114
Note: See TracChangeset
for help on using the changeset viewer.