resolving conflicts

This commit is contained in:
Aleyna Guecuek 2025-12-15 12:47:58 +01:00
commit 683917f564
3 changed files with 69 additions and 29 deletions

View File

@ -27,19 +27,20 @@ target_include_directories(Prog3B PRIVATE
${CMAKE_CURRENT_LIST_DIR}/includes
${CMAKE_CURRENT_LIST_DIR}/raylib
)
target_link_libraries(${EXECUTABLE_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/mac_x86/libgamematrix.a
raylib
#${CMAKE_CURRENT_LIST_DIR}/windows/libgamematrix.a
${CMAKE_CURRENT_LIST_DIR}/windows/libraylib.a
opengl32
gdi32
m
winmm
)
# Checks if OSX and links appropriate frameworks (Only required on MacOS)
if (APPLE)
target_link_libraries(Prog3B PRIVATE "-framework IOKit"
"-framework Cocoa"
"-framework OpenGL"
)
target_link_libraries(Prog3B "-framework IOKit")
target_link_libraries(Prog3B "-framework Cocoa")
target_link_libraries(Prog3B "-framework OpenGL")
endif()
add_executable(tests
@ -48,12 +49,15 @@ add_executable(tests
)
target_include_directories(tests PRIVATE ${INCLUDE_DIRS})
target_link_libraries(tests PRIVATE)
target_link_libraries(tests PRIVATE
opengl32
gdi32
winmm
)
#if (APPLE)
#target_link_libraries(Prog3B PRIVATE "-framework IOKit")
#target_link_libraries(Prog3B PRIVATE "-framework Cocoa")
#target_link_libraries(Prog3B PRIVATE "-framework OpenGL")
#endif()
if (APPLE)
target_link_libraries(Prog3B PRIVATE "-framework IOKit")
target_link_libraries(Prog3B PRIVATE "-framework Cocoa")
target_link_libraries(Prog3B PRIVATE "-framework OpenGL")
endif()

View File

@ -1,15 +1,14 @@
#include "gamecube.h"
#include "raylib.h"
#include "gamecube.h"
gamecube::gamecube(const Vec3& pos, Color col)
: position(pos), color(col) {}
void gamecube::Update(float flipSpeed)
{
float dt = GetFrameTime();
if (flippingForward)
{
rotation += flipSpeed * dt;
rotation += flipSpeed;
if (rotation >= 180.0f)
{
rotation = 180.0f;
@ -19,8 +18,7 @@ void gamecube::Update(float flipSpeed)
}
else if (flippingBackward)
{
rotation -= flipSpeed * dt;
rotation -= flipSpeed;
if (rotation <= 0.0f)
{
rotation = 0.0f;
@ -29,3 +27,40 @@ void gamecube::Update(float flipSpeed)
}
}
}
void gamecube::FlipForward() { flippingForward = true; }
void gamecube::FlipBackward() { flippingBackward = true; }
bool gamecube::IsFlipped() const { return flipped; }
bool gamecube::IsMatched() const { return matched; }
void gamecube::SetMatched(bool m) { matched = m; }
void gamecube::Draw() const
{
rlPushMatrix();
auto matrix_a = Matrix3D::gameMatrix::translate(
{ position.x, position.y, position.z }
);
auto matrix_b = Matrix3D::gameMatrix::rot3D(rotation, 'y');
auto model = Matrix3D::gameMatrix::matmul(matrix_a, matrix_b);
float f[16];
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
f[j * 4 + i] = model[i][j];
rlMultMatrixf(f);
if (rotation < 90.0f)
DrawCube({ 0, 0, 0 }, 1, 1, 1, GRAY);
else
DrawCube({ 0, 0, 0 }, 1, 1, 1, color);
DrawCubeWires({ 0, 0, 0 }, 1, 1, 1, BLACK);
rlPopMatrix();
}
Vec3 gamecube::GetPosition() const { return position; }
float gamecube::GetRotationY() const { return rotation; }

View File

@ -1,3 +1,4 @@
//
// Created by bakee on 03.11.2025.
//
#include "gamematrix.h"
@ -55,16 +56,16 @@ namespace Matrix3D
switch (axis)
{
case 'x':
result[1][1] = c; result[1][2] = -s;
result[2][1] = s; result[2][2] = c;
result[1][1] = c; result[1][2] = -s;
result[2][1] = s; result[2][2] = c;
break;
case 'y':
result[0][0] = c; result[0][2] = s;
result[0][0] = c; result[0][2] = s;
result[2][0] = -s; result[2][2] = c;
break;
case 'z':
result[0][0] = c; result[0][1] = -s;
result[1][0] = s; result[1][1] = c;
result[0][0] = c; result[0][1] = -s;
result[1][0] = s; result[1][1] = c;
break;
default:
break;
@ -79,7 +80,7 @@ namespace Matrix3D
Vec3 operator*(const Mat4& m, const Vec3& v)
{
Vec4 v_hom = {v[0], v[1], v[2], 1.0};
Vec4 v_hom = { v[0], v[1], v[2], 1.0 };
Vec4 res_hom = {};
for (int i = 0; i < 4; ++i)
@ -90,6 +91,6 @@ namespace Matrix3D
}
}
return {res_hom[0], res_hom[1], res_hom[2]};
return { res_hom[0], res_hom[1], res_hom[2] };
}
}