2023-03-31 06:49:36 +08:00
|
|
|
#include "view.h"
|
2023-03-31 08:08:02 +08:00
|
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "level.h"
|
2023-03-31 06:49:36 +08:00
|
|
|
|
|
|
|
static sf::Uint32 style = sf::Style::Titlebar;
|
2023-03-31 08:08:02 +08:00
|
|
|
static sf::RenderWindow window(sf::VideoMode(500, 500), "Raycasting", style);
|
2023-03-31 06:49:36 +08:00
|
|
|
|
|
|
|
int view_init()
|
|
|
|
{
|
2023-03-31 08:08:02 +08:00
|
|
|
printf("view_init()\n");
|
|
|
|
level_init(&window);
|
2023-03-31 06:49:36 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int view_update()
|
|
|
|
{
|
|
|
|
if (!window.isOpen()) return 0;
|
|
|
|
|
|
|
|
sf::Event event;
|
|
|
|
while (window.pollEvent(event)) {
|
|
|
|
if (event.type == sf::Event::Closed) {
|
|
|
|
window.close();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.clear();
|
2023-03-31 08:08:02 +08:00
|
|
|
if (!level_update()) return 0;
|
2023-03-31 06:49:36 +08:00
|
|
|
window.display();
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2023-03-31 08:08:02 +08:00
|
|
|
void view_end()
|
|
|
|
{
|
|
|
|
printf("view_end()\n");
|
|
|
|
level_end();
|
|
|
|
return;
|
|
|
|
}
|