Created
October 31, 2012 02:21
-
-
Save colwem/3984434 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Game | |
| def initialize | |
| @board = Board.new 100,100 | |
| add_objects | |
| end | |
| def add_objects | |
| #add objects to board | |
| @board.add Movable.new 1,2 | |
| @board.add Movable.new 1,3 | |
| @board.add Imovable.new 2,2 | |
| @board.add Mob.new 3,4 | |
| @hero = Hero.new | |
| @board.add @hero | |
| end | |
| # called by the engine | |
| def move x_move, y_move | |
| @hero.x += x_move | |
| @hero.y += y_move | |
| display @board | |
| end | |
| # send to the engine | |
| def display @board | |
| end | |
| end | |
| class Board | |
| def initialize x, y | |
| @max_x, @max_y = x,y | |
| @representation = [][] | |
| end | |
| def add addable | |
| @representation[addable.x][addable.y] = addable | |
| end | |
| end | |
| class Entity | |
| def initialize x,y | |
| @x, @y = x,y | |
| end | |
| end | |
| class Hero < Entity | |
| end | |
| class Mob < Entity | |
| end | |
| class Immovable < Entity | |
| end | |
| class Movable < Entity | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment