The basic server map is being displayed in the client
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#config
|
||||
INCLUDES+=. ..
|
||||
INCLUDES+=. .. ../map
|
||||
LIBS+=
|
||||
CXXFLAGS+=-std=c++11 -DDEBUG $(addprefix -I,$(INCLUDES))
|
||||
CFLAGS+=-DDEBUG $(addprefix -I,$(INCLUDES))
|
||||
|
||||
@@ -34,8 +34,28 @@ void TileSheet::Unload() {
|
||||
XCount = YCount = 0;
|
||||
}
|
||||
|
||||
void TileSheet::DrawTo(SDL_Surface* const dest, int x, int y, int tile) {
|
||||
image.SetClipX(tile % XCount * image.GetClipW());
|
||||
image.SetClipY(tile / XCount * image.GetClipH());
|
||||
void TileSheet::DrawTo(SDL_Surface* const dest, int x, int y, Region::type_t tile) {
|
||||
//0 is invisible
|
||||
if (tile == 0) return;
|
||||
image.SetClipX((tile-1) % XCount * image.GetClipW());
|
||||
image.SetClipY((tile-1) / XCount * image.GetClipH());
|
||||
image.DrawTo(dest, x, y);
|
||||
}
|
||||
|
||||
void TileSheet::DrawRegionTo(SDL_Surface* const dest, Region* const region, int camX, int camY) {
|
||||
Region::type_t tile = 0;
|
||||
for (register int i = 0; i < region->GetWidth(); ++i) {
|
||||
for (register int j = 0; j < region->GetHeight(); ++j) {
|
||||
for (register int k = 0; k < region->GetDepth(); ++k) {
|
||||
tile = region->GetTile(i, j, k);
|
||||
//0 is invisible
|
||||
if (tile == 0) continue;
|
||||
image.SetClipX((tile-1) % XCount * image.GetClipW());
|
||||
image.SetClipY((tile-1) / XCount * image.GetClipH());
|
||||
image.DrawTo(dest,
|
||||
region->GetX() + i * image.GetClipW() - camX,
|
||||
region->GetY() + j * image.GetClipH() - camY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,8 @@
|
||||
#ifndef TILESHEET_HPP_
|
||||
#define TILESHEET_HPP_
|
||||
|
||||
#include "region.hpp"
|
||||
|
||||
#include "image.hpp"
|
||||
|
||||
#include <string>
|
||||
@@ -35,7 +37,8 @@ public:
|
||||
void Load(std::string fname, int XCount, int YCount);
|
||||
void Unload();
|
||||
|
||||
void DrawTo(SDL_Surface* const dest, int x, int y, int tile);
|
||||
void DrawTo(SDL_Surface* const dest, int x, int y, Region::type_t tile);
|
||||
void DrawRegionTo(SDL_Surface* const dest, Region* const region, int camX, int camY);
|
||||
|
||||
//accessors
|
||||
Image* GetImage() { return ℑ }
|
||||
|
||||
Reference in New Issue
Block a user