Changeset 222
- Timestamp:
- Jan 18, 2011, 2:04:03 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/deushax/debugsprite.cpp
r221 r222 37 37 data->game = game; 38 38 Ticker::Ref(game); 39 data->tiler = Tiler::Register("art/test/character-dress.png", 32, 32); 39 data->tiler = Tiler::Register("art/test/character-dress.png", 40 32, 32, sqrtf(2)); 40 41 data->x = 320; 41 42 data->y = 206; -
trunk/deushax/game.cpp
r221 r222 70 70 { 71 71 if (!data->scene) 72 data->scene = new Scene( );72 data->scene = new Scene(45.0f); 73 73 return data->scene; 74 74 } -
trunk/deushax/mapviewer.cpp
r220 r222 70 70 { 71 71 if (!data->scene) 72 data->scene = new Scene( );72 data->scene = new Scene(45.0f); 73 73 return data->scene; 74 74 } -
trunk/monsterz/debugboard.cpp
r221 r222 41 41 data->game = game; 42 42 Ticker::Ref(game); 43 data->background = Tiler::Register("monsterz/background.png", 640, 480 );44 data->board = Tiler::Register("monsterz/board.png", 384, 384 );45 data->tiler = Tiler::Register("monsterz/tiles.png", 48, 48 );43 data->background = Tiler::Register("monsterz/background.png", 640, 480, 1.0f); 44 data->board = Tiler::Register("monsterz/board.png", 384, 384, 1.0f); 45 data->tiler = Tiler::Register("monsterz/tiles.png", 48, 48, 1.0f); 46 46 } 47 47 … … 55 55 Entity::TickDraw(deltams); 56 56 57 data->game->GetScene()->AddTile((data->background << 16) | 0, 0, 980, 0, 0);58 data->game->GetScene()->AddTile((data->board << 16) | 0, 24, 841, 1, 0);57 data->game->GetScene()->AddTile((data->background << 16) | 0, 0, 1050, 0, 0); 58 data->game->GetScene()->AddTile((data->board << 16) | 0, 24, 912, 1, 0); 59 59 60 60 for (int j = 0; j < 8; j++) … … 64 64 id += (id % 5) / 4; 65 65 data->game->GetScene()->AddTile((data->tiler << 16) | id, 66 i * 48 + 24, j * 48 + 1 07, 0, 1);66 i * 48 + 24, j * 48 + 177, 2, 0); 67 67 } 68 68 } -
trunk/monsterz/game.cpp
r221 r222 71 71 { 72 72 if (!data->scene) 73 data->scene = new Scene( );73 data->scene = new Scene(0.0f); 74 74 return data->scene; 75 75 } -
trunk/src/map.cpp
r221 r222 16 16 #include <cstring> 17 17 #include <cstdlib> 18 #include <cmath> 18 19 #include <ctype.h> 19 20 … … 127 128 { 128 129 /* This is a tileset image file. Associate it with firstgid. */ 129 data->tilers[data->ntilers] = Tiler::Register(str, 32, 32); 130 data->tilers[data->ntilers] = Tiler::Register(str, 32, 32, 131 sqrtf(2)); 130 132 data->ntilers++; 131 133 //fprintf(stderr, "new tiler %s\n", str); -
trunk/src/scene.cpp
r221 r222 54 54 Tile *tiles; 55 55 int ntiles; 56 float angle; 56 57 }; 57 58 … … 60 61 */ 61 62 62 Scene::Scene( )63 Scene::Scene(float angle) 63 64 { 64 65 data = new SceneData(); 65 66 data->tiles = 0; 66 67 data->ntiles = 0; 68 data->angle = angle; 67 69 } 68 70 … … 105 107 f += 0.05f; 106 108 glTranslatef(320.0f, 240.0f, 0.0f); 107 glRotatef(- 45.0f, 1.0f, 0.0f, 0.0f);109 glRotatef(-data->angle, 1.0f, 0.0f, 0.0f); 108 110 #if 0 109 111 glRotatef(3.0f * sinf(f), 1.0f, 0.0f, 0.0f); -
trunk/src/scene.h
r221 r222 24 24 { 25 25 public: 26 Scene( );26 Scene(float angle); 27 27 ~Scene(); 28 28 -
trunk/src/tiler.cpp
r221 r222 34 34 */ 35 35 36 int Tiler::Register(char const *path, int w, int h )36 int Tiler::Register(char const *path, int w, int h, float dilate) 37 37 { 38 38 int id = data->tilesets.MakeSlot(path); … … 40 40 if (!data->tilesets.GetEntity(id)) 41 41 { 42 TileSet *tileset = new TileSet(path, w, h );42 TileSet *tileset = new TileSet(path, w, h, dilate); 43 43 data->tilesets.SetEntity(id, tileset); 44 44 } -
trunk/src/tiler.h
r221 r222 23 23 { 24 24 public: 25 static int Register(char const *path, int w, int h );25 static int Register(char const *path, int w, int h, float dilate); 26 26 static void Deregister(int id); 27 27 -
trunk/src/tileset.cpp
r221 r222 44 44 int *tiles; 45 45 int w, h, nw, nh, ntiles; 46 float tx, ty;46 float dilate, tx, ty; 47 47 48 48 SDL_Surface *img; … … 54 54 */ 55 55 56 TileSet::TileSet(char const *path, int w, int h )56 TileSet::TileSet(char const *path, int w, int h, float dilate) 57 57 { 58 58 data = new TileSetData(); … … 79 79 data->w = w; 80 80 data->h = h; 81 data->dilate = dilate; 81 82 /* FIXME: check for non-zero here */ 82 83 data->nw = data->img->w / w; … … 135 136 float tx = data->tx * ((id & 0xffff) % data->nw); 136 137 float ty = data->ty * ((id & 0xffff) / data->nw); 138 float dilate = data->dilate; 137 139 138 float sqrt2 = sqrtf(2.0f);139 140 int off = o ? data->h : 0; 140 141 int dx = data->w; … … 147 148 glBegin(GL_QUADS); 148 149 glTexCoord2f(tx, ty); 149 glVertex3f(x, sqrt2 * (y - dy - off), sqrt2* (z + off));150 glVertex3f(x, dilate * (y - dy - off), dilate * (z + off)); 150 151 glTexCoord2f(tx + data->tx, ty); 151 glVertex3f(x + dx, sqrt2 * (y - dy - off), sqrt2* (z + off));152 glVertex3f(x + dx, dilate * (y - dy - off), dilate * (z + off)); 152 153 glTexCoord2f(tx + data->tx, ty + data->ty); 153 glVertex3f(x + dx, sqrt2 * (y - dy2), sqrt2* z);154 glVertex3f(x + dx, dilate * (y - dy2), dilate * z); 154 155 glTexCoord2f(tx, ty + data->ty); 155 glVertex3f(x, sqrt2 * (y - dy2), sqrt2* z);156 glVertex3f(x, dilate * (y - dy2), dilate * z); 156 157 glEnd(); 157 158 } -
trunk/src/tileset.h
r221 r222 29 29 { 30 30 public: 31 TileSet(char const *path, int w, int h );31 TileSet(char const *path, int w, int h, float dilate); 32 32 virtual ~TileSet(); 33 33
Note: See TracChangeset
for help on using the changeset viewer.