# All of the sources participating in the build are defined here
-include sources.mk
-include src/sdl/subdir.mk
+-include src/graphics/subdir.mk
-include src/battle/subdir.mk
-include src/app/subdir.mk
-include src/subdir.mk
SUBDIRS := \
src/sdl \
src \
+src/graphics \
src/battle \
src/app \
--- /dev/null
+################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables
+CPP_SRCS += \
+../src/graphics/Sprite.cpp
+
+OBJS += \
+./src/graphics/Sprite.o
+
+CPP_DEPS += \
+./src/graphics/Sprite.d
+
+
+# Each subdirectory must supply rules for building sources it contributes
+src/graphics/%.o: ../src/graphics/%.cpp
+ @echo 'Building file: $<'
+ @echo 'Invoking: GCC C++ Compiler'
+ g++ -I/usr/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
+ @echo 'Finished building: $<'
+ @echo ' '
+
+
# All of the sources participating in the build are defined here
-include sources.mk
-include src/sdl/subdir.mk
+-include src/graphics/subdir.mk
-include src/battle/subdir.mk
-include src/app/subdir.mk
-include src/subdir.mk
SUBDIRS := \
src/sdl \
src \
+src/graphics \
src/battle \
src/app \
--- /dev/null
+################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables
+CPP_SRCS += \
+../src/graphics/Sprite.cpp
+
+OBJS += \
+./src/graphics/Sprite.o
+
+CPP_DEPS += \
+./src/graphics/Sprite.d
+
+
+# Each subdirectory must supply rules for building sources it contributes
+src/graphics/%.o: ../src/graphics/%.cpp
+ @echo 'Building file: $<'
+ @echo 'Invoking: GCC C++ Compiler'
+ g++ -I/usr/include/SDL -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
+ @echo 'Finished building: $<'
+ @echo ' '
+
+
#include <SDL.h>
+namespace graphics { class Sprite; }
+
namespace battle {
class Monster {
public:
const char *Name() const { return name; }
Uint8 Level() const { return level; }
- const /* Sprite */ void *Sprite() const { return sprite; }
+ const graphics::Sprite *Sprite() const { return sprite; }
Uint16 MaxHealth() const { return maxHealth; }
Uint16 Health() const { return health; }
private:
const char *name;
- /* Sprite */ void *sprite;
+ graphics::Sprite *sprite;
/* Item */ void *dropItem;
/* Script */ void *attackScript;
/* Script */ void *defenseScript;
--- /dev/null
+/*
+ * Sprite.cpp
+ *
+ * Created on: Aug 5, 2012
+ * Author: holy
+ */
+
+#include "Sprite.h"
+
+namespace graphics {
+
+void Sprite::Draw(SDL_Surface *dest, int x, int y, int col, int row) const {
+ SDL_Rect srcRect, destRect;
+ srcRect.x = col * Width();
+ srcRect.y = row * Height();
+ srcRect.w = Width();
+ srcRect.h = Height();
+ destRect.x = x;
+ destRect.y = y;
+ destRect.w = Width();
+ destRect.h = Height();
+ SDL_BlitSurface(surface, &srcRect, dest, &destRect);
+}
+
+}
--- /dev/null
+/*
+ * Sprite.h
+ *
+ * Created on: Aug 5, 2012
+ * Author: holy
+ */
+
+#ifndef GRAPHICS_SPRITE_H_
+#define GRAPHICS_SPRITE_H_
+
+#include <SDL.h>
+
+namespace graphics {
+
+class Sprite {
+
+public:
+ Sprite(SDL_Surface *s, int width, int height)
+ : surface(s), width(width), height(height) { }
+
+public:
+ int Width() const { return width; }
+ int Height() const { return height; }
+ void Draw(SDL_Surface *dest, int x, int y, int col = 0, int row = 0) const;
+
+private:
+ SDL_Surface *surface;
+ int width;
+ int height;
+
+};
+
+}
+
+#endif /* GRAPHICS_SPRITE_H_ */