Refactored the CameraLOL to be inside the rayview instead of a convolute main_ui->camera->rayview and back. Closes #16.
This commit is contained in:
parent
75c28cd764
commit
ab1a415b55
7 changed files with 83 additions and 89 deletions
|
@ -9,8 +9,7 @@ namespace gui {
|
|||
|
||||
MainUI::MainUI(sf::RenderWindow& window) :
|
||||
$window(window),
|
||||
$rayview(RAY_VIEW_WIDTH, RAY_VIEW_HEIGHT),
|
||||
$camera($rayview)
|
||||
$rayview(RAY_VIEW_WIDTH, RAY_VIEW_HEIGHT)
|
||||
{
|
||||
$window.setVerticalSyncEnabled(VSYNC);
|
||||
$window.setFramerateLimit(FRAME_LIMIT);
|
||||
|
@ -32,7 +31,7 @@ namespace gui {
|
|||
}
|
||||
|
||||
DinkyECS::Entity MainUI::camera_aim() {
|
||||
auto aimed_at = $camera.aimed_at();
|
||||
auto aimed_at = $rayview.aimed_at();
|
||||
|
||||
if($level.collision->occupied(aimed_at)) {
|
||||
return $level.collision->get(aimed_at);
|
||||
|
@ -42,7 +41,6 @@ namespace gui {
|
|||
}
|
||||
|
||||
void MainUI::render() {
|
||||
$rayview.aiming_at = camera_aim();
|
||||
if($needs_render) $rayview.render();
|
||||
$rayview.draw($window);
|
||||
|
||||
|
@ -59,20 +57,17 @@ namespace gui {
|
|||
}
|
||||
|
||||
bool MainUI::play_rotate() {
|
||||
bool done = $camera.play_rotate();
|
||||
bool done = $rayview.play_rotate();
|
||||
$needs_render = !done;
|
||||
|
||||
return done;
|
||||
}
|
||||
|
||||
// this could be an optional that returs a Point
|
||||
std::optional<Point> MainUI::play_move() {
|
||||
if($camera.play_move()) {
|
||||
if($rayview.play_move()) {
|
||||
$needs_render = false;
|
||||
Point pos{
|
||||
size_t($camera.target_x),
|
||||
size_t($camera.target_y)};
|
||||
return std::make_optional<Point>(pos);
|
||||
return std::make_optional<Point>(
|
||||
$rayview.camera_target());
|
||||
} else {
|
||||
$needs_render = true;
|
||||
return std::nullopt;
|
||||
|
@ -83,15 +78,15 @@ namespace gui {
|
|||
// -1 is left, 1 is right
|
||||
int extra = (amount == 0.5) * dir;
|
||||
$compass_dir = ($compass_dir + dir + extra) % COMPASS.size();
|
||||
$camera.plan_rotate(dir, amount);
|
||||
$rayview.plan_rotate(dir, amount);
|
||||
}
|
||||
|
||||
Point MainUI::plan_move(int dir, bool strafe) {
|
||||
return $camera.plan_move(dir, strafe);
|
||||
return $rayview.plan_move(dir, strafe);
|
||||
}
|
||||
|
||||
void MainUI::abort_plan() {
|
||||
$camera.abort_plan();
|
||||
$rayview.abort_plan();
|
||||
}
|
||||
|
||||
void MainUI::dead_entity(DinkyECS::Entity entity) {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "gui/overlay_ui.hpp"
|
||||
#include "gui/debug_ui.hpp"
|
||||
#include "raycaster.hpp"
|
||||
#include "camera.hpp"
|
||||
#include <optional>
|
||||
|
||||
namespace gui {
|
||||
|
@ -21,7 +20,6 @@ namespace gui {
|
|||
GameLevel $level;
|
||||
OverlayUI $overlay_ui;
|
||||
Raycaster $rayview;
|
||||
CameraLOL $camera;
|
||||
|
||||
MainUI(sf::RenderWindow& window);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue