From f78e71f96b103bafeb3c1201c43bee2e13b70bea Mon Sep 17 00:00:00 2001 From: Sheldon Lee Date: Mon, 15 Jan 2024 18:35:35 +0800 Subject: [PATCH] Start on texturing --- firstperson.cpp | 13 ++++++++++++- level.cpp | 2 ++ level.h | 1 + xd.bmp | Bin 0 -> 3210 bytes 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 xd.bmp diff --git a/firstperson.cpp b/firstperson.cpp index 0fef513..d01ec03 100644 --- a/firstperson.cpp +++ b/firstperson.cpp @@ -10,6 +10,8 @@ static bool init = false; static unsigned int width; static unsigned int height; +static sf::Image image; + int firstperson_init(unsigned int _width, unsigned int _height) { printf("firstperson_init()\n"); @@ -17,6 +19,9 @@ int firstperson_init(unsigned int _width, unsigned int _height) width = _width; height = _height; init = true; + + if (!image.loadFromFile("xd.bmp")) return 0; + return 1; } @@ -70,11 +75,17 @@ void firstperson_update(sf::RenderTarget* renderTarget, Camera* camera) renderTexture.draw(rectangle); } + sf::Texture imageTexture; + sf::Sprite imageSprite; + imageTexture.loadFromImage(image); + imageSprite.setTexture(imageTexture); + renderTexture.draw(imageSprite); + renderTexture.display(); sf::Sprite sprite(renderTexture.getTexture()); sprite.setPosition(renderTexturePosition); - renderTarget->draw(sprite); + renderTarget->draw(sprite); } void firstperson_setTexturePosition(float x, float y) diff --git a/level.cpp b/level.cpp index e0f1c45..338be90 100644 --- a/level.cpp +++ b/level.cpp @@ -130,6 +130,7 @@ static float castRay(sf::Vector2f point, float direction, TileData* tileData) if (gridValue) { tileData->value = gridValue; tileData->side = goingDown? NORTH : SOUTH; + tileData->horizontalUV = 0.f; return horizontalRayDist; } @@ -143,6 +144,7 @@ static float castRay(sf::Vector2f point, float direction, TileData* tileData) if (gridValue) { tileData->value = gridValue; tileData->side = goingRight? WEST : EAST; + tileData->horizontalUV = 0.f; return verticalRayDist; } diff --git a/level.h b/level.h index 8e2ec8c..09c1745 100644 --- a/level.h +++ b/level.h @@ -15,6 +15,7 @@ typedef struct { unsigned int value; level_tileSide side; + float horizontalUV; } TileData; int level_init(); diff --git a/xd.bmp b/xd.bmp new file mode 100644 index 0000000000000000000000000000000000000000..f7cf171b2f9c5d058346046deb141c943eec10f0 GIT binary patch literal 3210 zcmeH`F%H5&3S%=MiaA(eM>oUXV`*lMQBNo3lmBopRCMdb}4|%6Od*!@6d9 zKV+Y_y&I0AWJ&#e!G`gAFYjly#_4wd)M{#Pu%)j)fxn*sev0B41TK<_=})IlLns`I zcH_4yqDGi(U&S$Xgk7vhyr0LG_?hpdThgCH8eF40!&JVKxq1W!BR2= zLeu2Sv4RO>Fz@(egx5(sumSchqi bMlP}D%v6V$q6?)4kcM}lPoPiWw+TD}066{? literal 0 HcmV?d00001