]> git.localhorst.tv Git - l2e.git/commitdiff
added Point class
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 5 Aug 2012 15:45:49 +0000 (17:45 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 5 Aug 2012 15:45:49 +0000 (17:45 +0200)
Debug/makefile
Debug/sources.mk
Debug/src/geometry/subdir.mk [new file with mode: 0644]
Release/makefile
Release/sources.mk
Release/src/geometry/subdir.mk [new file with mode: 0644]
src/geometry/Point.cpp [new file with mode: 0644]
src/geometry/Point.h [new file with mode: 0644]
src/graphics/Sprite.cpp
src/graphics/Sprite.h

index 507437a93cbfa29ba2e0136e4c244d637cf0e2b3..48bc75f7d9901d9207bba013f501cc9056091d19 100644 (file)
@@ -10,6 +10,7 @@ RM := rm -rf
 -include sources.mk
 -include src/sdl/subdir.mk
 -include src/graphics/subdir.mk
+-include src/geometry/subdir.mk
 -include src/battle/subdir.mk
 -include src/app/subdir.mk
 -include src/subdir.mk
index 0fdadd38f9a63f83ae891efcde4019c97aab7708..41a8dd362c1382ebbf2404fa292ceed6c378947e 100644 (file)
@@ -26,6 +26,7 @@ SUBDIRS := \
 src/sdl \
 src \
 src/graphics \
+src/geometry \
 src/battle \
 src/app \
 
diff --git a/Debug/src/geometry/subdir.mk b/Debug/src/geometry/subdir.mk
new file mode 100644 (file)
index 0000000..3173086
--- /dev/null
@@ -0,0 +1,24 @@
+################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables 
+CPP_SRCS += \
+../src/geometry/Point.cpp 
+
+OBJS += \
+./src/geometry/Point.o 
+
+CPP_DEPS += \
+./src/geometry/Point.d 
+
+
+# Each subdirectory must supply rules for building sources it contributes
+src/geometry/%.o: ../src/geometry/%.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 ' '
+
+
index 507437a93cbfa29ba2e0136e4c244d637cf0e2b3..48bc75f7d9901d9207bba013f501cc9056091d19 100644 (file)
@@ -10,6 +10,7 @@ RM := rm -rf
 -include sources.mk
 -include src/sdl/subdir.mk
 -include src/graphics/subdir.mk
+-include src/geometry/subdir.mk
 -include src/battle/subdir.mk
 -include src/app/subdir.mk
 -include src/subdir.mk
index 0fdadd38f9a63f83ae891efcde4019c97aab7708..41a8dd362c1382ebbf2404fa292ceed6c378947e 100644 (file)
@@ -26,6 +26,7 @@ SUBDIRS := \
 src/sdl \
 src \
 src/graphics \
+src/geometry \
 src/battle \
 src/app \
 
diff --git a/Release/src/geometry/subdir.mk b/Release/src/geometry/subdir.mk
new file mode 100644 (file)
index 0000000..3ddc804
--- /dev/null
@@ -0,0 +1,24 @@
+################################################################################
+# Automatically-generated file. Do not edit!
+################################################################################
+
+# Add inputs and outputs from these tool invocations to the build variables 
+CPP_SRCS += \
+../src/geometry/Point.cpp 
+
+OBJS += \
+./src/geometry/Point.o 
+
+CPP_DEPS += \
+./src/geometry/Point.d 
+
+
+# Each subdirectory must supply rules for building sources it contributes
+src/geometry/%.o: ../src/geometry/%.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 ' '
+
+
diff --git a/src/geometry/Point.cpp b/src/geometry/Point.cpp
new file mode 100644 (file)
index 0000000..a3bb3a2
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * Point.cpp
+ *
+ *  Created on: Aug 5, 2012
+ *      Author: holy
+ */
+
+#include "Point.h"
+
+namespace geometry {
+
+} /* namespace geometry */
diff --git a/src/geometry/Point.h b/src/geometry/Point.h
new file mode 100644 (file)
index 0000000..9d4bd85
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Point.h
+ *
+ *  Created on: Aug 5, 2012
+ *      Author: holy
+ */
+
+#ifndef GEOMETRY_POINT_H_
+#define GEOMETRY_POINT_H_
+
+namespace geometry {
+
+template<class T>
+class Point {
+
+public:
+       Point() : x(0), y(0) { }
+       Point(T x, T y) : x(x), y(y) { }
+
+public:
+       T X() const { return x; }
+       T Y() const { return y; }
+
+private:
+       T x, y;
+
+};
+
+}
+
+#endif /* GEOMETRY_POINT_H_ */
index 67deeefbbfb67edb69435069b5485636bc2295f3..afd6209546c3a6bdcb8f359f43e89dd8c75ec8c5 100644 (file)
@@ -7,16 +7,18 @@
 
 #include "Sprite.h"
 
+using geometry::Point;
+
 namespace graphics {
 
-void Sprite::Draw(SDL_Surface *dest, int x, int y, int col, int row) const {
+void Sprite::Draw(SDL_Surface *dest, Point<int> position, 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.x = position.X();
+       destRect.y = position.Y();
        destRect.w = Width();
        destRect.h = Height();
        SDL_BlitSurface(surface, &srcRect, dest, &destRect);
index 5710ee58639b3eebf439dd975794968c03e39620..c81ed01984c7e1d00bd9866212808df4be34ffaa 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef GRAPHICS_SPRITE_H_
 #define GRAPHICS_SPRITE_H_
 
+#include "../geometry/Point.h"
+
 #include <SDL.h>
 
 namespace graphics {
@@ -21,7 +23,7 @@ public:
 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;
+       void Draw(SDL_Surface *dest, geometry::Point<int> position, int col = 0, int row = 0) const;
 
 private:
        SDL_Surface *surface;