implementacja zbierania monet

This commit is contained in:
s473595 2024-03-01 09:27:00 +01:00
parent de08ea9744
commit 33015d4029
19 changed files with 1610 additions and 308 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,28 +1,7 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\maksg\\Documents\\Grafika_2024\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.vert||{8B382828-6202-11D1-8870-0000F87579D2}",
"RelativeMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|solutionrelative:projekt_grk\\shaders\\shader_coin.vert||{8B382828-6202-11D1-8870-0000F87579D2}"
},
{
"AbsoluteMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.frag||{8B382828-6202-11D1-8870-0000F87579D2}",
"RelativeMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|solutionrelative:projekt_grk\\shaders\\shader_coin.frag||{8B382828-6202-11D1-8870-0000F87579D2}"
},
{
"AbsoluteMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\src\\ex_7_1.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|solutionrelative:projekt_grk\\src\\ex_7_1.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_5_1_tex_copy.frag||{8B382828-6202-11D1-8870-0000F87579D2}",
"RelativeMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|solutionrelative:projekt_grk\\shaders\\shader_5_1_tex_copy.frag||{8B382828-6202-11D1-8870-0000F87579D2}"
},
{
"AbsoluteMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_5_1_tex_copy.vert||{8B382828-6202-11D1-8870-0000F87579D2}",
"RelativeMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|solutionrelative:projekt_grk\\shaders\\shader_5_1_tex_copy.vert||{8B382828-6202-11D1-8870-0000F87579D2}"
}
],
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
@ -30,76 +9,11 @@
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 2,
"SelectedChildIndex": -1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:128:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}"
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "shader_coin.frag",
"DocumentMoniker": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.frag",
"RelativeDocumentMoniker": "projekt_grk\\shaders\\shader_coin.frag",
"ToolTip": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.frag",
"RelativeToolTip": "projekt_grk\\shaders\\shader_coin.frag",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001001|",
"WhenOpened": "2024-02-29T07:55:43.769Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "shader_coin.vert",
"DocumentMoniker": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.vert",
"RelativeDocumentMoniker": "projekt_grk\\shaders\\shader_coin.vert",
"ToolTip": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_coin.vert",
"RelativeToolTip": "projekt_grk\\shaders\\shader_coin.vert",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAMAAAAqAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001001|",
"WhenOpened": "2024-02-29T07:54:35.741Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 4,
"Title": "shader_5_1_tex_copy.vert",
"DocumentMoniker": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_5_1_tex_copy.vert",
"RelativeDocumentMoniker": "projekt_grk\\shaders\\shader_5_1_tex_copy.vert",
"ToolTip": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_5_1_tex_copy.vert",
"RelativeToolTip": "projekt_grk\\shaders\\shader_5_1_tex_copy.vert",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001001|",
"WhenOpened": "2024-02-29T07:51:18.227Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "ex_7_1.hpp",
"DocumentMoniker": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\src\\ex_7_1.hpp",
"RelativeDocumentMoniker": "projekt_grk\\src\\ex_7_1.hpp",
"ToolTip": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\src\\ex_7_1.hpp",
"RelativeToolTip": "projekt_grk\\src\\ex_7_1.hpp",
"ViewState": "AQIAAIkAAAAAAAAAAAAmwJYAAAA+AAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
"WhenOpened": "2024-02-25T17:55:58.673Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "shader_5_1_tex_copy.frag",
"DocumentMoniker": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_5_1_tex_copy.frag",
"RelativeDocumentMoniker": "projekt_grk\\shaders\\shader_5_1_tex_copy.frag",
"ToolTip": "C:\\Users\\maksg\\Documents\\Grafika_2024\\projekt_grk\\shaders\\shader_5_1_tex_copy.frag",
"RelativeToolTip": "projekt_grk\\shaders\\shader_5_1_tex_copy.frag",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001001|",
"WhenOpened": "2024-02-29T07:37:23.837Z",
"EditorCaption": ""
}
]
}

Binary file not shown.

Binary file not shown.

View File

@ -5,16 +5,16 @@ C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\minwindef.h(1
C:\Users\maksg\Documents\Grafika_2024\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123,1):
zobacz poprzednią definicję „APIENTRY”
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(92,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(109,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
(kompilowanie pliku źródłowego „src/main.cpp”)
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(138,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(155,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
(kompilowanie pliku źródłowego „src/main.cpp”)
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(211,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(255,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
(kompilowanie pliku źródłowego „src/main.cpp”)
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(229,29): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(273,29): warning C4305: "inicjowanie": obcięcie z "double" do "float"
(kompilowanie pliku źródłowego „src/main.cpp”)
Box.obj : warning LNK4075: zignorowano opcję „/EDITANDCONTINUE” z powodu określenia opcji „/INCREMENTAL:NO”

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -68,6 +68,23 @@ GLuint VAO,VBO;
float aspectRatio = 1.f;
unsigned int textureID;
const int maxSize = 30;
int numberOfCollectedCoins = 0;
float xCordinatesOfCoin[maxSize] = {
5.3f, 10.0f, -4.7f, 9.2f, 3.5f, -7.5f, 1.8f, 2.5f, 11.8f, -10.2f,
-4.5f, 6.7f, -6.7f, 5.5f, -0.1f, -9.2f, -6.8f, -9.7f, -12.9f, 5.0f,
12.2f, -7.4f, 2.4f, 12.3f, -4.1f, -5.7f, -5.5f, -3.6f, -2.5f, -7.6f
};
float zCordinatesOfCoin[maxSize] = {
2.6f, 1.5f, 4.8f, 2.2f, -11.8f, 3.3f, 9.1f, -6.0f, -12.0f, 11.1f,
11.9f, 2.5f, 5.2f, 1.1f, -2.0f, -8.2f, -2.9f, -9.4f, 0.5f, -2.3f,
-1.0f, 1.0f, -4.2f, 7.3f, 10.0f, -12.6f, -5.9f, -2.7f, 12.8f, 2.3f
};
float xCordinatesOfCollectedCoin[maxSize] = {};
float zCordinatesOfCollectedCoin[maxSize] = {};
glm::mat4 createCameraMatrix()
{
@ -153,19 +170,46 @@ void drawCylinder(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3
Core::DrawContext(context);
}
bool checkCoinCollection(glm::vec3 spaceshipPos, glm::vec3 coinPos) {
float collectionDistance = 0.8f;
float distance = glm::length(spaceshipPos - coinPos);
if (distance < collectionDistance) {
return true;
}
return false;
}
void renderCoins() {
float xCordinates[30] = {
5.3f, 10.0f, -4.7f, 9.2f, 3.5f, -7.5f, 1.8f, 2.5f, 11.8f, -10.2f,
-4.5f, 6.7f, -6.7f, 5.5f, -0.1f, -9.2f, -6.8f, -9.7f, -12.9f, 5.0f,
12.2f, -7.4f, 2.4f, 12.3f, -4.1f, -5.7f, -5.5f, -3.6f, -2.5f, -7.6f
};
float zCordinates[30] = {
2.6f, 1.5f, 4.8f, 2.2f, -11.8f, 3.3f, 9.1f, -6.0f, -12.0f, 11.1f,
11.9f, 2.5f, 5.2f, 1.1f, -2.0f, -8.2f, -2.9f, -9.4f, 0.5f, -2.3f,
-1.0f, 1.0f, -4.2f, 7.3f, 10.0f, -12.6f, -5.9f, -2.7f, 12.8f, 2.3f
};
for (int i = 0;i < 30;i++) {
drawCylinder(cylinderContext, glm::translate(glm::vec3(xCordinates[i], 0.0f, zCordinates[i])), glm::vec3(1.0f, 1.0f, 0.0f));
for (int i = 0;i < maxSize;i++) {
bool found = false;
if (checkCoinCollection(spaceshipPos, glm::vec3(xCordinatesOfCoin[i], 0.0f, zCordinatesOfCoin[i]))) {
for (int y = 0; y < numberOfCollectedCoins; y++) {
if (xCordinatesOfCollectedCoin[y] == xCordinatesOfCoin[i] &&
zCordinatesOfCollectedCoin[y] == zCordinatesOfCoin[i]) {
found = true;
break;
}
}
if (!found) {
xCordinatesOfCollectedCoin[numberOfCollectedCoins] = xCordinatesOfCoin[i];
zCordinatesOfCollectedCoin[numberOfCollectedCoins] = zCordinatesOfCoin[i];
numberOfCollectedCoins++;
}
}else{
for (int y = 0; y < numberOfCollectedCoins; y++) {
if (xCordinatesOfCollectedCoin[y] == xCordinatesOfCoin[i] &&
zCordinatesOfCollectedCoin[y] == zCordinatesOfCoin[i]) {
found = true;
break;
}
}
if (!found) {
drawCylinder(cylinderContext, glm::translate(glm::vec3(xCordinatesOfCoin[i], 0.0f, zCordinatesOfCoin[i])), glm::vec3(1.0f, 1.0f, 0.0f));
}
}
}
}