More cleanup, mostly removing variables and simplifying the math.
This commit is contained in:
parent
113df851af
commit
033d5cdfec
3 changed files with 41 additions and 51 deletions
39
main.cpp
39
main.cpp
|
@ -3,30 +3,30 @@
|
|||
static const int SCREEN_HEIGHT=720;
|
||||
static const int SCREEN_WIDTH=1280;
|
||||
|
||||
Matrix MAP{{8,8,8,8,8,8,8,8,8},
|
||||
{8,0,2,0,0,0,0,0,8},
|
||||
{8,0,7,0,0,5,6,0,8},
|
||||
{8,0,0,0,0,0,0,0,8},
|
||||
{8,8,0,0,0,0,0,8,8},
|
||||
{8,0,0,1,3,4,0,0,8},
|
||||
{8,0,0,0,0,0,8,8,8},
|
||||
{8,0,0,0,0,0,0,0,8},
|
||||
{8,8,8,8,8,8,8,8,8}
|
||||
};
|
||||
Matrix MAP{
|
||||
{8,8,8,8,8,8,8,8,8},
|
||||
{8,0,2,0,0,0,0,0,8},
|
||||
{8,0,7,0,0,5,6,0,8},
|
||||
{8,0,0,0,0,0,0,0,8},
|
||||
{8,8,0,0,0,0,0,8,8},
|
||||
{8,0,0,1,3,4,0,0,8},
|
||||
{8,0,0,0,0,0,8,8,8},
|
||||
{8,0,0,0,0,0,0,0,8},
|
||||
{8,8,8,8,8,8,8,8,8}
|
||||
};
|
||||
|
||||
int main() {
|
||||
using KB = sf::Keyboard;
|
||||
|
||||
sf::RenderWindow window(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT), "Zed's Ray Caster Game Thing");
|
||||
|
||||
int TILE_SIZE = RAY_VIEW_HEIGHT / matrix::width(MAP);
|
||||
|
||||
//ZED this should set with a function
|
||||
float player_x = RAY_VIEW_HEIGHT / 2;
|
||||
float player_y = RAY_VIEW_HEIGHT / 2;
|
||||
float player_x = matrix::width(MAP) / 2;
|
||||
float player_y = matrix::height(MAP) / 2;
|
||||
|
||||
Raycaster rayview(window, MAP);
|
||||
rayview.position_camera(player_x, player_y, TILE_SIZE);
|
||||
|
||||
rayview.position_camera(player_x, player_y);
|
||||
|
||||
double moveSpeed = 0.1;
|
||||
double rotSpeed = 0.1;
|
||||
|
@ -37,15 +37,15 @@ int main() {
|
|||
window.display();
|
||||
|
||||
if(KB::isKeyPressed(KB::W)) {
|
||||
rayview.move_forward(moveSpeed);
|
||||
rayview.run(moveSpeed, 1);
|
||||
} else if(KB::isKeyPressed(KB::S)) {
|
||||
rayview.move_backward(moveSpeed);
|
||||
rayview.run(moveSpeed, -1);
|
||||
}
|
||||
|
||||
if(KB::isKeyPressed(KB::D)) {
|
||||
rayview.rotate_right(rotSpeed);
|
||||
rayview.rotate(rotSpeed, -1);
|
||||
} else if(KB::isKeyPressed(KB::A)) {
|
||||
rayview.rotate_left(rotSpeed);
|
||||
rayview.rotate(rotSpeed, 1);
|
||||
}
|
||||
|
||||
sf::Event event;
|
||||
|
@ -54,7 +54,6 @@ int main() {
|
|||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue