Browse Source

adding redstone

meemknight 1 year ago
parent
commit
4963b1abdc

+ 56 - 3
Pika/gameplay/containers/isometricGame/isometricGameEditor.cpp

@@ -1,7 +1,7 @@
 #include <containers/isometricGame/isometricGameEditor.h>
 #include <containers/isometricGame/isometricGameEditor.h>
 #include <glui/glui.h>
 #include <glui/glui.h>
 
 
-static int blocksCount = 8;
+static int blocksCount = 16;
 
 
 static bool pointInBox(glm::vec2 p, glm::vec4 box)
 static bool pointInBox(glm::vec2 p, glm::vec4 box)
 {
 {
@@ -26,7 +26,7 @@ bool IsometricGameEditor::create(RequestedContainerInfo &requestedInfo, pika::St
 
 
 	tiles = pika::gl2d::loadTextureWithPixelPadding(PIKA_RESOURCES_PATH "isoTiles/Isometric-Tiles.png", requestedInfo, 32, true);
 	tiles = pika::gl2d::loadTextureWithPixelPadding(PIKA_RESOURCES_PATH "isoTiles/Isometric-Tiles.png", requestedInfo, 32, true);
 
 
-	tilesAtlas = gl2d::TextureAtlasPadding(8, 2, tiles.GetSize().x, tiles.GetSize().y);
+	tilesAtlas = gl2d::TextureAtlasPadding(16, 8, tiles.GetSize().x, tiles.GetSize().y);
 
 
 	//fileChanged.setFile(mapFile.c_str());
 	//fileChanged.setFile(mapFile.c_str());
 
 
@@ -202,8 +202,61 @@ bool IsometricGameEditor::update(pika::Input input, pika::WindowState windowStat
 				{
 				{
 					glm::vec2 position = calculateBlockPos({x,y,z});
 					glm::vec2 position = calculateBlockPos({x,y,z});
 
 
-					renderer.renderRectangle({position,size,size}, tiles, Colors_White, {}, 0,
+					glm::vec4 color = Colors_White;
+
+					if (b->get().x == Blocks::redstone)
+					{
+						color = glm::vec4(0.8, 0.2, 0.2, 1.0);
+					}
+
+					renderer.renderRectangle({position,size,size}, tiles, color, {}, 0,
 						tilesAtlas.get(b->get().x, b->get().y));
 						tilesAtlas.get(b->get().x, b->get().y));
+
+					if (b->get().x == Blocks::redstone)
+					{
+						auto b2 = map.getSafe({x,y,z-1});
+						if (b2 && b2->type == Blocks::redstone)
+						{
+							renderer.renderRectangle({position,size,size}, tiles, color, {}, 0,
+								tilesAtlas.get(b->get().x, 1));
+						}
+
+						b2 = map.getSafe({x-1,y,z});
+						if (b2 && b2->type == Blocks::redstone)
+						{
+							renderer.renderRectangle({position,size,size}, tiles, color, {}, 0,
+								tilesAtlas.get(b->get().x, 2));
+						}
+
+						b2 = map.getSafe({x + 1,y,z});
+						if (b2 && b2->type == Blocks::redstone)
+						{
+							renderer.renderRectangle({position,size,size}, tiles, color, {}, 0,
+								tilesAtlas.get(b->get().x, 3));
+						}
+
+						b2 = map.getSafe({x,y,z + 1});
+						if (b2 && b2->type == Blocks::redstone)
+						{
+							renderer.renderRectangle({position,size,size}, tiles, color, {}, 0,
+								tilesAtlas.get(b->get().x, 4));
+						}
+
+						b2 = map.getSafe({x-1,y+1,z});
+						if (b2 && b2->type == Blocks::redstone)
+						{
+							renderer.renderRectangle({position,size,size}, tiles, color, {}, 0,
+								tilesAtlas.get(b->get().x, 5));
+						}
+
+						b2 = map.getSafe({x,y+1,z-1});
+						if (b2 && b2->type == Blocks::redstone)
+						{
+							renderer.renderRectangle({position,size,size}, tiles, color, {}, 0,
+								tilesAtlas.get(b->get().x, 6));
+						}
+
+					}
 				}
 				}
 
 
 				if (currentSelectedBlockDelete == glm::ivec3{x, y, z})
 				if (currentSelectedBlockDelete == glm::ivec3{x, y, z})

+ 18 - 13
Pika/gameplay/containers/isometricGame/isometricGameEditor.h

@@ -12,6 +12,20 @@
 struct IsometricGameEditor: public Container
 struct IsometricGameEditor: public Container
 {
 {
 
 
+	enum Blocks
+	{
+		air = 0,
+		clay,
+		stone,
+		ice,
+		snowDirt,
+		dirt,
+		log,
+		woddenPlank,
+		redstone
+	};
+
+
 	pika::FileChanged fileChanged;
 	pika::FileChanged fileChanged;
 
 
 	gl2d::Renderer2D renderer;
 	gl2d::Renderer2D renderer;
@@ -40,26 +54,17 @@ struct IsometricGameEditor: public Container
 	struct Block
 	struct Block
 	{
 	{
 		unsigned char type;
 		unsigned char type;
+		unsigned char secondType;
 
 
-		void set(unsigned char count, bool down)
+		void set(unsigned char count, unsigned char down)
 		{
 		{
 			type = count;
 			type = count;
-			if (down)
-			{
-				type |= 0b1000'0000;
-			}
+			secondType = down;
 		}
 		}
 
 
 		glm::ivec2 get()
 		glm::ivec2 get()
 		{
 		{
-			if (type & 0b1000'0000)
-			{
-				return {type & 0b0111'1111, 1};
-			}
-			else
-			{
-				return {type, 0};
-			}
+			return {type, secondType};
 		}
 		}
 	};
 	};
 
 

BIN
Pika/resources/isoSaves/test1.isomap


BIN
Pika/resources/isoTiles/Isometric-Tiles.png


+ 4 - 7
Pika/resources/logs.txt

@@ -1,7 +1,4 @@
-#2024-01-03 16:04:06: Created container: IsometricGameEditor
-#2024-01-03 16:04:49: Reloaded dll
-#2024-01-03 16:07:06: Reloaded dll
-#2024-01-03 16:07:44: Reloaded dll
-#2024-01-03 16:07:58: Reloaded dll
-#2024-01-03 16:08:48: Reloaded dll
-#2024-01-03 16:10:43: Destroyed continer: IsometricGameEditor #1
+#2024-01-03 17:50:06: Created container: IsometricGameEditor
+#2024-01-03 17:50:13: Destroyed continer: IsometricGameEditor #1
+#2024-01-03 17:50:17: Created container: IsometricGameEditor
+#2024-01-03 17:50:40: Destroyed continer: IsometricGameEditor #2