Author SHA1 Message Date
1nn0c3ntt 9d8cdb8207 Tests.cpp funktioniert jetzt 2025-11-17 12:58:36 +01:00
linkse100241 e179abd8d9 tests.cpp update 2025-11-16 16:48:17 +01:00
linkse100241 72168eaa79 test.cpp aktualisiert 2025-11-16 16:46:56 +01:00
linkse100241 5dfa867449 Create tests.txt 2025-11-03 12:40:11 +01:00
linkse100241 368576471a Create tests.cpp 2025-11-03 12:36:07 +01:00
15 changed files with 114 additions and 196 deletions
-10
View File
@@ -1,10 +0,0 @@
# Ignore CMake build directories
cmake-build-debug/
cmake-build-release/
# General build artifacts
build/
out/
*.o
*.obj
*.log
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/windows/libgamematrix.a" charset="ISO-8859-1" />
</component>
</project>
+1
View File
@@ -0,0 +1 @@
hallo
+3
View File
@@ -33,6 +33,7 @@ if(WIN32)
message(STATUS "Configuring for Windows") message(STATUS "Configuring for Windows")
target_link_libraries(${EXECUTABLE_NAME} PRIVATE target_link_libraries(${EXECUTABLE_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/windows/libgamematrix.a
${CMAKE_CURRENT_LIST_DIR}/windows/libraylib.a ${CMAKE_CURRENT_LIST_DIR}/windows/libraylib.a
opengl32 gdi32 winmm opengl32 gdi32 winmm
) )
@@ -41,6 +42,7 @@ elseif(APPLE)
message(STATUS "Configuring for MacOS") message(STATUS "Configuring for MacOS")
target_link_libraries(${EXECUTABLE_NAME} PRIVATE target_link_libraries(${EXECUTABLE_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/mac_x86/libgamematrix.a
${CMAKE_CURRENT_LIST_DIR}/mac_x86/libraylib.a ${CMAKE_CURRENT_LIST_DIR}/mac_x86/libraylib.a
"-framework IOKit" "-framework IOKit"
"-framework Cocoa" "-framework Cocoa"
@@ -50,6 +52,7 @@ else()
# --- Linux --- # --- Linux ---
message(STATUS "Configuring for Linux") message(STATUS "Configuring for Linux")
target_link_libraries(${EXECUTABLE_NAME} PRIVATE target_link_libraries(${EXECUTABLE_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/linux/libgamematrix.a
${CMAKE_CURRENT_LIST_DIR}/linux/libraylib.a ${CMAKE_CURRENT_LIST_DIR}/linux/libraylib.a
GL X11 m GL X11 m
) )
Binary file not shown.
+44
View File
@@ -0,0 +1,44 @@
@@ -1,43 +0,0 @@
========================================================
Projekt: gamematrix (C++ Library)
Rolle: Tester
Datei: tests.txt
Datum: 4.10.2025
Team: prog3b_652
========================================================
# ----------------------------
# 1. Testplan Übersicht
# ----------------------------
Ziel: Überprüfung der Funktionen matmul(), translate(), rot3D().
| Funktion | Testfall | Eingabe | Erwartetes Ergebnis | Bemerkung |
|---------------|---------------------------|------------------------------|-----------------------------------|----------------------------|
| matmul | Identity * Identity | 4x4 Identity Matrizen | Identity | Basisfall |
| matmul | Beispielmatrizen | A=[[...]], B=[[...]] | C=[[...]] | Prüfen mit Handrechnung |
| translate | Verschiebung | Vec3 {1,2,3} | Matrix mit Translation 1,2,3 | Prüfen letzte Spalte |
| rot3D | Rotation Z 90° | angle_deg=90, axis='z' | (1,0,0) -> (0,1,0) | Prüfen Anwendung auf Vektor|
| rot3D | Rotation X 180° | angle_deg=180, axis='x' | (0,1,0) -> (0,-1,0) | Prüfen Anwendung auf Vektor|
| rot3D | Rotation Y 270° | angle_deg=270, axis='y' | (1,0,0) -> (0,0,-1) | Prüfen Anwendung auf Vektor|
# ----------------------------
# 2. Testdaten / Matrizen
# ----------------------------
- Matrizen für matmul: Identity, Beispiel A/B Matrizen
- Vektoren für translate: Vec3 {x, y, z}
- Vektoren für rot3D: Vec3 {1,0,0}, Vec3 {0,1,0}
# ----------------------------
# 3. Abnahmekriterien
# ----------------------------
- Alle Unit-Tests erfolgreich
- Keine Exceptions außer gewollt (z. B. ungültige Achse)
- Testbericht in tests.txt dokumentiert
========================================================
Hinweis:
- Diese Datei wird vom Tester gepflegt.
- Tester dokumentiert Input, Output, erwartetes Ergebnis und Erfolg/Fehler.
========================================================
BIN
View File
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
Download
git Clone (link)
Download-Ordner
cd (/Pfad)
pull = ziehen/ abgleichen
Upload
git Clone (link)
git pull
fix:
(cd prog3b_652
git Status
git pull)
git Status
git add
*= alles / Dateiname sonst
-77
View File
@@ -1,77 +0,0 @@
//Ablage für ChatGPT Sachen, nicht relavant für das Projekt (Nur ein "Cloud"-Zwischenspeicher)
#include <iostream>
#include <array>
#include <string>
#include <cmath>
// Typalias für 4x4-Matrix mit double
#include "gamematrix.h"
// Matrixmultiplikation
// Rotationsmatrix um Achse x/y/z
static std::array<std::array<double,4>,4> rot3D(double angle_deg, char axis);
// Verschiebung
static std::array<std::array<double,4>,4> translate(const std::array<double, 3>& pos);
//Matrixmultiplikation-Funktion
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)
{ //Matrix-Mathematik (Matrix C = A*B)
std::array<std::array<double,4>,4> C{};
for (int i = 0; i < 4; ++i)
for (int j = 0; j < 4; ++j)
for (int k = 0; k < 4; ++k)
C[i][j] += A[i][k] * B[k][j];
return C;
}
// -------------------- Translationsmatrix --------------------
std::array<std::array<double,4>,4> gameMatrix::translate(const std::array<double,3>& pos) {
std::array<std::array<double,4>,4> T{};
for (int i = 0; i < 4; ++i)
T[i][i] = 1.0; // Identitätsmatrix
T[0][3] = pos[0]; // x-Verschiebung
T[1][3] = pos[1]; // y-Verschiebung
T[2][3] = pos[2]; // z-Verschiebung
return T;
}
int main()
{
// Beispiel: Translation testen
std::array<double,3> pos;
std::cout << "Gib die Translation (x y z) ein: ";
std::cin >> pos[0] >> pos[1] >> pos[2];
std::array<std::array<double,4>,4> T = gameMatrix::translate(pos);
std::cout << "\nTranslationsmatrix T:\n";
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j)
std::cout << T[i][j] << "\t";
std::cout << "\n";
}
}
+5 -21
View File
@@ -8,28 +8,12 @@ class gameMatrix
{ {
public: public:
// Matrix Multiplikation // Matrix Multiplikation
static std::array<std::array<double,4>,4> matmul( static std::array<std::array<double,4>,4> matmul(const std::array<std::array<double,4>,4>& A,
const std::array<std::array<double,4>,4>& A, const std::array<std::array<double,4>,4>& B);
const std::array<std::array<double,4>,4>& B
);
// Rotationsmatrix um Achse x/y/z // Rotationsmatrix um Achse x/y/z
static std::array<std::array<double,4>,4> rot3D( static std::array<std::array<double,4>,4> rot3D(double angle_deg, char axis);
double angle_deg,
char axis
);
// Translation // Verschiebung
static std::array<std::array<double,4>,4> translate( static std::array<std::array<double,4>,4> translate(const std::array<double, 3>& pos);
const std::array<double,3>& pos
);
}; };
enum class GameState
{
Idle, // kein Würfel offen, Eingabe erlaubt
OneFlipped, // ein Würfel offen
CheckingMatch, // zwei Würfel vollständig aufgeklappt, Vergleich läuft
LockInput // Würfel drehen gerade – Eingabe kurz blockiert
};
+8 -5
View File
@@ -2,13 +2,16 @@
// Created by kris- on 03.11.2025. // Created by kris- on 03.11.2025.
// //
#include <iostream> #include <iostream>
#include "../includes/gamematrix.h" #include "gamematrix.h"
// Matrixmultiplikation // Matrixmultiplikation
// Rotationsmatrix um Achse x/y/z // Rotationsmatrix um Achse x/y/z
//static std::array<std::array<double,4>,4> rot3D(double angle_deg, char axis); static std::array<std::array<double,4>,4> rot3D(double angle_deg, char axis);
// Verschiebung // Verschiebung
//static std::array<std::array<double,4>,4> translate(const std::array<double, 3>& pos); static std::array<std::array<double,4>,4> translate(const std::array<double, 3>& pos);
@@ -140,8 +143,8 @@ std::array<std::array<double,4>,4> gameMatrix::translate(const std::array<double
} }
return 0; return 0;
}*/ }
*/
+20 -81
View File
@@ -1,78 +1,12 @@
#include "gamecube.h" #include "gamecube.h"
#include <algorithm> #include <algorithm>
#include <ctime> #include <ctime>
//enum game
//Ab Zeile 169 if game won
//Ab Zeile 148 checking match?
void innitGame(int pairCount,
std::vector<gamecube> &cubes,
std::vector<Vec3> &positions )
{
cubes.clear();
positions.clear();
// Spielfeld grob quadratisch machen
int total = pairCount * 2;
int cols = ceil(sqrt(total));
int rows = (total + cols - 1) / cols;
float spacing = 2.2f;
// Dynamische Positionen erzeugen
for (int r = 0; r < rows; r++)
{
for (int c = 0; c < cols; c++)
{
if ((int)positions.size() < total)
{
positions.push_back({
(c - cols/2.0f) * spacing,
0,
(r - rows/2.0f) * spacing
});
}
}
}
// Colors erzeugen
std::vector<Color> colorPool;
colorPool.reserve(total);
for (int i = 0; i < pairCount; i++)
{
Color col = {
(unsigned char)(rand() % 256),
(unsigned char)(rand() % 256),
(unsigned char)(rand() % 256),
255
};
colorPool.push_back(col);
colorPool.push_back(col); // Paar
}
// Shuffle
for (int i = total - 1; i > 0; --i)
std::swap(colorPool[i], colorPool[rand() % (i + 1)]);
// Würfel erstellen
for (int i = 0; i < total; i++)
cubes.emplace_back(positions[i], colorPool[i]);
}
// ----------------------------------------------------------- // -----------------------------------------------------------
// 3D Memory Game – Hauptprogramm // 3D Memory Game – Hauptprogramm
// ----------------------------------------------------------- // -----------------------------------------------------------
int main() int main()
{ {
//NEU Counter
int counter = 0;
// Zufall initialisieren // Zufall initialisieren
srand(time(NULL)); srand(time(NULL));
@@ -87,19 +21,31 @@ int main()
camera.fovy = 45.0f; camera.fovy = 45.0f;
camera.projection = CAMERA_PERSPECTIVE; camera.projection = CAMERA_PERSPECTIVE;
// -------------------------------------------------------
// Spielvariablen
// -------------------------------------------------------
// Nur 3 Farben für 3 Paare // Nur 3 Farben für 3 Paare
int pairCount = 6; // <-- vorerst fixe Anzahl Color colors[] = { RED, GREEN, BLUE };
std::vector<Vec3> positions;
std::vector<gamecube> cubes;
innitGame(pairCount, cubes, positions); // 6 Karten-Positionen im 3x2 Raster
std::vector<Vec3> positions = {{-2, 0, -2}, {0, 0, -2}, {2, 0, -2},{-2, 0, 0}, {0, 0, 0}, {2, 0, 0}};
// Farben doppelt in einen Pool legen und mischen
std::vector<Color> colorPool;
for (int i = 0; i < 3; i++)
{
colorPool.push_back(colors[i]);
colorPool.push_back(colors[i]);
}
// Fisher-Yates Shuffle mit rand()
for (int i = colorPool.size() - 1; i > 0; --i)
{
int j = rand() % (i + 1); // Zufallsindex von 0 bis i
std::swap(colorPool[i], colorPool[j]);
}
// Karten/Würfel erstellen // Karten/Würfel erstellen
std::vector<gamecube> cubes;
for (int i = 0; i < 6; i++)
cubes.emplace_back(positions[i], colorPool[i]);
gamecube* first = nullptr; gamecube* first = nullptr;
gamecube* second = nullptr; gamecube* second = nullptr;
@@ -114,9 +60,6 @@ int main()
// Klick-Erkennung // Klick-Erkennung
if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{ {
//Neu Counter
counter++;
Vector2 mouse = GetMousePosition(); Vector2 mouse = GetMousePosition();
for (auto &c : cubes) for (auto &c : cubes)
@@ -147,8 +90,6 @@ int main()
// Matching-Logik // Matching-Logik
if (first && second) if (first && second)
{ {
//counter hier macht umdrehungen
Color col1 = first->GetColor(); Color col1 = first->GetColor();
Color col2 = second->GetColor(); Color col2 = second->GetColor();
@@ -163,7 +104,6 @@ int main()
second->FlipBackward(); second->FlipBackward();
} }
first = second = nullptr; first = second = nullptr;
} }
@@ -182,12 +122,11 @@ int main()
c.Draw(); c.Draw();
EndMode3D(); EndMode3D();
if (gameWon) if (gameWon)
DrawText("Congrats! You found all pairs!", 150, 260, 30, DARKBLUE); DrawText("Congrats! You found all pairs!", 150, 260, 30, DARKBLUE);
else else
DrawText("Flip 2 cubes - find matching pairs!", 10, 10, 20, DARKGRAY); DrawText("Flip 2 cubes - find matching pairs!", 10, 10, 20, DARKGRAY);
//Neu Counter
DrawText(TextFormat("Counter: %i",counter/2),10,40,20,DARKGRAY); //counter//2 da sonst doppelt
EndDrawing(); EndDrawing();
} }
+1
View File
@@ -0,0 +1 @@
git push pull test
Binary file not shown.