1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 22:09:06 +00:00

added Type Jam puzzle app for review (#1554)

* added Type Jam puzzle app for review

* pr round 2 prep

* updated ci scripts for varfont_shader_puzzle

* resolved unused and minor variable naming issues

* rotator tiles row and col are final vars now

* removed unused import and print from production

* made constructors const where needed

* pages_flow export refactored to directly come from that file

* removed old api commented out section from FragmentShaded

* updated pubspec yaml to correct project name

* dart min version updated; removed unnecessary commented out dependencies from pubspec.yaml

* updated pubspec.yaml min flutter version to ensure FragmentShader support

* added/edited comments for explanation, esp on var fonts; removed obsolete comments

* trailing newline added to pubspec.yaml eof
This commit is contained in:
Brian James
2023-01-12 19:40:47 -05:00
committed by GitHub
parent bea2ef6c66
commit 057728c5d2
164 changed files with 8214 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
// Copyright 2023 The Flutter team. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
class PuzzleModel {
final int dim; // num tiles in any one dir; dim x dim board
// 2d array like a board
// x is the tileID and its position in the array mirrors the board
List<List<int>> positions = [<int>[]];
// rotation states, where index == tileID
// x is num of CCW rotations off from correct (x % 4 == 0 indicates correct)
List<int> status = [];
PuzzleModel({required this.dim}) {
for (int i = 0; i < dim; i++) {
if (positions[positions.length - 1].length == dim) {
positions.add(<int>[]);
}
positions[positions.length - 1].add(i);
status.add(0);
}
}
bool allRotationsCorrect() {
for (int i = 0; i < status.length; i++) {
if (status[i] % 4 != 0) {
return false;
}
}
return true;
}
void setTileStatus(int tileID, int newStatus) {
status[tileID] = newStatus;
}
int getTileStatus(int tileID) {
return status[tileID];
}
void rotateTile(int tileID) {
status[tileID]--;
}
int getRotationOfTile(int tileID) {
return status[tileID];
}
}