allgames/games/animatronical/q1/a1/src/scenes/scenes.cpp
2026-02-23 21:13:51 -03:00

111 lines
2.3 KiB
C++

#include "game.h"
// 0 1 2 3 4 5 6
// 7 8 9 10
// 11 12 13
// 14 15 16
// N S L R
std::vector<char>opposites{1,0,3,2};
std::vector<char> sides{
'n','s','l','r'
};
std::vector<std::string> lightlevel{
"off","on","urcooked"
};
#define N (-1)
std::vector<std::vector<char>> map{
// 0 1 2 3 4 5 6
{N,7,N,1} ,{N,8,0,2} , {N,3,1,N} ,{2,4,N,N},{3,N,5,N}, {9,N,6,4},{10,N,N,5},
// 7 8 9 10
{0,11,N,8} ,{1,13,7,N}, {N,5,10,N},{N,6,N,9},
// 11 12 13
{7,14,N,12},{N,N,11,N}, {8,16,N,N},
// 14 15 16
{11,N,N,15},{N,N,14,16},{13,N,15,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 tmpos=-1;
if (backwards)tmpos= map[pos][opposites[dir]];
else tmpos=map[pos][dir];
if (tmpos==-1) return pos;
return tmpos;
}
std::vector<std::vector<char>> look={
{3,2,0,1},
{2,3,1,0},
{1,0}
};
char rotateentity(char pos,char dir, bool clockwise) {
if (pos==13) {
return look[2][dir];
}
return look[!clockwise][dir];
}
bool ifforward() {
if (IsKeyPressed(KEY_W))return true;
if (IsKeyPressed(KEY_UP))return true;
if (IsKeyPressed(KEY_KP_8))return true;
return false;
}
bool ifbackward() {
if (IsKeyPressed(KEY_S))return true;
if (IsKeyPressed(KEY_DOWN))return true;
if (IsKeyPressed(KEY_KP_2))return true;
return false;
}
bool ifleft() {
if (IsKeyPressed(KEY_A))return true;
if (IsKeyPressed(KEY_LEFT))return true;
if (IsKeyPressed(KEY_KP_4))return true;
return false;
}
bool ifright(){
if (IsKeyPressed(KEY_D))return true;
if (IsKeyPressed(KEY_RIGHT))return true;
if (IsKeyPressed(KEY_KP_6))return true;
return false;
}