summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/graphic/graphic.cpp5
-rw-r--r--src/graphic/image.cpp21
-rw-r--r--src/graphic/image.h5
-rw-r--r--src/main.h1
4 files changed, 29 insertions, 3 deletions
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp
index e05842d6..40a00aa4 100644
--- a/src/graphic/graphic.cpp
+++ b/src/graphic/graphic.cpp
@@ -204,10 +204,13 @@ GraphicEngine::GraphicEngine() {
emotionset = new Spriteset("./data/graphic/emotionset.dat");
hairset = new Spriteset("./data/graphic/hairset.dat");
- monsterset = new Spriteset("./data/graphic/monsterset.dat");
npcset = new Spriteset("./data/graphic/npcset.dat");
playerset = new Spriteset("./data/graphic/playerset.dat");
tileset = new Spriteset("./data/graphic/tileset.dat");
+
+ BITMAP *monsterbitmap = load_bitmap("data/graphic/monsterset.bmp", NULL);
+ if (!monsterbitmap) error("Unable to load monsterset.bmp");
+ monsterset = new Spriteset(monsterbitmap, 60, 60);
}
GraphicEngine::~GraphicEngine() {
diff --git a/src/graphic/image.cpp b/src/graphic/image.cpp
index da9bb1d5..c5e28bfb 100644
--- a/src/graphic/image.cpp
+++ b/src/graphic/image.cpp
@@ -104,9 +104,28 @@ Spriteset::Spriteset(std::string filename)
}
}
+Spriteset::Spriteset(BITMAP *bmp, int width, int height)
+{
+ /*
+ * We're creating sub bitmaps here for plain convenience. With SDL this'll
+ * probably need to be done different.
+ */
+ int x, y;
+
+ for (y = 0; y + height <= bmp->h; y += height)
+ {
+ for (x = 0; x + width <= bmp->w; x += width)
+ {
+ spriteset.push_back(new VideoImage(
+ create_sub_bitmap(bmp, x, y, width, height),
+ 30, 40));
+ }
+ }
+}
+
Spriteset::~Spriteset()
{
- for (int i = 0; i < spriteset.size(); i++) {
+ for (unsigned int i = 0; i < spriteset.size(); i++) {
delete spriteset[i];
}
}
diff --git a/src/graphic/image.h b/src/graphic/image.h
index 2491b5ad..41d94a2d 100644
--- a/src/graphic/image.h
+++ b/src/graphic/image.h
@@ -127,6 +127,11 @@ class Spriteset {
*/
Spriteset(std::string filename);
+ /*
+ * Cuts the passed bitmap in a grid of sub bitmaps.
+ */
+ Spriteset::Spriteset(BITMAP *bmp, int width, int height);
+
/**
* Destructor
*/
diff --git a/src/main.h b/src/main.h
index d46953ba..59d3377d 100644
--- a/src/main.h
+++ b/src/main.h
@@ -85,7 +85,6 @@ typedef struct {
} PLAYER_INFO;
extern BITMAP *playerset, *login_wallpaper;
-extern DATAFILE *emotions;
extern char username[25];
extern char password[25];
extern int map_address, char_ID;