generated from freudenreichan/Programmieren_3b
Konflikte in .idea-Dateien gelöst
This commit is contained in:
commit
dfbe5edbda
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
|||||||
|
Prog3B
|
||||||
2
.idea/Prog3B_Anke.iml
generated
Normal file
2
.idea/Prog3B_Anke.iml
generated
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
||||||
7
.idea/misc.xml
generated
Normal file
7
.idea/misc.xml
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CMakePythonSetting">
|
||||||
|
<option name="pythonIntegrationState" value="YES" />
|
||||||
|
</component>
|
||||||
|
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/Prog3B_Anke.iml" filepath="$PROJECT_DIR$/.idea/Prog3B_Anke.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
58
.idea/workspace.xml
generated
58
.idea/workspace.xml
generated
@ -26,7 +26,9 @@
|
|||||||
</configurations>
|
</configurations>
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="cd494894-f5e2-4e63-8762-0780bfaa57e7" name="Changes" comment="" />
|
<list default="true" id="cd494894-f5e2-4e63-8762-0780bfaa57e7" name="Changes" comment="">
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
@ -53,28 +55,32 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">{
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"CMake Application.Prog3B.executor": "Run",
|
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
"RunOnceActivity.RadMigrateCodeStyle": "true",
|
"CMake Application.Prog3B.executor": "Run",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
||||||
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
"RunOnceActivity.RadMigrateCodeStyle": "true",
|
||||||
"RunOnceActivity.cidr.known.project.marker": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
||||||
"RunOnceActivity.readMode.enableVisualFormatting": "true",
|
"RunOnceActivity.cidr.known.project.marker": "true",
|
||||||
"RunOnceActivity.west.config.association.type.startup.service": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"cf.first.check.clang-format": "false",
|
"RunOnceActivity.readMode.enableVisualFormatting": "true",
|
||||||
"cidr.known.project.marker": "true",
|
"RunOnceActivity.west.config.association.type.startup.service": "true",
|
||||||
"last_opened_file_path": "C:/Users/aksai/CLionProjects/Prog3B_Anke1",
|
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
"node.js.detected.package.eslint": "true",
|
"cf.first.check.clang-format": "false",
|
||||||
"node.js.detected.package.tslint": "true",
|
"cidr.known.project.marker": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"git-widget-placeholder": "project__developer",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"last_opened_file_path": "C:/Users/aksai/CLionProjects/Prog3B_Anke1",
|
||||||
"nodejs_package_manager_path": "npm",
|
"node.js.detected.package.eslint": "true",
|
||||||
"settings.editor.selected.configurable": "preferences.keymap",
|
"node.js.detected.package.tslint": "true",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
|
"nodejs_package_manager_path": "npm",
|
||||||
|
"settings.editor.selected.configurable": "preferences.keymap",
|
||||||
|
"vue.rearranger.settings.migration": "true"
|
||||||
}
|
}
|
||||||
}</component>
|
}]]></component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
<recent name="C:\Users\aksai\CLionProjects\Prog3B_Anke1" />
|
<recent name="C:\Users\aksai\CLionProjects\Prog3B_Anke1" />
|
||||||
@ -86,6 +92,11 @@
|
|||||||
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<configuration default="true" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true">
|
||||||
|
<method v="2">
|
||||||
|
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
<component name="TaskManager">
|
<component name="TaskManager">
|
||||||
<task active="true" id="Default" summary="Default task">
|
<task active="true" id="Default" summary="Default task">
|
||||||
@ -96,6 +107,7 @@
|
|||||||
<updated>1763378940554</updated>
|
<updated>1763378940554</updated>
|
||||||
<workItem from="1763378941684" duration="11287000" />
|
<workItem from="1763378941684" duration="11287000" />
|
||||||
<workItem from="1763403043188" duration="625000" />
|
<workItem from="1763403043188" duration="625000" />
|
||||||
|
<workItem from="1763403684347" duration="653000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
@ -135,7 +147,7 @@
|
|||||||
<breakpoints>
|
<breakpoints>
|
||||||
<line-breakpoint enabled="true" type="CMakeLineBreakpoint">
|
<line-breakpoint enabled="true" type="CMakeLineBreakpoint">
|
||||||
<url>file://$PROJECT_DIR$/CMakeLists.txt</url>
|
<url>file://$PROJECT_DIR$/CMakeLists.txt</url>
|
||||||
<line>11</line>
|
<line>10</line>
|
||||||
<option name="timeStamp" value="2" />
|
<option name="timeStamp" value="2" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
</breakpoints>
|
</breakpoints>
|
||||||
|
|||||||
@ -1,35 +1,44 @@
|
|||||||
cmake_minimum_required(VERSION 3.28)
|
cmake_minimum_required(VERSION 3.28)
|
||||||
project(Prog3B)
|
project(Prog3B)
|
||||||
|
|
||||||
set(EXECUTABLE_NAME Prog3B)
|
set(EXECUTABLE_NAME Prog3B)
|
||||||
|
|
||||||
# Generate compile_commands.json
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
# Set the default build type if not specified
|
# Default build type
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Quell- und Header-Dateien
|
||||||
set(SRC_FILES
|
set(SRC_FILES
|
||||||
${CMAKE_CURRENT_LIST_DIR}/main.cpp
|
${CMAKE_CURRENT_LIST_DIR}/src/main.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/gamecube.cpp
|
${CMAKE_CURRENT_LIST_DIR}/src/gamecube.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/src/gamematrix.cpp
|
||||||
)
|
)
|
||||||
|
#automatisch hinzufügen
|
||||||
|
file(GLOB SRC_FILES "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp")
|
||||||
|
|
||||||
set(INCLUDE_DIRS
|
set(INCLUDE_DIRS
|
||||||
${CMAKE_CURRENT_LIST_DIR}/linux
|
${CMAKE_CURRENT_LIST_DIR}/includes
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/raylib
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Executable erstellen
|
||||||
add_executable(${EXECUTABLE_NAME} ${SRC_FILES})
|
add_executable(${EXECUTABLE_NAME} ${SRC_FILES})
|
||||||
target_include_directories(${EXECUTABLE_NAME} PRIVATE ${INCLUDE_DIRS})
|
|
||||||
target_link_libraries(${EXECUTABLE_NAME} PRIVATE
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}/linux/libgamematrix.a
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}/linux/libraylib.a
|
|
||||||
)
|
|
||||||
|
|
||||||
# Checks if OSX and links appropriate frameworks (Only required on MacOS)
|
# Include-Verzeichnisse hinzufügen
|
||||||
if (APPLE)
|
target_include_directories(${EXECUTABLE_NAME} PRIVATE ${INCLUDE_DIRS})
|
||||||
target_link_libraries(Prog3B "-framework IOKit")
|
|
||||||
target_link_libraries(Prog3B "-framework Cocoa")
|
|
||||||
target_link_libraries(Prog3B "-framework OpenGL")
|
# Nur noch raylib und systemabhängige Libraries linken
|
||||||
|
#target_link_libraries(${EXECUTABLE_NAME} PRIVATE
|
||||||
|
# ${CMAKE_CURRENT_LIST_DIR}/windows/libraylib.a
|
||||||
|
# winmm
|
||||||
|
|
||||||
|
# MacOS Frameworks (falls benötigt)
|
||||||
|
if(APPLE)
|
||||||
|
target_link_libraries(${EXECUTABLE_NAME} PRIVATE "-framework IOKit")
|
||||||
|
target_link_libraries(${EXECUTABLE_NAME} PRIVATE "-framework Cocoa")
|
||||||
|
target_link_libraries(${EXECUTABLE_NAME} PRIVATE "-framework OpenGL")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@ -31,4 +31,7 @@ private:
|
|||||||
bool flippingForward = false;
|
bool flippingForward = false;
|
||||||
bool flippingBackward = false;
|
bool flippingBackward = false;
|
||||||
float rotation = 0.0f;
|
float rotation = 0.0f;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -16,4 +16,8 @@ public:
|
|||||||
|
|
||||||
// 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);
|
||||||
|
|
||||||
|
|
||||||
|
//Einheitsmatrix
|
||||||
|
static std::array<std::array<double,4>,4> identity();
|
||||||
};
|
};
|
||||||
1
raylib/raylib
Submodule
1
raylib/raylib
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit d8601121da44b993f2893e9afd51b85105c6e698
|
||||||
@ -1,16 +1,27 @@
|
|||||||
#include "gamecube.h"
|
#include "gamecube.h"
|
||||||
|
|
||||||
|
// Konstanten für Rotation und Matrixgröße
|
||||||
|
constexpr float ROTATION_HALF = 90.0f;
|
||||||
|
constexpr float ROTATION_FULL = 180.0f;
|
||||||
|
|
||||||
|
|
||||||
|
// Standardfarben
|
||||||
|
const Color DEFAULT_COLOR = GRAY;
|
||||||
|
const Color WIRES_COLOR = BLACK;
|
||||||
|
|
||||||
|
|
||||||
gamecube::gamecube(const Vec3 &pos, Color col)
|
gamecube::gamecube(const Vec3 &pos, Color col)
|
||||||
: position(pos), color(col) {}
|
: position(pos), color(col) {}
|
||||||
|
|
||||||
|
// ✅ Klar strukturierte Funktion
|
||||||
void gamecube::Update(float flipSpeed)
|
void gamecube::Update(float flipSpeed)
|
||||||
{
|
{
|
||||||
if (flippingForward)
|
if (flippingForward)
|
||||||
{
|
{
|
||||||
rotation += flipSpeed;
|
rotation += flipSpeed;
|
||||||
if (rotation >= 180.0f)
|
if (rotation >= ROTATION_FULL) // ⚠️ Magic Number
|
||||||
{
|
{
|
||||||
rotation = 180.0f;
|
rotation = ROTATION_FULL; // ⚠️ Magic Number
|
||||||
flippingForward = false;
|
flippingForward = false;
|
||||||
flipped = true;
|
flipped = true;
|
||||||
}
|
}
|
||||||
@ -30,7 +41,7 @@ void gamecube::Update(float flipSpeed)
|
|||||||
void gamecube::FlipForward() { flippingForward = true; }
|
void gamecube::FlipForward() { flippingForward = true; }
|
||||||
void gamecube::FlipBackward() { flippingBackward = true; }
|
void gamecube::FlipBackward() { flippingBackward = true; }
|
||||||
|
|
||||||
bool gamecube::IsFlipped() const { return flipped; }
|
bool gamecube::IsFlipped() const { return flipped; } // ✅ Getter sauber, const korrekt
|
||||||
bool gamecube::IsMatched() const { return matched; }
|
bool gamecube::IsMatched() const { return matched; }
|
||||||
void gamecube::SetMatched(bool m) { matched = m; }
|
void gamecube::SetMatched(bool m) { matched = m; }
|
||||||
|
|
||||||
@ -52,12 +63,12 @@ void gamecube::Draw() const
|
|||||||
f[j * 4 + i] = model[i][j];
|
f[j * 4 + i] = model[i][j];
|
||||||
rlMultMatrixf(f);
|
rlMultMatrixf(f);
|
||||||
|
|
||||||
if (rotation < 90.0f)
|
if (rotation < ROTATION_HALF) // ⚠️ Magic Number
|
||||||
DrawCube({0,0,0}, 1,1,1, GRAY);
|
DrawCube({0,0,0}, 1,1,1, DEFAULT_COLOR);
|
||||||
else
|
else
|
||||||
DrawCube({0,0,0}, 1,1,1, color);
|
DrawCube({0,0,0}, 1,1,1, color);
|
||||||
|
|
||||||
DrawCubeWires({0,0,0}, 1,1,1, BLACK);
|
DrawCubeWires({0,0,0}, 1,1,1,WIRES_COLOR);
|
||||||
|
|
||||||
rlPopMatrix();
|
rlPopMatrix();
|
||||||
}
|
}
|
||||||
75
src/gamematrix.cpp
Normal file
75
src/gamematrix.cpp
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#include "gamematrix.h"
|
||||||
|
#include <cmath>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
// Matrix Multiplikation
|
||||||
|
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 = {0};
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
for (int j = 0; j < 4; ++j)
|
||||||
|
{
|
||||||
|
result[i][j] = 0.0;
|
||||||
|
for (int k = 0; k < 4; ++k)
|
||||||
|
result[i][j] += A[i][k] * B[k][j];
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rotationsmatrix
|
||||||
|
std::array<std::array<double,4>,4> gameMatrix::rot3D(double angle_deg, char axis)
|
||||||
|
{
|
||||||
|
double angle_rad = angle_deg * M_PI / 180.0;
|
||||||
|
double c = std::cos(angle_rad);
|
||||||
|
double s = std::sin(angle_rad);
|
||||||
|
|
||||||
|
std::array<std::array<double,4>,4> R = identity();
|
||||||
|
|
||||||
|
switch (axis)
|
||||||
|
{
|
||||||
|
case 'x': case 'X':
|
||||||
|
R[1][1] = c; R[1][2] = -s;
|
||||||
|
R[2][1] = s; R[2][2] = c;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'y': case 'Y':
|
||||||
|
R[0][0] = c; R[0][2] = s;
|
||||||
|
R[2][0] = -s; R[2][2] = c;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'z': case 'Z':
|
||||||
|
R[0][0] = c; R[0][1] = -s;
|
||||||
|
R[1][0] = s; R[1][1] = c;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw std::invalid_argument("Invalid axis for rotation (use x, y, or z)");
|
||||||
|
}
|
||||||
|
|
||||||
|
return R;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Translation
|
||||||
|
std::array<std::array<double,4>,4> gameMatrix::translate(const std::array<double,3>& pos)
|
||||||
|
{
|
||||||
|
std::array<std::array<double,4>,4> T = identity();
|
||||||
|
|
||||||
|
T[0][3] = pos[0];
|
||||||
|
T[1][3] = pos[1];
|
||||||
|
T[2][3] = pos[2];
|
||||||
|
|
||||||
|
return T;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Einheitsmatrix-Matrix
|
||||||
|
std::array<std::array<double,4>,4> gameMatrix::identity()
|
||||||
|
{
|
||||||
|
std::array<std::array<double,4>,4> I = {0};
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
I[i][i] = 1.0;
|
||||||
|
return I;
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
#include "gamecube.h"
|
#include "../includes/gamecube.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
BIN
wuerfelmemory.exe
Normal file
BIN
wuerfelmemory.exe
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user