Gitignore hinzugefügt und Blöcke werden gezählt.
This commit is contained in:
1 parent
987845e4dc
commit
32be3483ad
2 files changed
+21
-18
No files matched your search
+12
@@ -0,0 +1,12 @@
|
||||
# Kompilierte ausführbare Dateien
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
# Objektdateien
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Build-Ordner oder IDE-spezifische Ordner (falls vorhanden)
|
||||
build/
|
||||
.vscode/
|
||||
@@ -40,11 +40,12 @@ int main(void) {
|
||||
// INIT
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
InitWindow(screenWidth, screenHeight, "Raylib Manuell");
|
||||
InitWindow(screenWidth, screenHeight, "Tetris-C");
|
||||
|
||||
Block *block = { 0 };
|
||||
createBlock(&block);
|
||||
int blockMoving = 1;
|
||||
int blockCounter = 1;
|
||||
|
||||
SetTargetFPS(60);
|
||||
|
||||
@@ -56,24 +57,12 @@ int main(void) {
|
||||
// Wenn Block noch nicht auf Boden, dann fallen
|
||||
if (currentBlock->onGround == 0) {
|
||||
|
||||
Block *collisionBlock = block;
|
||||
while (collisionBlock != NULL) {
|
||||
struct Rectangle rect1 = {currentBlock->position.x, currentBlock->position.y, 20, 20};
|
||||
struct Rectangle rect2 = {collisionBlock->position.x, collisionBlock->position.y, 20, 20};
|
||||
|
||||
if (CheckCollisionRecs(rect1, rect2)) {
|
||||
currentBlock->onGround = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (currentBlock->position.y < screenHeight - 20) {
|
||||
currentBlock->position.y += currentBlock->speed;
|
||||
} else {
|
||||
blockMoving = 0;
|
||||
currentBlock->onGround = 1;
|
||||
}
|
||||
|
||||
collisionBlock = collisionBlock->next;
|
||||
if (currentBlock->position.y < screenHeight - 20) {
|
||||
currentBlock->position.y += currentBlock->speed;
|
||||
} else {
|
||||
blockMoving = 0;
|
||||
currentBlock->onGround = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +75,7 @@ int main(void) {
|
||||
// Wenn sich kein Block mehr bewegt, einen neuen erstellen
|
||||
if (blockMoving == 0) {
|
||||
createBlock(&block);
|
||||
blockCounter++;
|
||||
blockMoving = 1;
|
||||
}
|
||||
|
||||
@@ -94,6 +84,7 @@ int main(void) {
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawFPS(20, 20);
|
||||
DrawText(TextFormat("Blocks: %i", blockCounter), 20, 40, 20, GREEN);
|
||||
|
||||
currentBlock = block;
|
||||
while (currentBlock != NULL) {
|
||||
|
||||
Reference in new issue
Block a user