#pragma once
#include <enginend/engine.h>
#include "cheats.h"
enum CURSORMODES {
	MAINMENU=0,
	COMPUTER=1,
	LEFT=2,RIGHT=3,UP=4,DOWN=5,
	FLASHLIGHT=6,INTERACT=7
};
#define LOADMAP LoadTexture(newpath.c_str());
struct entity {
	char pos;
	char dir;
};



extern std::vector<std::vector<char>> map;
extern std::vector<char> opposites;
char moveentity(char pos,char dir,bool backwards);
char rotateentity(char pos,char dir, bool clockwise);
bool ifforward();bool ifbackward();bool ifleft();bool ifright();
extern std::vector<char> sides;
extern std::vector<std::string> lightlevel;

struct game:public enginend::scene {
	// dir 1
	
	int lightmode:2=1; // off, on, urcooked
	std::string mappath;
	// this is for quick loading but without weighting ram..
	// yea the assets are small but i like optimization
	float stamina=0.0;
	entity uycatroz{6,3};
	entity skaile{10,3};
	entity player{0,1};
	Texture2D current;
	void boot() final {
		mappath=AT("res/map");
		this->nodes={
			new enginend::nodes::twod::relative::textured()
		};
		std::string newpath=AT((mappath+"/"+lightlevel[lightmode]+"/"+sides[player.dir]+"/"+std::to_string(player.pos)+".jpg"));
				
		current=LOADMAP
	}
	void tick() final {
		bool changed=false;
		if (stamina>=1.){
			if (ifforward()){player.pos=moveentity(player.pos,player.dir,false);changed=true;}
			if (ifbackward()){player.pos=moveentity(player.pos,player.dir,true);changed=true;}
			if (ifleft()){player.dir=rotateentity(player.pos,player.dir,false);changed=true;}
			if (ifright()){player.dir=rotateentity(player.pos,player.dir,true);changed=true;}
			if (changed) {
				UnloadTexture(current);
				std::string newpath=AT((mappath+"/"+lightlevel[lightmode]+"/"+sides[player.dir]+"/"+std::to_string(player.pos)+".jpg"));
				current=LOADMAP
				tiny::success((char*)newpath.c_str());
			}
		}else stamina+=.01;
		
		
	}
	void draw() final {
		int screenw=GetScreenWidth();int screenh=GetScreenHeight();
		BeginDrawing();
		ClearBackground(rl::WHITE);
		DrawTexturePro(current,{0,0,480,280},{0,0,(float)screenw,(float)screenh},{0,0},0,rl::WHITE);
		EndDrawing();
	}
};