This converts it to SFML 3.0 but the build only runs on Windows at the moment.
This commit is contained in:
parent
cdbd83ded7
commit
105c974f1c
7 changed files with 62 additions and 630 deletions
|
@ -28,6 +28,8 @@ inline uint32_t dumb_lighting(uint32_t pixel, double distance) {
|
|||
|
||||
|
||||
Raycaster::Raycaster(sf::RenderWindow& window, Matrix &map, int width, int height) :
|
||||
view_texture({(unsigned int)width, (unsigned int)height}),
|
||||
view_sprite(view_texture),
|
||||
$width(width), $height(height),
|
||||
$window(window),
|
||||
$map(map),
|
||||
|
@ -36,15 +38,13 @@ Raycaster::Raycaster(sf::RenderWindow& window, Matrix &map, int width, int heigh
|
|||
ZBuffer(width)
|
||||
{
|
||||
$window.setVerticalSyncEnabled(true);
|
||||
view_texture.create($width, $height);
|
||||
view_sprite.setTexture(view_texture);
|
||||
view_sprite.setPosition(0, 0);
|
||||
view_sprite.setPosition({0, 0});
|
||||
pixels = make_unique<RGBA[]>($width * $height);
|
||||
textures.load_textures();
|
||||
}
|
||||
|
||||
void Raycaster::set_position(int x, int y) {
|
||||
view_sprite.setPosition(x, y);
|
||||
view_sprite.setPosition({(float)x, (float)y});
|
||||
}
|
||||
|
||||
void Raycaster::position_camera(float player_x, float player_y) {
|
||||
|
@ -54,8 +54,7 @@ void Raycaster::position_camera(float player_x, float player_y) {
|
|||
}
|
||||
|
||||
void Raycaster::draw_pixel_buffer() {
|
||||
view_texture.update((uint8_t *)pixels.get(), $width, $height, 0, 0);
|
||||
// BUG: can I do this once and just update it?
|
||||
view_texture.update((uint8_t *)pixels.get(), {(unsigned int)$width, (unsigned int)$height}, {0, 0});
|
||||
$window.draw(view_sprite);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue