visibility!
This commit is contained in:
parent
d5474f5107
commit
38ea792ee7
4 changed files with 48 additions and 6 deletions
|
|
@ -20,6 +20,7 @@ extern std::vector<char> opposites;
|
||||||
char moveentity(char pos,char dir,bool backwards);
|
char moveentity(char pos,char dir,bool backwards);
|
||||||
char rotateentity(char pos,char dir, bool clockwise);
|
char rotateentity(char pos,char dir, bool clockwise);
|
||||||
bool ifforward();bool ifbackward();bool ifleft();bool ifright();
|
bool ifforward();bool ifbackward();bool ifleft();bool ifright();
|
||||||
|
bool cansee(char dest,char pos, char dir);
|
||||||
extern std::vector<char> sides;
|
extern std::vector<char> sides;
|
||||||
extern std::vector<std::string> lightlevel;
|
extern std::vector<std::string> lightlevel;
|
||||||
|
|
||||||
|
|
@ -35,6 +36,8 @@ struct game:public enginend::scene {
|
||||||
entity skaile{10,3};
|
entity skaile{10,3};
|
||||||
entity player{0,1};
|
entity player{0,1};
|
||||||
Texture2D current;
|
Texture2D current;
|
||||||
|
bool canseeuycatroz=false;
|
||||||
|
bool canseeskaile=false;
|
||||||
void boot() final {
|
void boot() final {
|
||||||
mappath=AT("res/map");
|
mappath=AT("res/map");
|
||||||
this->nodes={
|
this->nodes={
|
||||||
|
|
@ -46,6 +49,7 @@ struct game:public enginend::scene {
|
||||||
}
|
}
|
||||||
void tick() final {
|
void tick() final {
|
||||||
bool changed=false;
|
bool changed=false;
|
||||||
|
bool updateview=false;
|
||||||
if (stamina>=1.){
|
if (stamina>=1.){
|
||||||
if (ifforward()){player.pos=moveentity(player.pos,player.dir,false);changed=true;}
|
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 (ifbackward()){player.pos=moveentity(player.pos,player.dir,true);changed=true;}
|
||||||
|
|
@ -55,17 +59,28 @@ struct game:public enginend::scene {
|
||||||
UnloadTexture(current);
|
UnloadTexture(current);
|
||||||
std::string newpath=AT((mappath+"/"+lightlevel[lightmode]+"/"+sides[player.dir]+"/"+std::to_string(player.pos)+".jpg"));
|
std::string newpath=AT((mappath+"/"+lightlevel[lightmode]+"/"+sides[player.dir]+"/"+std::to_string(player.pos)+".jpg"));
|
||||||
current=LOADMAP
|
current=LOADMAP
|
||||||
tiny::success((char*)newpath.c_str());
|
//tiny::success((char*)newpath.c_str());
|
||||||
|
updateview=true;
|
||||||
|
}
|
||||||
|
if (updateview) {
|
||||||
|
canseeuycatroz=cansee(uycatroz.pos,player.pos,player.dir);
|
||||||
|
canseeskaile=cansee(skaile.pos,player.pos,player.dir);
|
||||||
}
|
}
|
||||||
}else stamina+=.01;
|
}else stamina+=.01;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void draw() final {
|
void draw() final {
|
||||||
int screenw=GetScreenWidth();int screenh=GetScreenHeight();
|
float screenw=(float)GetScreenWidth();float screenh=(float)GetScreenHeight();
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(rl::WHITE);
|
ClearBackground(rl::WHITE);
|
||||||
DrawTexturePro(current,{0,0,480,280},{0,0,(float)screenw,(float)screenh},{0,0},0,rl::WHITE);
|
DrawTexturePro(current,{0,0,480,280},{0,0,screenw,screenh},{0,0},0,rl::WHITE);
|
||||||
|
if (canseeuycatroz)DrawRectangle(
|
||||||
|
screenw/10.,screenh/10.,screenw/12,screenh/1.5,rl::BLUE);
|
||||||
|
if (canseeskaile)DrawRectangle(
|
||||||
|
screenw/2.,screenh/10.,screenw/12,screenh/1.5,rl::RED);
|
||||||
|
DrawText(("pos: "+std::to_string(player.pos)+" dir:"+std::to_string(player.dir)).c_str(),0,0,64,rl::WHITE);
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -24,6 +24,35 @@ std::vector<std::vector<char>> map{
|
||||||
{11,N,N,15},{N,N,14,16},{13,N,15,N}
|
{11,N,N,15},{N,N,14,16},{13,N,15,N}
|
||||||
};
|
};
|
||||||
#undef N
|
#undef N
|
||||||
|
std::vector<std::vector<std::vector<char>>> visibilitychart{
|
||||||
|
|
||||||
|
{{},{7,8,11,14},{},{1,2,8}},//0
|
||||||
|
{{},{7,8,11},{0,7},{2}},
|
||||||
|
{{},{3,4},{0,7},{}},//2
|
||||||
|
{{2},{4,5},{5,6,9,10},{}},
|
||||||
|
{{2,3},{},{5,6,10},{}},//4
|
||||||
|
{{3,9,10},{},{6},{4}},
|
||||||
|
{{9,10},{},{},{5,4,3}},//6
|
||||||
|
{{0,1},{11,14},{},{1,2,8}},
|
||||||
|
{{0,1},{13},{7,1},{}},//8
|
||||||
|
{{},{6,10},{3,4,5,6},{}},
|
||||||
|
{{},{5,6},{},{3,5,9}},//10
|
||||||
|
{{0,7},{14},{},{12}},
|
||||||
|
{{},{},{11},{}},//12
|
||||||
|
{{0,1,8},{},{16},{}},
|
||||||
|
{{0,7,11},{},{},{15,16}},//14
|
||||||
|
{{},{},{14},{16}},
|
||||||
|
{{13},{},{14,15},{}}//16
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
bool cansee(char dest,char pos, char dir) {
|
||||||
|
std::vector<char> check=visibilitychart[pos][dir];
|
||||||
|
for (char i: check) {
|
||||||
|
if (dest==i)return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char moveentity(char pos,char dir,bool backwards) {
|
char moveentity(char pos,char dir,bool backwards) {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ set_target_properties(pretend PROPERTIES
|
||||||
target_link_directories(
|
target_link_directories(
|
||||||
pretend PUBLIC
|
pretend PUBLIC
|
||||||
"${CMAKE_SOURCE_DIR}/link")
|
"${CMAKE_SOURCE_DIR}/link")
|
||||||
|
|
||||||
target_link_libraries(pretend PRIVATE
|
target_link_libraries(pretend PRIVATE
|
||||||
enginend
|
enginend
|
||||||
raylib
|
raylib
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
//
|
|
||||||
// Created by komi on 2/23/26.
|
|
||||||
//
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue