Raycaster now keeps track of the square we are aimed but _does not_ know what is there, that's the job of other things like MainUI. Closes #50.
This commit is contained in:
parent
0d79ce35b3
commit
8bbafc4d10
4 changed files with 15 additions and 12 deletions
|
@ -14,6 +14,7 @@ constexpr const int RAY_VIEW_X=(SCREEN_WIDTH - RAY_VIEW_WIDTH);
|
|||
constexpr const int RAY_VIEW_Y=0;
|
||||
constexpr const int GLOW_LIMIT=220;
|
||||
constexpr const int LIGHT_MULTIPLIER=2.5;
|
||||
constexpr const float AIMED_AT_BRIGHTNESS=0.2f;
|
||||
|
||||
constexpr const int BOSS_VIEW_WIDTH=1080;
|
||||
constexpr const int BOSS_VIEW_HEIGHT=SCREEN_HEIGHT;
|
||||
|
|
|
@ -31,10 +31,8 @@ namespace gui {
|
|||
}
|
||||
|
||||
DinkyECS::Entity MainUI::camera_aim() {
|
||||
auto aimed_at = $rayview.aimed_at();
|
||||
|
||||
if($level.collision->occupied(aimed_at)) {
|
||||
return $level.collision->get(aimed_at);
|
||||
if($level.collision->occupied($rayview.aiming_at)) {
|
||||
return $level.collision->get($rayview.aiming_at);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -204,7 +204,7 @@ void Raycaster::sprite_casting(sf::RenderTarget &target) {
|
|||
apply_sprite_effect(effect, sprite_width, sprite_height);
|
||||
} else {
|
||||
effect = $brightness;
|
||||
level += (aiming_at == rec.second) * 0.1;
|
||||
level += (aiming_at == sprite_pos.location) * AIMED_AT_BRIGHTNESS;
|
||||
effect->setUniform("darkness", level);
|
||||
}
|
||||
|
||||
|
@ -475,6 +475,8 @@ bool Raycaster::play_rotate() {
|
|||
$plane_x = std::lerp($plane_x, $camera.target_plane_x, $camera.t);
|
||||
$plane_y = std::lerp($plane_y, $camera.target_plane_y, $camera.t);
|
||||
|
||||
aiming_at = { size_t($pos_x + $dir_x), size_t($pos_y + $dir_y) };
|
||||
|
||||
return $camera.t >= 1.0;
|
||||
}
|
||||
|
||||
|
@ -482,19 +484,21 @@ bool Raycaster::play_move() {
|
|||
$camera.t += $camera.move_speed;
|
||||
$pos_x = std::lerp($pos_x, $camera.target_x, $camera.t);
|
||||
$pos_y = std::lerp($pos_y, $camera.target_y, $camera.t);
|
||||
|
||||
aiming_at = { size_t($pos_x + $dir_x), size_t($pos_y + $dir_y) };
|
||||
|
||||
return $camera.t >= 1.0;
|
||||
}
|
||||
|
||||
void Raycaster::abort_plan() {
|
||||
$camera.target_x = $pos_x;
|
||||
$camera.target_y = $pos_y;
|
||||
aiming_at = { size_t($pos_x + $dir_x), size_t($pos_y + $dir_y) };
|
||||
}
|
||||
|
||||
Point Raycaster::aimed_at() {
|
||||
return {
|
||||
size_t($pos_x + $dir_x),
|
||||
size_t($pos_y + $dir_y)
|
||||
};
|
||||
bool Raycaster::is_target(DinkyECS::Entity entity) {
|
||||
(void)entity;
|
||||
return false;
|
||||
}
|
||||
|
||||
Point Raycaster::camera_target() {
|
||||
|
|
|
@ -26,7 +26,7 @@ struct Raycaster {
|
|||
double $plane_y = 0.66;
|
||||
sf::Texture $view_texture;
|
||||
sf::Sprite $view_sprite;
|
||||
DinkyECS::Entity aiming_at = 0;
|
||||
Point aiming_at{0,0};
|
||||
CameraLOL $camera;
|
||||
|
||||
std::unique_ptr<RGBA[]> $pixels = nullptr;
|
||||
|
@ -72,6 +72,6 @@ struct Raycaster {
|
|||
bool play_move();
|
||||
|
||||
void abort_plan();
|
||||
Point aimed_at();
|
||||
bool is_target(DinkyECS::Entity entity);
|
||||
Point camera_target();
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue