Skip to content

Commit

Permalink
try to resolve twin image flickering
Browse files Browse the repository at this point in the history
  • Loading branch information
dzenanr committed May 28, 2013
1 parent 76f311c commit 9de99b1
Show file tree
Hide file tree
Showing 23 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion educ_memory_game.html
Expand Up @@ -38,7 +38,7 @@ <h1>educ_memory_game</h1>
<ul>
<li>
<a href="https://github.com/dzenanr/educ_memory_game">
Last Version
the last version with spirals in the spirals folder
</a>
</li>
</ul>
Expand Down
Binary file modified images/adventure.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/albion.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/alien.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/angry_birds.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/cars.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/dices.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/empire.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/ewe.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/football.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/hitman2.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/hunger.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/magic.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/mario.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/monsters.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/planet.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/racing.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/samurai.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/spiderman.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/wargame.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/warriors.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/wars2.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 17 additions & 7 deletions view/board.dart
Expand Up @@ -14,16 +14,25 @@ class Board {
Memory memory;
Cell lastCellClicked;

var imageMap = new Map<String, ImageElement>();

Board(this.canvas, this.memory) {
context = canvas.getContext('2d');
size = canvas.width;
boxSize = size / memory.length;
_createImages(memory);
query('#canvas').onMouseDown.listen(onMouseDown);
new Timer.periodic(const Duration(milliseconds: INTERVAL), (t) => draw());
}

_createImages(Memory memory) {
for (var cell in memory.cells) {
ImageElement image = new Element.tag('img');
image.src = 'images/${cell.image}';
imageMap[cell.image] = image;
}
}

void draw() {
_clear();
_boxes();
Expand Down Expand Up @@ -54,12 +63,13 @@ class Board {
context.arc(centerX, centerY, radius, 0, 2 * PI, false);
} else {
var imagePath = 'images/${cell.image}';
ImageElement img = new Element.tag('img');
img.src = imagePath;
img.onLoad.listen((event) {
//context.clearRect(x, y, boxSize, boxSize);
context.drawImageToRect(img, new Rect(x, y, boxSize, boxSize));
});
ImageElement image = new Element.tag('img');
image.src = imagePath;
//ImageElement imageElement = imageMap[cell.image];
image.onLoad.listen((event) {
context.drawImageToRect(image, new Rect(x, y, boxSize, boxSize));
//context.drawImage(image, x, y);
});
}
context.rect(x, y, boxSize, boxSize);
context.fill();
Expand Down

0 comments on commit 9de99b1

Please sign in to comment.