Просмотр исходного кода

Added example of predefined colors.

Florian DORMONT лет назад: 10
Родитель
Сommit
0b52181da9
3 измененных файлов с 16 добавлено и 2 удалено
  1. 8 1
      include/Pixel.h
  2. 7 0
      src/Pixel.cpp
  3. 1 1
      src/main.cpp

+ 8 - 1
include/Pixel.h

@@ -18,7 +18,7 @@ namespace WalrusRPG { namespace Graphics {
   			unsigned b : 5;
   		};
     };
-    
+
     public:
 		Pixel(std::uint16_t color);
 
@@ -33,6 +33,13 @@ namespace WalrusRPG { namespace Graphics {
 
 	};
 
+  extern const Pixel Black;
+  extern const Pixel White;
+  extern const Pixel Red;
+  extern const Pixel Green;
+  extern const Pixel Blue;
+
 }}
 
+
 #endif

+ 7 - 0
src/Pixel.cpp

@@ -1,6 +1,7 @@
 #include <Pixel.h>
 
 #define PIXEL WalrusRPG::Graphics::Pixel
+#define GRAPHICS WalrusRPG::Graphics
 
 PIXEL::Pixel(std::uint16_t color) : value(color) {
 
@@ -22,3 +23,9 @@ PIXEL& PIXEL::operator=(unsigned value) {
   this->value = value;
 	return *this;
 }
+
+const PIXEL GRAPHICS::Black(0, 0, 0);
+const PIXEL GRAPHICS::White(255, 255, 255);
+const PIXEL GRAPHICS::Red(255, 0, 0);
+const PIXEL GRAPHICS::Green(0, 255, 0);
+const PIXEL GRAPHICS::Blue(0, 0, 255);

+ 1 - 1
src/main.cpp

@@ -28,7 +28,7 @@ void map_loop(unsigned x, unsigned y, Map &map)
 		// Frameskip
 		if (timer_read(0) > loop_next)
 		{
-			Pixel pix(255, 255, 255);
+			Pixel pix(Green);
 			// TODO?: Preset color macros/consts?
 			buffer_fill(pix);
 			map.render(camera, 1);