Skip to content

Commit

Permalink
incomplete anvil
Browse files Browse the repository at this point in the history
  • Loading branch information
IonutParau committed Jul 22, 2023
1 parent 8d96a45 commit 92d58c6
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 17 deletions.
Binary file added assets/images/movers/anvil.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 1 addition & 14 deletions lib/layout/game_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,7 @@ class _GameUIState extends State<GameUI> with TickerProviderStateMixin {
void initState() {
game = PuzzleGame();
game.edType = widget.editorType;
game.ip = widget.ip;
// editorMenuWidthController.addListener(
// () {
// print(editorMenuWidthController.text);
// // game.overlays.remove('EditorMenu');
// // game.overlays.add('EditorMenu');
// },
// );
// editorMenuHeightController.addListener(
// () {
// // game.overlays.remove('EditorMenu');
// // game.overlays.add('EditorMenu');
// },
// );
game.ip = widget.ip;

super.initState();
}
Expand Down
14 changes: 14 additions & 0 deletions lib/logic/cell_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ final cells = {
"stable_p",
"stable_s",
"stable_o",
"anvil",
}.toList();

final modded = <String>[];
Expand All @@ -399,6 +400,7 @@ final cursorTextures = ["cursor", ...cells, "invis_tool", "trick_tool"]..removeW
final textureMapBackup = HashMap<String, String>.from(textureMap);

HashMap<String, String> textureMap = HashMap.from({
"anvil.png": "movers/anvil.png",
"electric_puller.png": "electrical/electric_puller.png",
"stable_a.png": "stableton/stable_a.png",
"stable_b.png": "stableton/stable_b.png",
Expand Down Expand Up @@ -1008,6 +1010,7 @@ final categories = [
],
"liner",
),
"anvil",
],
"mover",
),
Expand Down Expand Up @@ -3275,6 +3278,10 @@ final cellInfo = <String, CellProfile>{
"Stableton O",
"Combination of Stableton P and Stableton S. Decays into Stableton S and Stableton P",
),
"anvil": CellProfile(
"Anvil",
"Falls down, breaks stuff.",
),
};

enum CellPropertyType {
Expand Down Expand Up @@ -3538,4 +3545,11 @@ Map<String, List<CellProperty>> props = {
CellProperty("Left", "The rotation for the cell to the left", "left", CellPropertyType.integer, 0),
CellProperty("Right", "The rotation for the cell to the right", "right", CellPropertyType.integer, 0),
],
"anvil": [
CellProperty("Gravity", "How quickly the cell accelerates downwards. By default it is 0.7 cell per tick.", "gravity", CellPropertyType.number, 0.7),
CellProperty("Velocity", "How fast it is currently going. Changes over time.", "velocity", CellPropertyType.number, 0.7),
CellProperty("Breaking Velocity", "The speed at which it can start breaking the cells it runs into instead of simply being stopped by them.", "breaking_velocity", CellPropertyType.number, 4),
CellProperty("Loss Upon Lethal Impact", "How quickly the cell accelerates downwards. By default it is 0.7 cell per tick.", "impact_loss", CellPropertyType.number, 0.3),
CellProperty("Terminal Velocity", "The limit of how fast it can fall downwards.", "speed_limit", CellPropertyType.number, 5),
],
};
1 change: 1 addition & 0 deletions lib/logic/grid/subticks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ final subticks = [
transformers,
rots,
gears,
anvil,
grabbers,
speeds,
drillers,
Expand Down
4 changes: 2 additions & 2 deletions lib/logic/logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'dart:io';
import 'dart:math';
import 'package:equatable/equatable.dart';
import 'package:flame/components.dart';
import 'package:flame/extensions.dart';
import 'package:intl/intl.dart' show DateFormat;
import 'package:flame/flame.dart';
import 'package:flutter/material.dart' hide Colors;
import 'package:flutter/services.dart';
Expand All @@ -26,7 +26,6 @@ import 'package:window_manager/window_manager.dart';
import 'package:flame/input.dart' hide ButtonState;
import 'dart:ui' as ui;
import 'package:clipboard/clipboard.dart';
import 'package:intl/intl.dart' show DateFormat;
import 'package:flame/game.dart';
import 'package:flame/image_composition.dart';
import 'package:web_socket_channel/web_socket_channel.dart';
Expand Down Expand Up @@ -110,6 +109,7 @@ part 'update/platform.dart';
part 'update/carriers.dart';
part 'update/stableton.dart';
part 'update/releasers.dart';
part 'update/anvil.dart';

extension SetX on Set<String> {
bool containsAny(Iterable<String> strings) {
Expand Down
12 changes: 12 additions & 0 deletions lib/logic/update/anvil.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
part of logic;

void anvil() {
grid.updateCell((cell, x, y) {
final dir = cell.rot;
final double gravity = cell.data["gravity"];
final double velocity = cell.data["velocity"];
final double breakingVelocity = cell.data["breaking_velocity"];
final double lossUponLethalImpact = cell.data["impact_loss"];
final double terminalVelocity = cell.data["speed_limit"];
}, null, "anvil");
}
3 changes: 2 additions & 1 deletion lib/logic/update/transformers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ enum BreakType {
transform,
burn,
explode,
gravity,
}

bool breakable(Cell c, int x, int y, int dir, BreakType bt) {
Expand All @@ -146,7 +147,7 @@ bool breakable(Cell c, int x, int y, int dir, BreakType bt) {
return false;
}

if (bt == BreakType.transform) {
if (bt == BreakType.transform || bt == BreakType.gravity) {
if (c.id == "pushable") {
return false;
} else if (c.id == "pullable") {
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dependencies:
shelf_web_socket: ^1.0.4
google_fonts: ^4.0.3
image: ^4.0.17
intl: ^0.18.0

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 92d58c6

Please sign in to comment.