Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb751b132b | ||
|
|
19304d3344 | ||
|
|
a01ce2256e | ||
|
|
7cc1d0cbfd | ||
|
|
b0dbc38105 | ||
|
|
fba740c35c | ||
|
|
7666d43cfc | ||
|
|
28041fcf9f | ||
|
|
ad3ae081a9 | ||
|
|
f613b5a97f |
Generated
+97
@@ -1,6 +1,103 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="BackendCodeEditorSettings">
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/EditorConfig/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXPRESSION/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_FOR_STMT/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTIPLE_DECLARATION/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_TERNARY/@EntryValue" value="ALIGN_ALL" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_CLASS_DEFINITION/@EntryValue" value="1" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue" value="2" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_CODE/@EntryValue" value="2" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_USER_LINEBREAKS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_COMMENT/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INT_ALIGN_EQ/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_BLOCK_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_SEMICOLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_SEMICOLON/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_UNARY_OPERATOR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_ARRAY_ACCESS_BRACKETS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_METHOD_PARENTHESES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPECIAL_ELSE_IF_TREATMENT/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_BINARY_OPSIGN/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_TERNARY_OPSIGNS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TYPE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/OTHER_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DECLARATION/@EntryValue" value="1" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DEFINITION/@EntryValue" value="1" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_WHILE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_ELSE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_CATCH_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_INDENTATION/@EntryValue" value="All" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXTENDS_LIST/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_PARAMETER/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_ARGUMENT/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_PARAMETER/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_DECLARATIONS/@EntryValue" value="0" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_ACCESS_SPECIFIERS_FROM_CLASS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CLASS_MEMBERS_FROM_ACCESS_SPECIFIERS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_COLON_IN_MEMBER_INITIALIZER_LISTS/@EntryValue" value="ON_SINGLE_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/MEMBER_INITIALIZER_LIST_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_NAMESPACE_DEFINITIONS_ON_SAME_LINE/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_EXTENDS_COLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_EXTENDS_COLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_COLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_COLON/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_METHOD/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_NESTED_DECLARATOR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_METHOD/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_METHOD/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_METHOD/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BETWEEN_CLOSING_ANGLE_BRACKETS_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_DECLARATION_PARENTHESES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_BLOCKS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_LPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_INVOCATION_LPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_RPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_LPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_DECLARATION_LPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_RPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_ARGUMENTS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_PARAMETERS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BREAK_TEMPLATE_DECLARATION/@EntryValue" value="LINE_BREAK" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/FREE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INVOCABLE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INITIALIZER_BRACES/@EntryValue" value="END_OF_LINE_NO_SPACE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_STYLE/@EntryValue" value="Space" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_SIZE/@EntryValue" value="4" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CONTINUOUS_LINE_INDENT/@EntryValue" value="Double" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TAB_WIDTH/@EntryValue" value="4" type="int" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSmartPointerVsMakeFunction/@EntryIndexedValue" value="SUGGESTION" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCStyleCast/@EntryIndexedValue" value="SUGGESTION" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionalStyleCast/@EntryIndexedValue" value="SUGGESTION" type="string" />
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
========================================================
|
||||
Projekt: gamematrix (C++ Library)
|
||||
Rolle: Architekt
|
||||
Datei: design.txt
|
||||
Datum: ____________________
|
||||
Team: ____________________
|
||||
========================================================
|
||||
|
||||
# ----------------------------
|
||||
# 1. Projektstruktur / Namespace
|
||||
# ----------------------------
|
||||
Namespace: _______________________________________________
|
||||
|
||||
Ziel: Saubere Trennung der Bibliothek, Vermeidung von Namenskonflikten.
|
||||
|
||||
Beispiel:
|
||||
namespace Matrix3D {
|
||||
// Funktionen, ggf Klasse(n)
|
||||
}
|
||||
|
||||
# ----------------------------
|
||||
# 2. Datenstrukturen / Klassen
|
||||
# ----------------------------
|
||||
Listen Sie die Klassen oder Structs auf, die verwendet werden:
|
||||
|
||||
| Name | Typ | Beschreibung |
|
||||
|--------|------------------------------------------|--------------|
|
||||
| Vec3 | struct Vec3 | 3D-Vektor (x, y, z) |
|
||||
| Mat4 | std::array<std::array<double,4>,4> | 4x4-Matrix (homogen) |
|
||||
| ______ | ________ | ___________________ |
|
||||
| ______ | ________ | ___________________ |
|
||||
|
||||
# ----------------------------
|
||||
# 3. Operatoren / Templates
|
||||
# ----------------------------
|
||||
Welche Operatoren oder Templates sollen definiert werden?
|
||||
|
||||
- Templates für unterschiedliche Datentypen? ☐ Ja ☐ Nein
|
||||
- Operatoren:
|
||||
- Mat4 * Mat4
|
||||
- Mat4 * Vec3
|
||||
|
||||
# ----------------------------
|
||||
# 4. Funktionen / Schnittstellen
|
||||
# ----------------------------
|
||||
Liste der Funktionen mit Eingabe/Ausgabe und kurzer Beschreibung:
|
||||
|
||||
| Funktion | Eingabe | Ausgabe | Kurzbeschreibung |
|
||||
|---------------|------------------------------------|-----------------------|----------------------------------------|
|
||||
| matmul | Mat4 A, Mat4 B | Mat4 | Matrixmultiplikation 4x4 |
|
||||
| translate | Vec3 pos | Mat4 | Verschiebungstransformation |
|
||||
| rot3D | double angle_deg, char axis | Mat4 | Rotation um Achse x/y/z |
|
||||
| identity (optional)| --- | Mat4 | Identitätsmatrix |
|
||||
| _____________ | __________________________________ | ____________________ | ______________________________ |
|
||||
|
||||
# ----------------------------
|
||||
# 5. Designentscheidungen / Hinweise
|
||||
# ----------------------------
|
||||
- Rückgabe der Matrizen per Wert oder Referenz? ___________
|
||||
- Verwendung von std::array oder std::vector? ___________
|
||||
- Homogene Koordinaten für Translation / Rotation (4x4)? ☐ Ja ☐ Nein
|
||||
- Weitere Designüberlegungen: ___________________________
|
||||
|
||||
# ----------------------------
|
||||
# 6. Deliverables / Milestones
|
||||
# ----------------------------
|
||||
- design.txt fertig und im Branch architect committed
|
||||
- Übergabe an Entwickler für Implementierung
|
||||
|
||||
========================================================
|
||||
Hinweis:
|
||||
- Dieses Dokument dient als Grundlage für die Implementierung.
|
||||
- Alle Designentscheidungen sollen klar nachvollziehbar sein.
|
||||
========================================================
|
||||
@@ -22,6 +22,7 @@ public:
|
||||
Vec3 GetPosition() const;
|
||||
float GetRotationY() const;
|
||||
Color GetColor() const { return color; }
|
||||
bool IsAnimating() const;
|
||||
//zustände klarer abbikden bzw weniger bools = klarare Logik
|
||||
private:
|
||||
Vec3 position;
|
||||
|
||||
@@ -14,6 +14,6 @@ public:
|
||||
// Rotationsmatrix um Achse x/y/z
|
||||
static std::array<std::array<double,4>,4> rot3D(double angle_deg, char axis);
|
||||
|
||||
// Verschiebung
|
||||
// std::array<std::array<double,4>,4>
|
||||
static std::array<std::array<double,4>,4> translate(const std::array<double, 3>& pos);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
#ifndef MENU_H
|
||||
#define MENU_H
|
||||
|
||||
#pragma once
|
||||
#include "raylib.h"
|
||||
|
||||
enum MenuResult {
|
||||
MENU_NONE,
|
||||
MENU_SELECT_3,
|
||||
MENU_SELECT_6,
|
||||
MENU_SELECT_9
|
||||
};
|
||||
|
||||
MenuResult DrawMenu();
|
||||
|
||||
#endif //MENU_H
|
||||
|
||||
|
||||
+5
-1
@@ -63,4 +63,8 @@ void gamecube::Draw() const
|
||||
}
|
||||
|
||||
Vec3 gamecube::GetPosition() const { return position; }
|
||||
float gamecube::GetRotationY() const { return rotation; }
|
||||
float gamecube::GetRotationY() const { return rotation; }
|
||||
bool gamecube::IsAnimating() const
|
||||
{
|
||||
return flippingForward || flippingBackward;
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
#include <gamematrix.h>
|
||||
|
||||
|
||||
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> result{};
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
double sum = 0.0;
|
||||
for (int k = 0; k < 4; ++k) {
|
||||
sum += A[i][k] * B[k][j];
|
||||
}
|
||||
result[i][j] = sum;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
std::array<std::array<double,4>,4> gameMatrix::rot3D(double angle_deg, char axis) {
|
||||
double angle = angle_deg * M_PI / 180.0; // Grad → Radiant
|
||||
double c = std::cos(angle);
|
||||
double s = std::sin(angle);
|
||||
std::array<std::array<double,4>,4> R{}; // alles 0 initialisiert
|
||||
|
||||
switch (axis) {
|
||||
case 'x':
|
||||
R = {{
|
||||
{1, 0, 0, 0},
|
||||
{0, c, -s, 0},
|
||||
{0, s, c, 0},
|
||||
{0, 0, 0, 1}
|
||||
}};
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
R = {{
|
||||
{ c, 0, s, 0},
|
||||
{ 0, 1, 0, 0},
|
||||
{-s, 0, c, 0},
|
||||
{ 0, 0, 0, 1}
|
||||
}};
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
R = {{
|
||||
{c, -s, 0, 0},
|
||||
{s, c, 0, 0},
|
||||
{0, 0, 1, 0},
|
||||
{0, 0, 0, 1}
|
||||
}};
|
||||
break;
|
||||
|
||||
default:
|
||||
throw std::invalid_argument("Axis must be 'x', 'y' or 'z'");
|
||||
}
|
||||
|
||||
return R;
|
||||
}
|
||||
|
||||
std::array<std::array<double,4>,4> gameMatrix::translate(const std::array<double, 3>& pos) {
|
||||
std::array<std::array<double,4>,4> T{{
|
||||
{1, 0, 0, pos[0]},
|
||||
{0, 1, 0, pos[1]},
|
||||
{0, 0, 1, pos[2]},
|
||||
{0, 0, 0, 1}
|
||||
}};
|
||||
|
||||
return T;
|
||||
}
|
||||
|
||||
// Created by Fabian Weber on 10.11.25.
|
||||
//
|
||||
+85
-23
@@ -1,19 +1,20 @@
|
||||
#include "gamecube.h"
|
||||
#include <algorithm>
|
||||
#include <ctime>
|
||||
#include <menu.h>
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// 3D Memory Game – Hauptprogramm
|
||||
// -----------------------------------------------------------
|
||||
int main()
|
||||
{
|
||||
// Zufall initialisieren
|
||||
srand(time(NULL));
|
||||
|
||||
// Fenster und Kamera
|
||||
InitWindow(800, 600, "3D Memory Game with Matrix3D Library");
|
||||
SetTargetFPS(60);
|
||||
|
||||
// Zufall initialisieren
|
||||
srand(time(NULL));
|
||||
|
||||
Camera3D camera{};
|
||||
camera.position = {6.0f, 6.0f, 6.0f};
|
||||
camera.target = {0.0f, 0.0f, 0.0f};
|
||||
@@ -24,6 +25,7 @@ int main()
|
||||
// Nur 3 Farben für 3 Paare
|
||||
Color colors[] = { RED, GREEN, BLUE };
|
||||
|
||||
|
||||
// 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}};
|
||||
|
||||
@@ -52,65 +54,125 @@ int main()
|
||||
float flipSpeed = 5.0f; // Drehgeschwindigkeit
|
||||
bool gameWon = false;
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// Hauptspielschleife
|
||||
// -----------------------------------------------------------
|
||||
while (!WindowShouldClose())
|
||||
|
||||
enum class GameState
|
||||
{
|
||||
Menu,
|
||||
Idle, // kein Würfel offen, Eingabe erlaubt
|
||||
OneFlipped, // ein Würfel offen
|
||||
LockInput, // Würfel drehen gerade – Eingabe kurz blockiert
|
||||
CheckingMatch // zwei Würfel vollständig aufgeklappt, Vergleich läuft
|
||||
};
|
||||
|
||||
GameState state = GameState::Menu;
|
||||
|
||||
while (!WindowShouldClose()) {
|
||||
|
||||
if (state == GameState::Menu)
|
||||
{
|
||||
MenuResult res = DrawMenu();
|
||||
switch (res)
|
||||
{
|
||||
case MENU_SELECT_3:
|
||||
case MENU_SELECT_6:
|
||||
case MENU_SELECT_9:
|
||||
state = GameState::Idle;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (state == GameState::Menu)
|
||||
continue;
|
||||
}
|
||||
|
||||
// === GAME ===
|
||||
// Klick-Erkennung
|
||||
if (!gameWon && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||
if (!gameWon
|
||||
&& state != GameState::LockInput
|
||||
&& state != GameState::CheckingMatch
|
||||
&& IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||
{
|
||||
Vector2 mouse = GetMousePosition();
|
||||
|
||||
for (auto &c : cubes)
|
||||
{
|
||||
if (!c.IsFlipped() && !c.IsMatched())
|
||||
if (!c.IsAnimating() && !c.IsMatched())
|
||||
{
|
||||
Vector2 screenPos = GetWorldToScreen({c.GetPosition().x, c.GetPosition().y, c.GetPosition().z}, camera);
|
||||
|
||||
if (fabs(mouse.x - screenPos.x) < 40 && fabs(mouse.y - screenPos.y) < 40)
|
||||
{
|
||||
c.FlipForward();
|
||||
if (!first)
|
||||
{
|
||||
first = &c;
|
||||
state = GameState::OneFlipped;
|
||||
}
|
||||
else if (!second)
|
||||
{
|
||||
second = &c;
|
||||
state = GameState::LockInput;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Animation aller Würfel
|
||||
bool anyAnimating = false;
|
||||
for (auto &c : cubes)
|
||||
{
|
||||
c.Update(flipSpeed);
|
||||
if (c.IsAnimating()) anyAnimating = true;
|
||||
}
|
||||
|
||||
// Sobald ein Würfel vollständig umgedreht ist → merken
|
||||
if (c.IsFlipped() && !c.IsMatched())
|
||||
|
||||
if (state == GameState::LockInput && !anyAnimating)
|
||||
{
|
||||
// If both pointers are null → this was a failed attempt finishing its backflip
|
||||
if (!first && !second)
|
||||
{
|
||||
if (!first) first = &c;
|
||||
else if (!second && &c != first) second = &c;
|
||||
state = GameState::Idle;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Two cubes fully opened → proceed to matching
|
||||
state = GameState::CheckingMatch;
|
||||
}
|
||||
}
|
||||
|
||||
// Matching-Logik
|
||||
if (first && second)
|
||||
if (state == GameState::CheckingMatch && first && second)
|
||||
{
|
||||
Color col1 = first->GetColor();
|
||||
Color col2 = second->GetColor();
|
||||
bool match =
|
||||
first->GetColor().r == second->GetColor().r &&
|
||||
first->GetColor().g == second->GetColor().g &&
|
||||
first->GetColor().b == second->GetColor().b;
|
||||
|
||||
if (col1.r == col2.r && col1.g == col2.g && col1.b == col2.b)
|
||||
if (match)
|
||||
{
|
||||
first->SetMatched(true);
|
||||
second->SetMatched(true);
|
||||
|
||||
first = nullptr;
|
||||
second = nullptr;
|
||||
|
||||
state = GameState::Idle;
|
||||
}
|
||||
else
|
||||
{
|
||||
first->FlipBackward();
|
||||
second->FlipBackward();
|
||||
|
||||
first = nullptr;
|
||||
second = nullptr;
|
||||
|
||||
// WAIT FOR BACKFLIP ANIMATION
|
||||
state = GameState::LockInput;
|
||||
}
|
||||
|
||||
first = second = nullptr;
|
||||
}
|
||||
|
||||
// Gewinnprüfung
|
||||
if (!gameWon)
|
||||
gameWon = std::all_of(cubes.begin(), cubes.end(), [](const gamecube &c){ return c.IsMatched(); });
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// Zeichnen
|
||||
// -----------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "menu.h"
|
||||
|
||||
MenuResult DrawMenu() {
|
||||
Rectangle b1 = { 250, 180, 300, 50 };
|
||||
Rectangle b2 = { 250, 260, 300, 50 };
|
||||
Rectangle b3 = { 250, 340, 300, 50 };
|
||||
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText("Wähle Anzahl Paare:", 200, 100, 30, DARKGRAY);
|
||||
|
||||
DrawRectangleRec(b1, LIGHTGRAY);
|
||||
DrawText("3 Paare", 340, 195, 20, BLACK);
|
||||
|
||||
DrawRectangleRec(b2, LIGHTGRAY);
|
||||
DrawText("6 Paare", 340, 275, 20, BLACK);
|
||||
|
||||
DrawRectangleRec(b3, LIGHTGRAY);
|
||||
DrawText("9 Paare", 340, 355, 20, BLACK);
|
||||
|
||||
EndDrawing();
|
||||
|
||||
Vector2 m = GetMousePosition();
|
||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) {
|
||||
if (CheckCollisionPointRec(m, b1)) return MENU_SELECT_3;
|
||||
if (CheckCollisionPointRec(m, b2)) return MENU_SELECT_6;
|
||||
if (CheckCollisionPointRec(m, b3)) return MENU_SELECT_9;
|
||||
}
|
||||
|
||||
return MENU_NONE;
|
||||
}
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <numeric>
|
||||
|
||||
bool readFile(const std::string& filename, std::vector<int>& data) {
|
||||
std::ifstream file(filename);
|
||||
|
||||
if (!file.is_open()) {
|
||||
std::cerr << "FEHLER: Konnte Datei nicht oeffnen!\n";
|
||||
std::cerr << "Pfad: " << filename << "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
int value;
|
||||
std::cout << "Lese Datei ein... (Pfad: " << filename << ")\n";
|
||||
|
||||
while (file >> value) {
|
||||
data.push_back(value);
|
||||
}
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::vector<int> messungen;
|
||||
std::string pfad = "C:\\Users\\Bruno\\Desktop\\BME\\BME 3\\PROG B\\praktikum\\thread\\measurements.txt";
|
||||
|
||||
if (!readFile(pfad, messungen)) {
|
||||
std::cout << "\nDruecke ENTER zum Beenden...";
|
||||
std::cin.get();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (messungen.size() < 2) {
|
||||
std::cout << "Datei ist leer oder hat zu wenig Werte!\n";
|
||||
std::cin.get();
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::cout << "Erfolg! " << messungen.size() << " Messwerte geladen.\n";
|
||||
std::cout << "-----------------------------------\n";
|
||||
|
||||
{
|
||||
std::cout << "Starte serielle Berechnung...\n";
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
|
||||
long long increases = 0;
|
||||
for (size_t i = 1; i < messungen.size(); i++) {
|
||||
if (messungen[i] > messungen[i - 1]) {
|
||||
increases++;
|
||||
}
|
||||
}
|
||||
|
||||
auto end = std::chrono::steady_clock::now();
|
||||
std::chrono::duration<double> diff = end - start;
|
||||
|
||||
std::cout << "[SERIELL] Anstiege: " << increases << "\n";
|
||||
std::cout << " Zeit: " << diff.count() << " s\n\n";
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << "Starte parallele Berechnung...\n";
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
|
||||
unsigned int numThreads = std::thread::hardware_concurrency();
|
||||
if (numThreads == 0) numThreads = 4;
|
||||
|
||||
std::vector<std::thread> threads;
|
||||
std::vector<long long> results(numThreads, 0);
|
||||
|
||||
size_t totalComparisons = messungen.size() - 1;
|
||||
size_t base = totalComparisons / numThreads;
|
||||
size_t remainder = totalComparisons % numThreads;
|
||||
|
||||
size_t idx = 1;
|
||||
|
||||
for (unsigned int t = 0; t < numThreads; t++)
|
||||
{
|
||||
size_t startIdx = idx;
|
||||
size_t count = base + (t < remainder ? 1 : 0);
|
||||
size_t endIdx = idx + count - 1;
|
||||
|
||||
idx = endIdx + 1;
|
||||
|
||||
threads.emplace_back([&, t, startIdx, endIdx]() {
|
||||
long long localCount = 0;
|
||||
if (startIdx < messungen.size()) {
|
||||
for (size_t i = startIdx; i <= endIdx; ++i) {
|
||||
if (messungen[i] > messungen[i - 1]) {
|
||||
++localCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
results[t] = localCount;
|
||||
});
|
||||
}
|
||||
|
||||
for (auto& th : threads) {
|
||||
if (th.joinable())
|
||||
th.join();
|
||||
}
|
||||
|
||||
long long totalParallel = 0;
|
||||
for (long long r : results) {
|
||||
totalParallel += r;
|
||||
}
|
||||
|
||||
auto end = std::chrono::steady_clock::now();
|
||||
std::chrono::duration<double> diff = end - start;
|
||||
|
||||
std::cout << "[PARALLEL] Anstiege: " << totalParallel << " (Threads: " << numThreads << ")\n";
|
||||
std::cout << " Zeit: " << diff.count() << " s\n";
|
||||
}
|
||||
|
||||
std::cout << "\n-----------------------------------\n";
|
||||
std::cout << "Druecke ENTER zum Beenden...";
|
||||
std::cin.get();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user