mnit_ballz: Display module
authorBlackMinou <romain.chanoir@viacesi.fr>
Mon, 22 Jun 2015 00:02:17 +0000 (02:02 +0200)
committerBlackMinou <romain.chanoir@viacesi.fr>
Wed, 9 Sep 2015 08:36:25 +0000 (10:36 +0200)
Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

examples/mnit_ballz/src/display.nit [new file with mode: 0644]

diff --git a/examples/mnit_ballz/src/display.nit b/examples/mnit_ballz/src/display.nit
new file mode 100644 (file)
index 0000000..1d63189
--- /dev/null
@@ -0,0 +1,47 @@
+# this file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Handles the drawing of all the game
+module display
+
+import game_logic
+
+redef class Ball
+
+       # Draw `self` onto `display` with image from `assets`
+       fun draw(display: Display, assets: Assets)
+       do
+               display.blit_centered(assets.ball, center.x, center.y)
+       end
+end
+
+redef class Wall
+
+       # Draw `self` onto `display` with image from `assets`
+       fun draw(display: Display, assets: Assets)
+       do
+               display.blit_rotated(assets.vertical_wall, center.x, center.y, angle)
+       end
+end
+
+redef class Game
+
+       # Draw all the entities onto `display`
+       fun draw(display: Display, assets: Assets)
+       do
+               display.clear (0.0, 0.0, 0.0)
+               ball.draw(display, assets)
+               for wall in walls do wall.draw(display, assets)
+       end
+end