Permalink
Browse files

Improved graphics.

  • Loading branch information...
1 parent 31ec833 commit 9dfebd281a0db7fd5b3dc3e09d2e71ff7c22e984 @kaisellgren kaisellgren committed Sep 4, 2012
View
Deleted file not rendered
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -25,7 +25,7 @@ public function __construct()
$temp = array();
for ($column = 0; $column < 20; $column++) {
- $temp[] = new GameObject(floor(mt_rand(0, 2)));
+ $temp[] = new GameObject(floor(mt_rand(0, 3))); // Randomize the game object type. TODO: Change this.
}
$this->gameArea[] = $temp;
@@ -12,6 +12,7 @@ class GameObject
const TYPE_EMPTY = 2; // Discovered.
const TYPE_NUMBER = 3; // Discovered.
const TYPE_EXPLOSION = 4; // Damn we hit a mine!
+ const TYPE_MINE_DISCOVERED = 5;
public $type;
@@ -34,4 +35,12 @@ public function isEmpty()
{
return $this->type === GameObject::TYPE_EMPTY;
}
+
+ /**
+ * Returns the number of mines around this cell.
+ */
+ public function getNumber()
+ {
+ return floor(mt_rand(0, 7)) + 1;
+ }
}
@@ -1,12 +1,24 @@
-html, body {
+html {
background: #eee;
+ margin: 0 64px;
+}
+
+body {
font-family: "Segoe UI", sans-serif;
- margin: 16px 32px;
+}
+
+h1 {
+ font-size: 50px;
+}
+
+#game {
+ border-spacing: 0;
+ border-collapse: collapse;
+ box-shadow: 0 0 16px 8px rgba(0, 0, 0, 0.25);
}
.game-cell {
- background: #ddd;
- border: 1px solid #aaa;
+ border: 1px solid #fff;
cursor: pointer;
width: 64px;
height: 64px;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -8,17 +8,27 @@
{% for row in 0..9 %}
<tr>
{% for column in 0..19 %}
- <td class="game-cell">
- {# Randomize what's in there... TODO: render the correct visual. #}
- {% set type = gameArea[row][column].type %}
+ {# Define variables. #}
+ {% set gameObject = gameArea[row][column] %}
+ {% set type = gameObject.type %}
+
+ <td class="game-cell" data-type="{{ type }}">
{% if type == constant('Loiste\\MinesweeperBundle\\Model\\GameObject::TYPE_NUMBER') %}
- <div class="game-number">3</div>
+ <img src="{{ asset('bundles/loisteminesweeper/images/' ~ gameObject.number ~ '.png') }}" />
{% endif %}
- {% if type == constant('Loiste\\MinesweeperBundle\\Model\\GameObject::TYPE_MINE') %}
+ {% if type == constant('Loiste\\MinesweeperBundle\\Model\\GameObject::TYPE_MINE_DISCOVERED') %}
<img src="{{ asset('bundles/loisteminesweeper/images/mine.png') }}" />
{% endif %}
+
+ {% if type == constant('Loiste\\MinesweeperBundle\\Model\\GameObject::TYPE_UNDISCOVERED') or type == constant('Loiste\\MinesweeperBundle\\Model\\GameObject::TYPE_MINE') %}
+ <img src="{{ asset('bundles/loisteminesweeper/images/cell.png') }}" />
+ {% endif %}
+
+ {% if type == constant('Loiste\\MinesweeperBundle\\Model\\GameObject::TYPE_EMPTY') %}
+ <img src="{{ asset('bundles/loisteminesweeper/images/empty.png') }}" />
+ {% endif %}
</td>
{% endfor %}
</tr>

0 comments on commit 9dfebd2

Please sign in to comment.