Added game like activity

This commit is contained in:
andreistr21 2022-02-10 22:57:13 +01:00
parent beff497f0e
commit 51cd9cfebb
11 changed files with 1230195 additions and 0 deletions

File diff suppressed because it is too large Load Diff

BIN
cw 6/models/Coin.fbx Normal file

Binary file not shown.

401573
cw 6/models/STONE3.obj Normal file

File diff suppressed because it is too large Load Diff

636422
cw 6/models/SfM03_03.obj Normal file

File diff suppressed because it is too large Load Diff

9735
cw 6/models/bubbles.obj Normal file

File diff suppressed because it is too large Load Diff

1395
cw 6/models/fishModel2.obj Normal file

File diff suppressed because it is too large Load Diff

18
cw 6/models/plane.obj Normal file
View File

@ -0,0 +1,18 @@
v 0 -100 -100
v 0 -100 100
v 0 100 -100
v 0 100 100
vt 0 0
vt 20 0
vt 0 20
vt 20 20
vn 0 1 0
s off
f 1/3/1 3/1/1 4/2/1
f 1/3/1 4/2/1 2/4/1
f 1/3/1 4/2/1 3/1/1
f 1/3/1 2/4/1 4/2/1

View File

@ -74,6 +74,7 @@ Core::RenderContext Coral1Context;
Core::RenderContext Coral2Context;
Core::RenderContext bubbleContext;
Core::RenderContext coinContext;
glm::vec3 cameraPos = glm::vec3(0, 0, 0);
glm::vec3 cameraDir; // Wektor "do przodu" kamery
@ -102,6 +103,7 @@ GLuint Coral1Texture;
GLuint Coral2Texture;
GLuint bubbleTexture;
GLuint coinTexture;
obj::Model planeModel;
@ -142,6 +144,10 @@ float vehicleAngleSpeed = 0.0f;
float vehicleVerticalSpeed = 0.0f;
bool directionChanged = false;
glm::vec3 starLocation;
bool starIsPlaced = false;
void keyboard(unsigned char key, int x, int y)
{
@ -462,6 +468,56 @@ void drawLightLocation()
glPopMatrix();
}
void checkIfStarIsNearby() {
bool xDone = false;
bool yDone = false;
bool zDone = false;
if (vehiclePos.x < starLocation.x + 2 && vehiclePos.x > starLocation.x - 2)
{
xDone = true;
}
if (vehiclePos.y < starLocation.y + 2 && vehiclePos.y > starLocation.y - 2)
{
yDone = true;
}
if (vehiclePos.z < starLocation.z + 2 && vehiclePos.z > starLocation.z - 2)
{
zDone = true;
}
if (xDone && yDone && zDone)
{
starIsPlaced = false;
}
}
void gameManager() {
checkIfStarIsNearby();
if (!starIsPlaced)
{
starLocation.x = (((float)rand() / (float)(RAND_MAX)) * 10) - 6;
starLocation.y = (((float)rand() / (float)(RAND_MAX)) * 10) - 6;
starLocation.z = (((float)rand() / (float)(RAND_MAX)) * 10) - 6;
starIsPlaced = true;
printf("starplaced");
}
glm::mat4 shipInitialTransformation = glm::translate(glm::vec3(0, -0.2, -0.05));
glm::vec3 shipScale = glm::vec3(1., 1., 1.);
shipInitialTransformation = glm::scale(shipInitialTransformation, shipScale);
shipInitialTransformation = shipInitialTransformation * glm::translate(glm::vec3(0, 0, 0)) * glm::scale(glm::vec3(0.1f));
glm::mat4 shipModelMatrix = glm::translate(starLocation /* + vehicleDir */) * glm::rotate(-vehicleAngle + 30, glm::vec3(0, 1, 0)) * shipInitialTransformation;
drawObjectTexture(coinContext, shipModelMatrix, coinTexture);
}
void drawScene()
{
glm::mat4 shipInitialTransformation = glm::translate(glm::vec3(0, -0.2, -0.05));
@ -482,6 +538,7 @@ void drawScene()
drawObjectTexture(fish1Context, modelMatrix, textureFish01);
bubbleManager();
gameManager();
for (int i = 0; i < fish1Number; i++)
{
@ -911,6 +968,9 @@ void init()
loadModelToContext("models/sphere_different_texcoords.obj", bubbleContext);
bubbleTexture = Core::LoadTexture("textures/white_2.png");
loadModelToContext("models/Coin.fbx", coinContext);
coinTexture = Core::LoadTexture("textures/Coin.png");
for (int i = 0; i < fish1Number; i++)

BIN
cw 6/textures/Coin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

BIN
cw 6/textures/white.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
cw 6/textures/white_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B