Changeset 294
- Timestamp:
- Jan 26, 2011, 3:49:51 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/deushax/debugsprite.cpp
r289 r294 48 48 Entity::TickGame(deltams); 49 49 50 Float2 axis = Input::GetAxis(0);50 float2 axis = Input::GetAxis(0); 51 51 data->x += 0.1f * sqrtf(2.0f) * deltams * axis.x; 52 52 data->y += 0.1f * deltams * axis.y; -
trunk/monsterz/board.cpp
r293 r294 40 40 Mash *mashes; 41 41 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; 46 46 float nextblink, whipdelay; 47 47 … … 70 70 data->whip = Sampler::Register(WAV_WHIP); 71 71 72 data->emitter = new Emitter(data->tiles, Float3(0, -0.0003, 0));72 data->emitter = new Emitter(data->tiles, float3(0, -0.0003, 0)); 73 73 Ticker::Ref(data->emitter); 74 74 … … 80 80 { 81 81 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); 83 83 if (j) 84 84 data->pieces[i][j]->SetBelow(data->pieces[i][j - 1]); … … 112 112 { 113 113 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); 116 116 data->emitter->AddParticle(id, pos, vel); 117 117 } 118 118 119 Int2 mouse = Input::GetMousePos();120 Int3 buttons = Input::GetMouseButtons();119 int2 mouse = Input::GetMousePos(); 120 int3 buttons = Input::GetMouseButtons(); 121 121 122 122 /* If possible, make a random monster blink */ … … 152 152 if (x >= 0 && x < 8 * 48 && y >= 0 && y < 8 * 48) 153 153 { 154 if (data->pieces[x / 48][y / 48]->Grab( Int2(0, 0)))154 if (data->pieces[x / 48][y / 48]->Grab(int2(0, 0))) 155 155 { 156 156 Sampler::PlaySample(data->click); 157 157 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); 160 160 data->state = BoardData::GRAB; 161 161 } … … 172 172 /* Mouse is still in the window, keep grabbing */ 173 173 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; 176 176 if (cur_cell.i < 0 || cur_cell.i >= 8 177 177 || cur_cell.j < 0 || cur_cell.j >= 8 178 178 || (cur_pos - cur_cell * 48).sqlen() > 24 * 24 179 179 || (cur_cell - data->src_cell).sqlen() != 1) 180 cur_cell = Int2(-1);180 cur_cell = int2(-1); 181 181 /* If potential target changed, update our cache. */ 182 182 if (cur_cell != data->dst_cell) … … 187 187 data->whipdelay = DELAY_WHIP; 188 188 } 189 if (data->dst_cell != Int2(-1))189 if (data->dst_cell != int2(-1)) 190 190 data->pieces[data->dst_cell.i] 191 191 [data->dst_cell.j]->Ungrab(data->dst_cell * 48); 192 if (cur_cell != Int2(-1))192 if (cur_cell != int2(-1)) 193 193 data->pieces[cur_cell.i] 194 194 [cur_cell.j]->Ungrab(data->src_cell * 48); … … 202 202 /* Mouse released, or exited window, or dragged too far. */ 203 203 data->grabbed->Ungrab(data->grabbed->GetCell() * 48); 204 if (data->dst_cell != Int2(-1))204 if (data->dst_cell != int2(-1)) 205 205 Switch(data->src_cell, data->dst_cell); 206 206 data->state = BoardData::IDLE; … … 232 232 } 233 233 234 void Board::Switch( Int2 cell_a, Int2 cell_b)234 void Board::Switch(int2 cell_a, int2 cell_b) 235 235 { 236 236 Piece *a = data->pieces[cell_a.i][cell_a.j]; … … 310 310 { 311 311 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); 314 314 list[i][j2 - 1] = list[i][j2]; 315 315 } … … 317 317 /* Spawn a new piece above all the others and attach it to 318 318 * the board. */ 319 Int2 newpos = Int2(i * 48, below->GetPos().y + 48);319 int2 newpos = int2(i * 48, below->GetPos().y + 48); 320 320 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); 322 322 data->pieces[i][7]->SetBelow(below); 323 323 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); 325 325 Ticker::Ref(data->pieces[i][7]); 326 326 list[i][7] = 0; -
trunk/monsterz/board.h
r258 r294 27 27 virtual void TickDraw(float deltams); 28 28 29 void Switch( Int2 cell_a, Int2 cell_b);29 void Switch(int2 cell_a, int2 cell_b); 30 30 int ListMashes(int list[8][8]); 31 31 -
trunk/monsterz/mash.cpp
r287 r294 33 33 int duh, pop; 34 34 Piece *pieces[8 * 8]; 35 Int2 cells[8 * 8];35 int2 cells[8 * 8]; 36 36 int npieces; 37 37 float timer; … … 86 86 for (int n = 0; n < data->npieces && allready; n++) 87 87 { 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(); 90 90 91 91 /* If piece is still too high, don't start the animation */ -
trunk/monsterz/piece.cpp
r289 r294 32 32 Piece *above, *below; 33 33 int tiler; 34 Int2 cell, pos, src, dst;34 int2 cell, pos, src, dst; 35 35 int id; 36 36 float speed, timer; … … 53 53 */ 54 54 55 Piece::Piece(Game *game, Int2 cell, int id)55 Piece::Piece(Game *game, int2 cell, int id) 56 56 : data(new PieceData()) 57 57 { … … 67 67 } 68 68 69 void Piece::SetCell( Int2 cell)69 void Piece::SetCell(int2 cell) 70 70 { 71 71 data->cell = cell; 72 72 } 73 73 74 Int2 Piece::GetCell() const74 int2 Piece::GetCell() const 75 75 { 76 76 return data->cell; 77 77 } 78 78 79 void Piece::SetPos( Int2 pos)79 void Piece::SetPos(int2 pos) 80 80 { 81 81 data->pos = pos; 82 82 } 83 83 84 Int2 Piece::GetPos() const84 int2 Piece::GetPos() const 85 85 { 86 86 return data->pos; … … 176 176 } 177 177 178 int Piece::Grab( Int2 dir)178 int Piece::Grab(int2 dir) 179 179 { 180 180 switch (data->state) … … 197 197 } 198 198 199 int Piece::Ungrab( Int2 pos)199 int Piece::Ungrab(int2 pos) 200 200 { 201 201 switch (data->state) … … 217 217 } 218 218 219 int Piece::Move( Int2 pos)219 int Piece::Move(int2 pos) 220 220 { 221 221 switch (data->state) … … 254 254 { 255 255 data->timer += deltams; 256 Int2 trip = data->dst - data->src;256 int2 trip = data->dst - data->src; 257 257 float moving_time = trip.len() / data->speed; 258 258 float t = moving_time ? data->timer / moving_time : 1.0f; -
trunk/monsterz/piece.h
r276 r294 20 20 { 21 21 public: 22 Piece(Game *game, Int2 cell, int id);22 Piece(Game *game, int2 cell, int id); 23 23 virtual ~Piece(); 24 24 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; 29 29 int GetId() const; 30 30 … … 38 38 int Blink(); 39 39 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); 43 43 44 44 protected: -
trunk/src/debugfps.cpp
r282 r294 40 40 { 41 41 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)); 43 43 Ticker::Ref(data->lines[i]); 44 44 } -
trunk/src/emitter.cpp
r290 r294 28 28 private: 29 29 int tiler; 30 Float3 gravity;30 float3 gravity; 31 31 int particles[100]; 32 Float3 positions[100];33 Float3 velocities[100];32 float3 positions[100]; 33 float3 velocities[100]; 34 34 int nparticles; 35 35 }; … … 39 39 */ 40 40 41 Emitter::Emitter(int tiler, Float3 gravity)41 Emitter::Emitter(int tiler, float3 gravity) 42 42 : data(new EmitterData()) 43 43 { … … 76 76 } 77 77 78 void Emitter::AddParticle(int id, Float3 pos, Float3 vel)78 void Emitter::AddParticle(int id, float3 pos, float3 vel) 79 79 { 80 80 if (data->nparticles >= 100) -
trunk/src/emitter.h
r290 r294 24 24 { 25 25 public: 26 Emitter(int tiler, Float3 gravity);26 Emitter(int tiler, float3 gravity); 27 27 virtual ~Emitter(); 28 28 29 void AddParticle(int id, Float3 pos, Float3 vel);29 void AddParticle(int id, float3 pos, float3 vel); 30 30 31 31 protected: -
trunk/src/input.cpp
r236 r294 35 35 { } 36 36 37 Int2 mouse;38 Int3 buttons;37 int2 mouse; 38 int3 buttons; 39 39 } 40 40 inputdata; … … 46 46 */ 47 47 48 Float2 Input::GetAxis(int axis)48 float2 Input::GetAxis(int axis) 49 49 { 50 50 float invsqrt2 = sqrtf(0.5f); 51 Float2 f;51 float2 f; 52 52 53 53 /* Simulate a joystick using the keyboard. This SDL call is free. */ … … 66 66 } 67 67 68 void Input::SetMousePos( Int2 coord)68 void Input::SetMousePos(int2 coord) 69 69 { 70 70 data->mouse = coord; 71 71 } 72 72 73 Int2 Input::GetMousePos()73 int2 Input::GetMousePos() 74 74 { 75 75 return data->mouse; … … 86 86 } 87 87 88 Int3 Input::GetMouseButtons()88 int3 Input::GetMouseButtons() 89 89 { 90 90 return data->buttons; -
trunk/src/input.h
r236 r294 22 22 { 23 23 public: 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(); 27 27 static void SetMouseButton(int index); 28 28 static void UnsetMouseButton(int index); 29 static Int3 GetMouseButtons();29 static int3 GetMouseButtons(); 30 30 }; 31 31 -
trunk/src/matrix.h
r293 r294 98 98 }; 99 99 100 typedef Vec2<float> Float2;101 typedef Vec2<int> Int2;100 typedef Vec2<float> float2; 101 typedef Vec2<int> int2; 102 102 103 103 template <typename T> struct Vec3 … … 114 114 }; 115 115 116 typedef Vec3<float> Float3; 117 typedef Vec3<int> Int3; 116 typedef Vec3<float> float3; 117 typedef Vec3<int> int3; 118 119 template <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 133 typedef Vec4<float> float4; 134 typedef Vec4<int> int4; 118 135 119 136 #define SCALAR_GLOBAL(elems, op, U) \ … … 140 157 GLOBALS(2) 141 158 GLOBALS(3) 159 GLOBALS(4) 142 160 143 161 #endif // __DH_MATRIX_H__ -
trunk/src/sdlinput.cpp
r259 r294 49 49 50 50 /* Handle mouse input */ 51 Int2 mouse;51 int2 mouse; 52 52 if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) 53 53 { -
trunk/src/text.cpp
r282 r294 30 30 int font; 31 31 char *text; 32 Int3 pos;32 int3 pos; 33 33 }; 34 34 … … 42 42 data->font = Forge::Register(font); 43 43 data->text = text ? strdup(text) : NULL; 44 data->pos = Int3(0, 0, 0);44 data->pos = int3(0, 0, 0); 45 45 46 46 drawgroup = DRAWGROUP_HUD; … … 54 54 } 55 55 56 void Text::SetPos( Int3 pos)56 void Text::SetPos(int3 pos) 57 57 { 58 58 data->pos = pos; -
trunk/src/text.h
r282 r294 28 28 29 29 void SetText(char const *text); 30 void SetPos( Int3 pos);30 void SetPos(int3 pos); 31 31 32 32 protected:
Note: See TracChangeset
for help on using the changeset viewer.