Skip to content

Commit

Permalink
refactor: 💡 delete dart:ffi
Browse files Browse the repository at this point in the history
  • Loading branch information
panicdragon committed Jun 6, 2024
1 parent 3182e93 commit 69c3dc2
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions lib/game.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:ffi';

import 'package:flame/components.dart' hide Timer;
import 'package:flame/game.dart';
import 'package:flame/input.dart';
Expand Down Expand Up @@ -35,22 +33,24 @@ class MainGame extends FlameGame with KeyboardEvents, HasGameRef {
final row = _tetris.displayBuffer[y];
for (var x = 0; x < row.length; x++) {
if (row[x] == 1) {
_wallComponentList.add(createBlock(x + 1, y + 1, getBlockPaint(row[x])));
_wallComponentList
.add(createBlock(x + 1, y + 1, getBlockPaint(row[x])));
} else if (row[x] > 1) {
_rectComponentList.add(createBlock(x + 1, y + 1, getBlockPaint(row[x])));
_rectComponentList
.add(createBlock(x + 1, y + 1, getBlockPaint(row[x])));
}
}
}

for(var wall in _wallComponentList) {
for (var wall in _wallComponentList) {
add(wall);
}
for(var rect in _rectComponentList) {
for (var rect in _rectComponentList) {
add(rect);
}

createNextMino();
for(var nextMino in _nextMinoComponentList) {
for (var nextMino in _nextMinoComponentList) {
add(nextMino);
}

Expand All @@ -73,7 +73,7 @@ class MainGame extends FlameGame with KeyboardEvents, HasGameRef {

resetRenderNextMino();
createNextMino();
for(var nextMino in _nextMinoComponentList) {
for (var nextMino in _nextMinoComponentList) {
add(nextMino);
}
}
Expand All @@ -83,11 +83,12 @@ class MainGame extends FlameGame with KeyboardEvents, HasGameRef {
final row = _tetris.nextMinoShapeArray[y];
for (var x = 0; x < row.length; x++) {
if (row[x] > 1) {
_nextMinoComponentList.add(createBlock(x + 1, y + 1, getBlockPaint(row[x])));
_nextMinoComponentList
.add(createBlock(x + 1, y + 1, getBlockPaint(row[x])));
}
}
}
for(var nextMino in _nextMinoComponentList) {
for (var nextMino in _nextMinoComponentList) {
nextMino.position.x = nextMino.position.x + 340;
nextMino.position.y = nextMino.position.y + 40;
}
Expand Down Expand Up @@ -121,11 +122,12 @@ class MainGame extends FlameGame with KeyboardEvents, HasGameRef {
final row = _tetris.displayBuffer[y];
for (var x = 0; x < row.length; x++) {
if (row[x] > 1) {
_rectComponentList.add(createBlock(x + 1, y + 1, getBlockPaint(row[x])));
_rectComponentList
.add(createBlock(x + 1, y + 1, getBlockPaint(row[x])));
}
}
}
for(var rect in _rectComponentList) {
for (var rect in _rectComponentList) {
add(rect);
}
}
Expand All @@ -139,13 +141,14 @@ class MainGame extends FlameGame with KeyboardEvents, HasGameRef {

void renderNextMino() {
createNextMino();
for(var nextMino in _nextMinoComponentList) {
for (var nextMino in _nextMinoComponentList) {
add(nextMino);
}
}

TextComponent getRenderText(String text, double x, double y) {
const style = TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold);
const style = TextStyle(
color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold);
final regular = TextPaint(style: style);

return TextComponent(text: text, textRenderer: regular)
Expand Down

0 comments on commit 69c3dc2

Please sign in to comment.