Merge conflicts resolved, ready to push
This commit is contained in:
commit
27703fb6a3
@ -1,4 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
<<<<<<< HEAD
|
||||
project(Programmieren_3b LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
@ -9,11 +10,23 @@ include(FetchContent)
|
||||
# -----------------------------
|
||||
# Raylib
|
||||
# -----------------------------
|
||||
=======
|
||||
project(Prog3B)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
# WICHTIG: wegen raylib + neuer CMake-Version
|
||||
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
>>>>>>> freund/main
|
||||
FetchContent_Declare(
|
||||
raylib
|
||||
GIT_REPOSITORY https://github.com/raysan5/raylib.git
|
||||
GIT_TAG 5.0
|
||||
)
|
||||
<<<<<<< HEAD
|
||||
FetchContent_MakeAvailable(raylib)
|
||||
|
||||
# -----------------------------
|
||||
@ -30,11 +43,18 @@ FetchContent_MakeAvailable(pybind11)
|
||||
# Executable für das Spiel
|
||||
# -----------------------------
|
||||
add_executable(Programmieren_3b
|
||||
=======
|
||||
|
||||
FetchContent_MakeAvailable(raylib)
|
||||
|
||||
add_executable(Prog3B
|
||||
>>>>>>> freund/main
|
||||
main.cpp
|
||||
gamecube.cpp
|
||||
gamematrix.cpp
|
||||
)
|
||||
|
||||
<<<<<<< HEAD
|
||||
target_link_libraries(Programmieren_3b PRIVATE raylib)
|
||||
|
||||
# Windows-spezifische Abhängigkeiten für raylib
|
||||
@ -58,3 +78,17 @@ target_include_directories(gamematrix_python PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
# Raylib ist für das Python-Modul nicht nötig, nur für C++ Executable
|
||||
# Optional: Falls du Gamematrix aus Python auch mit Raylib testen willst, kann man linken
|
||||
# target_link_libraries(gamematrix_python PRIVATE raylib)
|
||||
=======
|
||||
target_include_directories(Prog3B PRIVATE .)
|
||||
target_link_libraries(Prog3B raylib)
|
||||
|
||||
# macOS-Frameworks nicht vergessen:
|
||||
if(APPLE)
|
||||
target_link_libraries(Prog3B
|
||||
"-framework Cocoa"
|
||||
"-framework IOKit"
|
||||
"-framework CoreVideo"
|
||||
"-framework OpenGL"
|
||||
)
|
||||
endif()
|
||||
>>>>>>> freund/main
|
||||
|
||||
@ -14,7 +14,7 @@ void gamecube::Update(float flipSpeed)
|
||||
flippingForward = false;
|
||||
flipped = true;
|
||||
}
|
||||
}
|
||||
}// test
|
||||
else if (flippingBackward)
|
||||
{
|
||||
rotation -= flipSpeed;
|
||||
@ -60,8 +60,11 @@ void gamecube::Draw() const
|
||||
|
||||
Vec3 gamecube::GetPosition() const { return position; }
|
||||
float gamecube::GetRotationY() const { return rotation; }
|
||||
<<<<<<< HEAD
|
||||
bool gamecube::IsFullyFlipped() const
|
||||
{
|
||||
return rotation == 180.0f;
|
||||
}
|
||||
|
||||
=======
|
||||
>>>>>>> freund/main
|
||||
|
||||
@ -10,14 +10,18 @@ struct Vec3 {
|
||||
class gamecube {
|
||||
public:
|
||||
gamecube(const Vec3 &pos, Color col);
|
||||
|
||||
void Update(float flipSpeed);
|
||||
void FlipForward();
|
||||
void FlipBackward();
|
||||
|
||||
bool IsFlipped() const;
|
||||
bool IsFullyFlipped() const;
|
||||
bool IsMatched() const;
|
||||
void SetMatched(bool m);
|
||||
|
||||
void Draw() const;
|
||||
|
||||
Vec3 GetPosition() const;
|
||||
float GetRotationY() const;
|
||||
Color GetColor() const { return color; }
|
||||
@ -25,9 +29,12 @@ public:
|
||||
private:
|
||||
Vec3 position;
|
||||
Color color;
|
||||
|
||||
bool flipped = false;
|
||||
bool matched = false;
|
||||
|
||||
bool flippingForward = false;
|
||||
bool flippingBackward = false;
|
||||
|
||||
float rotation = 0.0f;
|
||||
};
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "gamematrix.h"
|
||||
|
||||
<<<<<<< HEAD
|
||||
namespace gameMatrix {
|
||||
|
||||
Mat4 matmul(const Mat4& A, const Mat4& B)
|
||||
@ -38,4 +39,46 @@ namespace gameMatrix {
|
||||
}};
|
||||
}
|
||||
|
||||
=======
|
||||
std::array<std::array<double,4>,4> gameMatrix::matmul(
|
||||
const std::array<std::array<double,4>,4>& A,
|
||||
const std::array<std::array<double,4>,4>& B)
|
||||
{
|
||||
std::array<std::array<double,4>,4> R = {};
|
||||
|
||||
for(int i=0;i<4;i++)
|
||||
for(int j=0;j<4;j++)
|
||||
for(int k=0;k<4;k++)
|
||||
R[i][j] += A[i][k] * B[k][j];
|
||||
|
||||
return R;
|
||||
}
|
||||
|
||||
std::array<std::array<double,4>,4> gameMatrix::rot3D(double angle_deg, char axis)
|
||||
{
|
||||
double a = angle_deg * M_PI / 180.0;
|
||||
double c = cos(a);
|
||||
double s = sin(a);
|
||||
|
||||
std::array<std::array<double,4>,4> M = {0};
|
||||
|
||||
M[3][3] = 1;
|
||||
M[axis == 'x'][axis == 'y'] = 1; // init identity axis
|
||||
|
||||
if(axis == 'x') M = {{{1,0,0,0},{0,c,-s,0},{0,s,c,0},{0,0,0,1}}};
|
||||
if(axis == 'y') M = {{{c,0,s,0},{0,1,0,0},{-s,0,c,0},{0,0,0,1}}};
|
||||
if(axis == 'z') M = {{{c,-s,0,0},{s,c,0,0},{0,0,1,0},{0,0,0,1}}};
|
||||
|
||||
return M;
|
||||
}
|
||||
|
||||
std::array<std::array<double,4>,4> gameMatrix::translate(const std::array<double,3>& p)
|
||||
{
|
||||
return {{
|
||||
{1,0,0,p[0]},
|
||||
{0,1,0,p[1]},
|
||||
{0,0,1,p[2]},
|
||||
{0,0,0,1}
|
||||
}};
|
||||
>>>>>>> freund/main
|
||||
}
|
||||
|
||||
28
tests.cpp
Normal file
28
tests.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include "gamematrix.h"
|
||||
|
||||
bool approx(double a, double b, double eps = 1e-6) {
|
||||
return std::fabs(a - b) < eps;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int failed = 0;
|
||||
|
||||
// Beispiel-Test: Rotation um Z 90°
|
||||
std::array<double,3> v = {1,0,0};
|
||||
auto Rz = rot3D(90, 'z'); // ggf. Namespace anpassen
|
||||
auto result = apply(Rz, v);
|
||||
if (!approx(result[0], 0.0) || !approx(result[1], 1.0)) {
|
||||
std::cout << "Test rot3D(Z,90) failed!\n";
|
||||
failed++;
|
||||
}
|
||||
|
||||
// Ausgabe
|
||||
if (failed == 0)
|
||||
std::cout << "ALL TESTS PASSED ✅\n";
|
||||
else
|
||||
std::cout << failed << " TEST(S) FAILED ❌\n";
|
||||
|
||||
return failed;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user