瀏覽代碼

made mario game

meemknight 2 年之前
父節點
當前提交
90da819525

+ 7 - 4
Pika/core/pikaRuntime/containerManager/containerManager.cpp

@@ -1,6 +1,4 @@
 #include "containerManager.h"
-#include "containerManager.h"
-#include "containerManager.h"
 #include <globalAllocator/globalAllocator.h>
 #include <unordered_set>
 #include <chrono>
@@ -457,8 +455,13 @@ void pika::ContainerManager::update(pika::LoadedDll &loadedDll, pika::PikaWindow
 					//https://github.com/ocornut/imgui/issues/5882
 					ImGuiViewport *viewPort = ImGui::GetWindowViewport();
 					auto io = ImGui::GetIO();
-					
-					windowInput.hasFocus = viewPort->PlatformUserData && ImGui::GetPlatformIO().Platform_GetWindowFocus(viewPort) && !io.AppFocusLost;
+				
+					if (viewPort->PlatformUserData)
+					{
+						windowInput.hasFocus = ImGui::IsWindowFocused()
+							&& ImGui::GetPlatformIO().Platform_GetWindowFocus(viewPort) && !io.AppFocusLost;
+					}
+
 					//windowInput.hasFocus = windowInput.hasFocus && !io.AppFocusLost;
 				}
 				

+ 53 - 0
Pika/core/pikaSTD/fileChanged.cpp

@@ -0,0 +1,53 @@
+#include "fileChanged.h"
+
+namespace pika
+{
+
+
+	void FileChanged::setFile(const char *path)
+	{
+		this->path = path;
+
+		WIN32_FILE_ATTRIBUTE_DATA Data = {};
+		if (GetFileAttributesEx(path, GetFileExInfoStandard, &Data))
+		{
+			time = Data.ftLastWriteTime;
+		}
+		else
+		{
+			time = {};
+		}
+
+	}
+	
+
+	bool FileChanged::changed()
+	{
+		if (time.dwHighDateTime == 0
+			&& time.dwLowDateTime == 0)
+		{
+			return 0;
+		}
+
+		if (path.empty()) { return 0; }
+
+		WIN32_FILE_ATTRIBUTE_DATA Data = {};
+		if (GetFileAttributesEx(path.string().c_str(), GetFileExInfoStandard, &Data))
+		{
+			if (time.dwHighDateTime == Data.ftLastWriteTime.dwHighDateTime
+				&& time.dwLowDateTime == Data.ftLastWriteTime.dwLowDateTime)
+			{
+				return 0;
+			}
+			else
+			{
+				time = Data.ftLastWriteTime;
+				return 1;
+			}
+		}
+
+		return 0;
+	}
+
+
+};

+ 50 - 0
Pika/core/pikaSTD/fileChanged.h

@@ -0,0 +1,50 @@
+#pragma once
+#include "pikaConfig.h"
+#include <filesystem>
+#include <logs/assert.h>
+
+
+#ifdef PIKA_WINDOWS
+
+#define NOMINMAX
+#include <Windows.h>
+
+namespace pika
+{
+
+	
+	struct FileChanged
+	{
+	
+		std::filesystem::path path;
+		FILETIME time = {};
+
+		void setFile(const char *path);
+		bool changed();
+	
+	private:
+	
+	};
+	
+	#else
+	
+	
+	struct FileChanged
+	{
+	
+	
+		std::filesystem::path path;
+	
+		void setFile(const char *path) {}
+		bool changed()
+		{
+			PIKA_PERMA_ASSERT(0, "file changed only supported on windows");
+			return 0;
+		}
+	
+	
+	};
+	
+	#endif
+
+};

二進制
Pika/engineResources/engineSaves/options1.bin


二進制
Pika/engineResources/engineSaves/options2.bin


二進制
Pika/engineResources/engineSaves/window1.bin


二進制
Pika/engineResources/engineSaves/window2.bin


二進制
Pika/engineResources/engineSaves/windowPos1.bin


二進制
Pika/engineResources/engineSaves/windowPos2.bin


二進制
Pika/engineResources/jump.recording


二進制
Pika/engineResources/jump.snapshot


二進制
Pika/engineResources/test.snapshot


+ 362 - 0
Pika/gameplay/containers/mario/mario.cpp

@@ -0,0 +1,362 @@
+#include "mario.h"
+
+
+
+
+glm::vec2 Transform::getTopLeftCorner()
+{
+	return position;
+}
+
+glm::vec2 Transform::getCenter()
+{
+	return position + size / 2.f;
+}
+
+glm::vec2 Transform::getBottomLeftCorner()
+{
+	return position + glm::vec2(0, size.y);
+}
+
+glm::vec2 Transform::getBottomCenter()
+{
+	return position + glm::vec2(size.x / 2.f, size.y);
+}
+
+
+
+void Player::move(glm::vec2 dir)
+{
+	if (length(dir) == 0.f) { return; }
+
+	movingThisFrame = true;
+	position.position += dir;
+}
+
+
+float maxMoveVelocity = 25;
+float startVelocity = 10;
+
+void Player::moveVelocityX(float dir)
+{
+	if (dir == 0) { return; }
+
+	movingThisFrame = true;
+
+	if (dir > 0 && velocity.x < 0)
+	{
+		velocity.x = 0;
+	}
+	else if (dir < 0 && velocity.x > 0)
+	{
+		velocity.x = 0;
+	}
+
+	if (dir > 0)
+	{
+		if (velocity.x < maxMoveVelocity)
+		{
+			if (velocity.x == 0)
+			{
+				velocity.x = startVelocity;
+			}
+
+			velocity.x += dir;
+
+			if (velocity.x > maxMoveVelocity)
+			{
+				velocity.x = maxMoveVelocity;
+			}
+		}
+	}
+	else if (dir < 0)
+	{
+		if (velocity.x > -maxMoveVelocity)
+		{
+			if (velocity.x == 0)
+			{
+				velocity.x = -startVelocity;
+			}
+
+			velocity.x += dir;
+
+			if (velocity.x < -maxMoveVelocity)
+			{
+				velocity.x = -maxMoveVelocity;
+			}
+		}
+	}
+
+
+
+}
+
+void Player::jump(float power)
+{
+	velocity.y = -power;
+}
+
+const float terminalVelocity = 60;
+
+void Player::applyGravity(float gravity)
+{
+
+	if (velocity.y < terminalVelocity)
+	{
+		velocity.y += gravity;
+
+		if (velocity.y > terminalVelocity)
+		{
+			velocity.y = terminalVelocity;
+		}
+	}
+
+}
+
+
+void Player::updateMove()
+{
+	if (lastPos.x - position.position.x < 0)
+	{
+		movingRight = true;
+	}
+	else if (lastPos.x - position.position.x > 0)
+	{
+		movingRight = false;
+	}
+
+	if (movingThisFrame)
+	{
+		//playerAnimation.state = PlayerAnimation::STATES::running;
+	}
+	else
+	{
+		//playerAnimation.state = {};
+	}
+
+
+	lastPos = position.position;
+
+	movingThisFrame = false;
+
+}
+
+float groundDrag = 120.f;
+float airDrag = 60.f;
+
+void Player::updatePhisics(float deltaTime)
+{
+
+	glm::vec2 drag = {groundDrag, groundDrag};
+
+	if (!grounded) { drag.x = airDrag; }
+
+	if (!movingThisFrame)
+	{
+		if (velocity.x > 0)
+		{
+			velocity -= drag * deltaTime;
+
+			if (velocity.x < 0)
+			{
+				velocity.x = 0;
+			}
+		}
+		else if (velocity.x < 0)
+		{
+			velocity += drag * deltaTime;
+
+			if (velocity.x > 0)
+			{
+				velocity.x = 0;
+			}
+		}
+	}
+
+	position.position += velocity * deltaTime;
+
+}
+
+void Player::checkCollisionBrute(glm::vec2 &pos, glm::vec2 lastPos, Block *map, bool &upTouch, bool &downTouch, bool &leftTouch, bool &rightTouch)
+{
+	glm::vec2 delta = pos - lastPos;
+	const float BLOCK_SIZE = 1.f;
+
+	glm::vec2 &dimensions = position.size;
+
+	glm::ivec2 mapSize = {100,100};
+
+	if (
+		(pos.y < -dimensions.y)
+		|| (pos.x < -dimensions.x)
+		|| (pos.y > mapSize.x * BLOCK_SIZE)
+		|| (pos.x > mapSize.y * BLOCK_SIZE)
+		)
+	{
+		return;
+	}
+
+	glm::vec2 newPos = performCollision(map, {pos.x, lastPos.y}, {dimensions.x, dimensions.y}, {delta.x, 0},
+		upTouch, downTouch, leftTouch, rightTouch);
+	pos = performCollision(map, {newPos.x, pos.y}, {dimensions.x, dimensions.y}, {0, delta.y},
+		upTouch, downTouch, leftTouch, rightTouch);
+
+}
+
+glm::vec2 Player::performCollision(Block *map, glm::vec2 pos, glm::vec2 size, glm::vec2 delta, bool &upTouch, bool &downTouch, bool &leftTouch, bool &rightTouch)
+{
+	glm::ivec2 mapSize = {100,100};
+
+	int minX = 0;
+	int minY = 0;
+	int maxX = mapSize.x;
+	int maxY = mapSize.y;
+
+	auto &dimensions = position.size;
+
+	const float BLOCK_SIZE = 1.f;
+
+	minX = (pos.x - abs(delta.x) - BLOCK_SIZE) / BLOCK_SIZE;
+	maxX = ceil((pos.x + abs(delta.x) + BLOCK_SIZE + size.x) / BLOCK_SIZE);
+
+	minY = (pos.y - abs(delta.y) - BLOCK_SIZE) / BLOCK_SIZE;
+	maxY = ceil((pos.y + abs(delta.y) + BLOCK_SIZE + size.y) / BLOCK_SIZE);
+
+	minX = std::max(0, minX);
+	minY = std::max(0, minY);
+	maxX = std::min(mapSize.x, maxX);
+	maxY = std::min(mapSize.y, maxY);
+
+	auto getMapBlockUnsafe = [&](int x, int y) -> Block *
+	{
+		return &map[x + y * mapSize.x];
+	};
+
+	for (int y = minY; y < maxY; y++)
+		for (int x = minX; x < maxX; x++)
+		{
+			if (getMapBlockUnsafe(x, y)->isCollidable())
+			{
+				if (aabb({pos,dimensions}, {x * BLOCK_SIZE, y * BLOCK_SIZE, BLOCK_SIZE, BLOCK_SIZE}, 0.0001f))
+				{
+					if (delta.x != 0)
+					{
+						if (delta.x < 0) // moving left
+						{
+							leftTouch = 1;
+							pos.x = x * BLOCK_SIZE + BLOCK_SIZE;
+							goto end;
+						}
+						else
+						{
+							rightTouch = 1;
+							pos.x = x * BLOCK_SIZE - dimensions.x;
+							goto end;
+						}
+					}
+					else if (delta.y != 0)
+					{
+						if (delta.y < 0) //moving up
+						{
+							upTouch = 1;
+							pos.y = y * BLOCK_SIZE + BLOCK_SIZE;
+							goto end;
+						}
+						else
+						{
+							downTouch = 1;
+							pos.y = y * BLOCK_SIZE - dimensions.y;
+							goto end;
+						}
+					}
+
+				}
+			}
+
+		}
+
+end:
+	return pos;
+
+}
+
+void Player::resolveConstrains(Block *map)
+{
+	glm::ivec2 mapSize = {100,100};
+
+	bool upTouch = 0;
+	bool downTouch = 0;
+	bool leftTouch = 0;
+	bool rightTouch = 0;
+
+	glm::vec2 &pos = position.position;
+
+	float distance = glm::length(lastPos - pos);
+	const float BLOCK_SIZE = 1.f;
+
+	if (distance < BLOCK_SIZE)
+	{
+		checkCollisionBrute(pos,
+			lastPos,
+			map,
+			upTouch,
+			downTouch,
+			leftTouch,
+			rightTouch
+		);
+	}
+	else
+	{
+		glm::vec2 newPos = lastPos;
+		glm::vec2 delta = pos - lastPos;
+		delta = glm::normalize(delta);
+		delta *= 0.9 * BLOCK_SIZE;
+
+		do
+		{
+			newPos += delta;
+			glm::vec2 posTest = newPos;
+			checkCollisionBrute(newPos,
+				lastPos,
+				map,
+				upTouch,
+				downTouch,
+				leftTouch,
+				rightTouch);
+
+			if (newPos != posTest)
+			{
+				pos = newPos;
+				goto end;
+			}
+
+		} while (glm::length((newPos + delta) - pos) > 1.0f * BLOCK_SIZE);
+
+		checkCollisionBrute(pos,
+			lastPos,
+			map,
+			upTouch,
+			downTouch,
+			leftTouch,
+			rightTouch);
+	}
+
+end:
+
+	//clamp the box if needed
+	if (pos.x < 0) { pos.x = 0; leftTouch = true; }
+	if (pos.x + position.size.x > (mapSize.x) * BLOCK_SIZE)
+	{
+		pos.x = ((mapSize.x) * BLOCK_SIZE) - position.size.x; rightTouch = true;
+	}
+
+
+	if (leftTouch && velocity.x < 0) { velocity.x = 0; }
+	if (rightTouch && velocity.x > 0) { velocity.x = 0; }
+
+	if (upTouch && velocity.y < 0) { velocity.y = 0; }
+	if (downTouch && velocity.y > 0) { velocity.y = 0; }
+
+	if (downTouch) { grounded = true; }
+
+}

+ 183 - 38
Pika/gameplay/containers/mario/mario.h

@@ -6,14 +6,72 @@
 #include <shortcutApi/shortcutApi.h>
 #include <pikaSizes.h>
 #include "marioCommon.h"
+#include <fileChanged.h>
+
+struct Transform
+{
+	glm::vec2 position = {};
+	glm::vec2 size = {};
+
+	glm::vec2 getTopLeftCorner();
+	glm::vec2 getCenter();
+	glm::vec2 getBottomLeftCorner();
+	glm::vec2 getBottomCenter();
+
+};
+
+#define PLAYER_SIZE glm::vec2(6.f / 8.f, 1.f)
+
+struct Player
+{
+	Transform position = {glm::vec2(0,0), PLAYER_SIZE};
+
+	glm::vec2 lastPos{};
+
+	glm::vec2 velocity = {};
+
+	bool movingRight = 0;
+	bool grounded = 0;
+
+	void move(glm::vec2 dir);
+
+	void moveVelocityX(float dir);
+
+	void jump(float power);
+
+	void applyGravity(float gravity);
+
+	bool movingThisFrame = false;
+
+
+	//should be called only once per frame last
+	void updateMove();
+
+	//this should be called before collisions 
+	void updatePhisics(float deltaTime);
+
+
+	void resolveConstrains(Block *map);
+
+	void checkCollisionBrute(glm::vec2 &pos, glm::vec2 lastPos,
+		Block *map, bool &upTouch, bool &downTouch, bool &leftTouch, bool &rightTouch);
+
+	glm::vec2 Player::performCollision(Block *map, glm::vec2 pos, glm::vec2 size,
+		glm::vec2 delta, bool &upTouch, bool &downTouch, bool &leftTouch, bool &rightTouch);
+
+	int input = 0;
+};
 
 struct Mario: public Container
 {
 
 	gl2d::Renderer2D renderer;
 	gl2d::Texture tiles;
+	gl2d::Texture marioTexture;
 	gl2d::TextureAtlasPadding atlas;
 	
+	Player player;
+	pika::FileChanged fileChanged;
 
 	//todo user can request imgui ids; shortcut manager context; allocators
 	static ContainerStaticInfo containerInfo()
@@ -24,13 +82,37 @@ struct Mario: public Container
 		info.requestImguiFbo = true; //todo this should not affect the compatibility of input recording
 
 
-
 		return info;
 	}
 
+	Block *map;
+	glm::ivec2 mapSize = {100, 100};
+
+	Block &getMapBlockUnsafe(int x, int y)
+	{
+		return map[x + y * mapSize.x];
+	}
+
+	bool loadMap(RequestedContainerInfo &requestedInfo)
+	{
+		size_t s = 0;
+		if (requestedInfo.getFileSizeBinary(PIKA_RESOURCES_PATH "/mario/map1.mario", s))
+		{
+			if (s == mapSize.x * mapSize.y)
+			{
+				requestedInfo.readEntireFileBinary(PIKA_RESOURCES_PATH "/mario/map1.mario", map, mapSize.x * mapSize.y);
+			}
+			else { return 0; }
+		}
+		else { return 0; }
+
+		return 1;
+	}
 
 	bool create(RequestedContainerInfo &requestedInfo, pika::StaticString<256> commandLineArgument)
 	{
+		player.position.position = {1,1};
+
 		renderer.create();
 		//gl2d::setErrorFuncCallback() //tood
 		//pika::initShortcutApi();
@@ -50,71 +132,134 @@ struct Mario: public Container
 		}
 		else { return 0; }
 
+		//todo push pop or sthing
+		pika::memory::setGlobalAllocatorToStandard();
+		marioTexture.loadFromFile(PIKA_RESOURCES_PATH "/mario/mario.png", true, false);
+		marioTexture.loadFromFile(PIKA_RESOURCES_PATH "/mario/mario.png", true, false);
+		pika::memory::setGlobalAllocator(requestedInfo.mainAllocator);
+
 
 		atlas = gl2d::TextureAtlasPadding(8, 10, 8*8, 8*10);
 
+		map = new Block[mapSize.x * mapSize.y];
+		Block d{27,0};
+		memset(map, *(int *)(&d), mapSize.x * mapSize.y);
 
-		return true;
+		renderer.currentCamera.zoom = 60.f;
+		
+		bool rez = loadMap(requestedInfo);
+
+		fileChanged.setFile(PIKA_RESOURCES_PATH "/mario/map1.mario");
+
+		return rez;
 	}
 
 	bool update(pika::Input input, pika::WindowState windowState,
 		RequestedContainerInfo &requestedInfo)
 	{
-		//todo keep window on top stuff
 
-		glClear(GL_COLOR_BUFFER_BIT);
-		gl2d::enableNecessaryGLFeatures();
+		{
+			glClear(GL_COLOR_BUFFER_BIT);
+			gl2d::enableNecessaryGLFeatures();
+			renderer.updateWindowMetrics(windowState.w, windowState.h);
+		}
+
+		if (fileChanged.changed())
+		{
+			loadMap(requestedInfo);
+		}
+
+		{
+			float wheel = ImGui::GetIO().MouseWheel;
+
+			//todo standard out
+
+			if ((ImGui::GetIO().KeysData[ImGuiKey_LeftCtrl].Down || ImGui::GetIO().KeysData[ImGuiKey_RightCtrl].Down) && input.hasFocus)
+			{
+				renderer.currentCamera.zoom += wheel * 3;
+			}
+
+			renderer.currentCamera.zoom = std::min(renderer.currentCamera.zoom, 70.f);
+			renderer.currentCamera.zoom = std::max(renderer.currentCamera.zoom, 50.f);
+
+			int delta = 0;
+
+			if (input.hasFocus)
+			{
+				if (input.buttons[pika::Button::A].held())
+				{
+					delta -= 1;
+				}
+				if (input.buttons[pika::Button::D].held())
+				{
+					delta += 1;
+				}
+				
+			}
+
+			player.input = delta;
+
+			if (input.buttons[pika::Button::Space].pressed() && player.grounded)
+			{
+				player.jump(60);
+			}
+
+			//phisics
+			{
+				player.moveVelocityX(5 * input.deltaTime * player.input);
+				
+				player.applyGravity(300.f * input.deltaTime);
 
+				player.updatePhisics(input.deltaTime);
 
-		renderer.updateWindowMetrics(windowState.w, windowState.h);
+				player.grounded = false;
+				player.resolveConstrains(map);
 
+				//player.playerAnimation.grounded = i.second.grounded;
 
-		renderer.renderRectangle({10, 10, 100, 100}, {}, {}, tiles, atlas.get(3, 5));
+				player.updateMove();
 
+				//player.playerAnimation.update(input.deltaTime);
+			}
 
-		int size = 20;
-		renderer.renderRectangle({input.mouseX - size / 2, input.mouseY - size / 2, size, size},
-			Colors_Turqoise, {}, 0.f);
+			//todo update gl2d this function
+			renderer.currentCamera.follow(player.position.getCenter(), input.deltaTime * 3, 0.0001, 0.2, windowState.w, windowState.h);
 
+		}
+		auto viewRect = renderer.getViewRect();
 
+		glm::ivec2 minV;
+		glm::ivec2 maxV;
+		//render
+		{
 
-		//requestedInfo.consoleWrite((std::string("Mouse: ") + std::to_string(input.mouseX) + " " +
-		//	std::to_string(input.mouseY) + "\n").c_str());
+			minV = {viewRect.x - 2, viewRect.y - 2};
+			maxV = minV + glm::ivec2{viewRect.z + 4, viewRect.w + 4};
+			minV = glm::max(minV, {0,0});
+			maxV = glm::min(maxV, mapSize);
 
 
-		//if (input.lMouse.pressed())
-		//{
-		//	std::cout << "pressed\n";
-		//}
-		//if (input.lMouse.released())
-		//{
-		//	std::cout << "released\n";
-		//}
+			for (int j = minV.y; j < maxV.y; j++)
+				for (int i = minV.x; i < maxV.x; i++)
+				{
+					auto b = getMapBlockUnsafe(i, j);
+					auto uv = getTileUV(atlas, b.type, b.flipped);
 
-		//if (input.lMouse.typed())
-		//{
-		//	std::cout << "typed\n";
-		//}
+					renderer.renderRectangle({i, j, 1, 1}, {}, {}, tiles, uv);
 
-		//if (input.buttons[pika::Button::E].typed())
-		//{
-		//	std::cout << "e";
-		//}
+				}
+		}
 
-		//std::cout << state.deltaTime << "\n";
+		glm::vec4 pos(player.position.position, 1, 1);
+		//pos.y -= 1 / 8.f;
+		pos.x -= 1 / 8.f;
 
-		renderer.flush();
+		renderer.renderRectangle(pos, {}, {}, marioTexture, 
+			player.movingRight ? glm::vec4(0,1,1,0) : glm::vec4(1, 1, 0, 0));
 
-		//ImGui::SetAllocatorFunctions(userMalloc, userFree);
 
-		//ImGui::Begin("window from gameplay");
-		//ImGui::Spinner("spinner", 10, 2);
-		//ImGui::ProgressBar(0.4);
-		//ImGui::BufferingBar("buffering bar", 0.4, {100, 5});
-		//ImGui::LoadingIndicatorCircle("circle", 20, 8, 8);
-		//ImGui::End();
+		renderer.flush();
 
-		//ImGui::ShowDemoWindow();
 
 		return true;
 	}

+ 20 - 0
Pika/gameplay/containers/mario/marioCommon.cpp

@@ -13,3 +13,23 @@ glm::vec4 getTileUV(gl2d::TextureAtlasPadding atlas, int id, int flip)
 	int y = id / 8;
 	return atlas.get(x, y, flip);
 }
+
+bool aabb(glm::vec4 b1, glm::vec4 b2, float delta)
+{
+	b2.x += delta;
+	b2.y += delta;
+	b2.z -= delta * 2;
+	b2.w -= delta * 2;
+
+	if (((b1.x - b2.x < b2.z)
+		&& b2.x - b1.x < b1.z
+		)
+		&& ((b1.y - b2.y < b2.w)
+		&& b2.y - b1.y < b1.w
+		)
+		)
+	{
+		return 1;
+	}
+	return 0;
+}

+ 16 - 1
Pika/gameplay/containers/mario/marioCommon.h

@@ -18,4 +18,19 @@ constexpr const char *collisionMap =
 
 bool isSolid(int id);
 
-glm::vec4 getTileUV(gl2d::TextureAtlasPadding atlas, int id, int flip = 0);
+glm::vec4 getTileUV(gl2d::TextureAtlasPadding atlas, int id, int flip = 0);
+
+struct Block
+{
+	unsigned char type : 7;
+	unsigned char flipped : 1;
+
+	bool isCollidable()
+	{
+		return collisionMap[type] == 'X';
+	}
+};
+
+
+
+bool aabb(glm::vec4 b1, glm::vec4 b2, float delta);

+ 2 - 42
Pika/gameplay/containers/mario/marioEditor.h

@@ -22,13 +22,7 @@ struct MarioEditor: public Container
 
 	int currentBlock = 0;
 	bool flip = 0;
-
-	struct Block
-	{
-		unsigned char type : 7;
-		unsigned char flipped : 1;
-	};
-
+	
 	Block *map;
 
 	Block &getMapBlockUnsafe(int x, int y)
@@ -338,44 +332,10 @@ struct MarioEditor: public Container
 
 		}
 
-		//requestedInfo.consoleWrite((std::string("Mouse: ") + std::to_string(input.mouseX) + " " +
-		//	std::to_string(input.mouseY) + "\n").c_str());
-
-
-		//if (input.lMouse.pressed())
-		//{
-		//	std::cout << "pressed\n";
-		//}
-		//if (input.lMouse.released())
-		//{
-		//	std::cout << "released\n";
-		//}
-
-		//if (input.lMouse.typed())
-		//{
-		//	std::cout << "typed\n";
-		//}
-
-		//if (input.buttons[pika::Button::E].typed())
-		//{
-		//	std::cout << "e";
-		//}
-
-		//std::cout << state.deltaTime << "\n";
 
 		renderer.flush();
 
-		//ImGui::SetAllocatorFunctions(userMalloc, userFree);
-
-		//ImGui::Begin("window from gameplay");
-		//ImGui::Spinner("spinner", 10, 2);
-		//ImGui::ProgressBar(0.4);
-		//ImGui::BufferingBar("buffering bar", 0.4, {100, 5});
-		//ImGui::LoadingIndicatorCircle("circle", 20, 8, 8);
-		//ImGui::End();
-
-		//ImGui::ShowDemoWindow();
-
+	
 		return true;
 	}
 

+ 9 - 5
Pika/pluggins/pluggins/threeDEditor.h

@@ -28,8 +28,8 @@ struct ThreeDEditor: public Container
 	}
 
 	gl3d::Renderer3D renderer;
-	gl3d::Model helmetModel;
-	gl3d::Entity helmetEntity;
+	gl3d::Model model;
+	gl3d::Entity entity;
 
 	bool create(RequestedContainerInfo &requestedInfo, pika::StaticString<256> commandLineArgument)
 	{
@@ -59,13 +59,13 @@ struct ThreeDEditor: public Container
 		//renderer.skyBox.color = {0.2,0.3,0.8};
 		
 		//helmetModel = renderer.loadModel(PIKA_RESOURCES_PATH "helmet/helmet.obj");
-		helmetModel = renderer.loadModel(PIKA_RESOURCES_PATH "/knight/uploads_files_1950170_Solus_the_knight.gltf");
+		model = renderer.loadModel(PIKA_RESOURCES_PATH "/knight/uploads_files_1950170_Solus_the_knight.gltf");
 		
 		gl3d::Transform t;
-		t.position = {0, 0, -4};
+		t.position = {0, -1, -4};
 		//t.rotation = {1.5, 0 , 0};
 		
-		helmetEntity = renderer.createEntity(helmetModel, t);
+		entity = renderer.createEntity(model, t);
 
 		return true;
 	}
@@ -109,6 +109,10 @@ struct ThreeDEditor: public Container
 			}
 		}
 		
+
+
+		renderer.setEntityAnimate(entity, true);
+
 		
 		renderer.render(input.deltaTime);
 		glDisable(GL_DEPTH_TEST);

+ 5 - 8
Pika/resources/logs.txt

@@ -1,8 +1,5 @@
-#2023-01-27 13:53:38: Created container: Gameplay
-#2023-01-27 13:53:43: Destroyed continer: Gameplay #1
-#2023-01-27 13:53:47: Created container: MarioEditor
-#2023-01-27 13:53:49: Created container: ImmageViewer
-#2023-01-27 13:57:04: Destroyed continer: MarioEditor #2
-#2023-01-27 13:57:14: Created container: MarioEditor
-#2023-01-27 14:03:07: Destroyed continer: ImmageViewer #3
-#2023-01-27 14:03:07: Destroyed continer: MarioEditor #4
+#2023-01-27 17:41:05: Created container: Gameplay
+#2023-01-27 17:44:20: Destroyed continer: Gameplay #1
+#2023-01-27 17:44:30: Created container: ThreeDEditor
+#2023-01-27 17:46:24: Reloaded dll
+#2023-01-27 17:46:36: Destroyed continer: ThreeDEditor #2

二進制
Pika/resources/mario/map1.mario


二進制
Pika/resources/mario/mario.png