Compare commits
2 Commits
22cd090f92
...
f78e71f96b
Author | SHA1 | Date | |
---|---|---|---|
f78e71f96b | |||
5a51a375a4 |
@ -10,6 +10,8 @@ static bool init = false;
|
|||||||
static unsigned int width;
|
static unsigned int width;
|
||||||
static unsigned int height;
|
static unsigned int height;
|
||||||
|
|
||||||
|
static sf::Image image;
|
||||||
|
|
||||||
int firstperson_init(unsigned int _width, unsigned int _height)
|
int firstperson_init(unsigned int _width, unsigned int _height)
|
||||||
{
|
{
|
||||||
printf("firstperson_init()\n");
|
printf("firstperson_init()\n");
|
||||||
@ -17,6 +19,9 @@ int firstperson_init(unsigned int _width, unsigned int _height)
|
|||||||
width = _width;
|
width = _width;
|
||||||
height = _height;
|
height = _height;
|
||||||
init = true;
|
init = true;
|
||||||
|
|
||||||
|
if (!image.loadFromFile("xd.bmp")) return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,11 +75,17 @@ void firstperson_update(sf::RenderTarget* renderTarget, Camera* camera)
|
|||||||
renderTexture.draw(rectangle);
|
renderTexture.draw(rectangle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sf::Texture imageTexture;
|
||||||
|
sf::Sprite imageSprite;
|
||||||
|
imageTexture.loadFromImage(image);
|
||||||
|
imageSprite.setTexture(imageTexture);
|
||||||
|
renderTexture.draw(imageSprite);
|
||||||
|
|
||||||
renderTexture.display();
|
renderTexture.display();
|
||||||
sf::Sprite sprite(renderTexture.getTexture());
|
sf::Sprite sprite(renderTexture.getTexture());
|
||||||
sprite.setPosition(renderTexturePosition);
|
sprite.setPosition(renderTexturePosition);
|
||||||
renderTarget->draw(sprite);
|
|
||||||
|
|
||||||
|
renderTarget->draw(sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
void firstperson_setTexturePosition(float x, float y)
|
void firstperson_setTexturePosition(float x, float y)
|
||||||
|
@ -130,6 +130,7 @@ static float castRay(sf::Vector2f point, float direction, TileData* tileData)
|
|||||||
if (gridValue) {
|
if (gridValue) {
|
||||||
tileData->value = gridValue;
|
tileData->value = gridValue;
|
||||||
tileData->side = goingDown? NORTH : SOUTH;
|
tileData->side = goingDown? NORTH : SOUTH;
|
||||||
|
tileData->horizontalUV = 0.f;
|
||||||
return horizontalRayDist;
|
return horizontalRayDist;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,6 +144,7 @@ static float castRay(sf::Vector2f point, float direction, TileData* tileData)
|
|||||||
if (gridValue) {
|
if (gridValue) {
|
||||||
tileData->value = gridValue;
|
tileData->value = gridValue;
|
||||||
tileData->side = goingRight? WEST : EAST;
|
tileData->side = goingRight? WEST : EAST;
|
||||||
|
tileData->horizontalUV = 0.f;
|
||||||
return verticalRayDist;
|
return verticalRayDist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
level.h
1
level.h
@ -15,6 +15,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
unsigned int value;
|
unsigned int value;
|
||||||
level_tileSide side;
|
level_tileSide side;
|
||||||
|
float horizontalUV;
|
||||||
} TileData;
|
} TileData;
|
||||||
|
|
||||||
int level_init();
|
int level_init();
|
||||||
|
6
view.cpp
6
view.cpp
@ -7,7 +7,7 @@
|
|||||||
#include "minimap.h"
|
#include "minimap.h"
|
||||||
#include "firstperson.h"
|
#include "firstperson.h"
|
||||||
|
|
||||||
#define MINIMAP_SIZE 480
|
#define MINIMAP_SIZE 512
|
||||||
#define VIEW_SIZE MINIMAP_SIZE*2
|
#define VIEW_SIZE MINIMAP_SIZE*2
|
||||||
|
|
||||||
static int handleKeyCode(sf::Keyboard::Key key);
|
static int handleKeyCode(sf::Keyboard::Key key);
|
||||||
@ -21,12 +21,13 @@ static sf::Clock timer;
|
|||||||
int view_init()
|
int view_init()
|
||||||
{
|
{
|
||||||
printf("view_init()\n");
|
printf("view_init()\n");
|
||||||
if (!camera_init(&camera, sf::Vector2f(10.f/2.f, 10.f/2.f), 0.f, 2<<7, 0.5f*PI)) return 0;
|
if (!camera_init(&camera, sf::Vector2f(10.f/2.f, 10.f/2.f), 0.f, VIEW_SIZE, 0.5f*PI)) return 0;
|
||||||
if (!minimap_init(MINIMAP_SIZE)) return 0;
|
if (!minimap_init(MINIMAP_SIZE)) return 0;
|
||||||
if (!firstperson_init(VIEW_SIZE, MINIMAP_SIZE)) return 0;
|
if (!firstperson_init(VIEW_SIZE, MINIMAP_SIZE)) return 0;
|
||||||
|
|
||||||
minimap_setTexturePosition(0.f, 0.f);
|
minimap_setTexturePosition(0.f, 0.f);
|
||||||
firstperson_setTexturePosition(MINIMAP_SIZE, 0.f);
|
firstperson_setTexturePosition(MINIMAP_SIZE, 0.f);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +55,7 @@ int view_update()
|
|||||||
window.clear();
|
window.clear();
|
||||||
minimap_update(&window, &camera);
|
minimap_update(&window, &camera);
|
||||||
firstperson_update(&window, &camera);
|
firstperson_update(&window, &camera);
|
||||||
|
|
||||||
window.display();
|
window.display();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user