Skip to content

Commit

Permalink
Unify the tile arrays
Browse files Browse the repository at this point in the history
There's no "restart" etc. so for now the code is much simpler by having just one array.
  • Loading branch information
tronical committed Dec 10, 2020
1 parent e75f617 commit 0b84f2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions examples/memory/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ pub fn main() {

let main_window = MainWindow::new();

let tile_options = main_window.get_tile_options();
let mut tiles: Vec<TileData> = tile_options.iter().chain(tile_options.iter()).collect();
let initial_tiles = main_window.get_memory_tiles();
let mut tiles: Vec<TileData> = initial_tiles.iter().chain(initial_tiles.iter()).collect();
shuffle(&mut tiles);
let tiles_model = Rc::new(VecModel::from(tiles));

Expand Down
16 changes: 7 additions & 9 deletions examples/memory/memory.60
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ export MainWindow := Window {
signal check_if_pair_solved();
property <bool> disable_tiles;

property<[TileData]> tile_options: [
property<length> tile_size: 80px;
property<length> tile_spacing: 10px;

width: 4 * tile_size + 5 * tile_spacing;
height: 4 * tile_size + 5 * tile_spacing;

property<[TileData]> memory_tiles : [
{ image: img!"icons/at.png" },
{ image: img!"icons/balance-scale.png" },
{ image: img!"icons/bicycle.png" },
Expand All @@ -96,14 +102,6 @@ export MainWindow := Window {
{ image: img!"icons/video.png" },
];

property<length> tile_size: 80px;
property<length> tile_spacing: 10px;

width: 4 * tile_size + 5 * tile_spacing;
height: 4 * tile_size + 5 * tile_spacing;

property<[TileData]> memory_tiles;

for tile[i] in memory_tiles: MemoryTile {
x: tile_spacing + mod(i, 4) * (tile_size + tile_spacing);
y: tile_spacing + floor(i / 4) * (tile_size + tile_spacing);
Expand Down

0 comments on commit 0b84f2c

Please sign in to comment.