Way better in the structure but still a lot of work to do. However, just by moving variables to better locations, taking things out of loops that don't need to be recalulated, etc. this is already 50% of the CPU/GPU usage as the previous version.
This commit is contained in:
parent
e379bcd5ec
commit
113df851af
3 changed files with 115 additions and 106 deletions
25
main.cpp
25
main.cpp
|
@ -3,19 +3,38 @@
|
|||
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}
|
||||
};
|
||||
|
||||
int main() {
|
||||
using KB = sf::Keyboard;
|
||||
|
||||
sf::RenderWindow window(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT), "Zed's Ray Caster Game Thing");
|
||||
|
||||
Raycaster rayview(window);
|
||||
int TILE_SIZE = RAY_VIEW_HEIGHT / matrix::width(MAP);
|
||||
|
||||
using KB = sf::Keyboard;
|
||||
rayview.load_textures();
|
||||
//ZED this should set with a function
|
||||
float player_x = RAY_VIEW_HEIGHT / 2;
|
||||
float player_y = RAY_VIEW_HEIGHT / 2;
|
||||
|
||||
Raycaster rayview(window, MAP);
|
||||
rayview.position_camera(player_x, player_y, TILE_SIZE);
|
||||
|
||||
double moveSpeed = 0.1;
|
||||
double rotSpeed = 0.1;
|
||||
|
||||
while(window.isOpen()) {
|
||||
rayview.render();
|
||||
// DRAW GUI
|
||||
window.display();
|
||||
|
||||
if(KB::isKeyPressed(KB::W)) {
|
||||
rayview.move_forward(moveSpeed);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue