-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start work on healer, weapons and enemy..
- Loading branch information
David Henry
committed
Feb 13, 2012
1 parent
78809b6
commit 7470530
Showing
25 changed files
with
536 additions
and
242 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Game | ||
class Object | ||
module Enemy | ||
end | ||
end | ||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class Game | ||
class Object | ||
module Healer | ||
def auto_process | ||
self.health -= Game::Player.instance.heal(health) | ||
self.location.remove(self) if self.health == 0 | ||
end | ||
|
||
def health | ||
@health ||= @options['health'] | ||
end | ||
|
||
def health=(val) | ||
@health = val | ||
end | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Game | ||
class Object | ||
module Weapon | ||
def equip | ||
Game::Player.instance.equip('weapon', self) | ||
end | ||
|
||
def attack | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
module Render | ||
class Console | ||
module DrawMap | ||
class Tile | ||
attr_reader :tile | ||
|
||
def initialize(tile) | ||
@tile = tile | ||
end | ||
|
||
def draw | ||
if tile.is_a?(Game::Location::Wall) | ||
draw_player(draw_wall) | ||
else | ||
draw_player(draw_empty) | ||
end | ||
end | ||
|
||
def draw_player(base) | ||
return base unless tile.has_object?(Game::Player) | ||
base[0] + | ||
case Game::Player.instance.direction | ||
when :up | ||
'^' | ||
when :down | ||
'v' | ||
when :left | ||
'<' | ||
when :right | ||
'>' | ||
else | ||
'*' | ||
end + | ||
base[2] | ||
end | ||
|
||
def draw_empty | ||
{ | ||
Game::Object::Switcher => 'SSS', | ||
Game::Object::Setter => 'SSS', | ||
Game::Object::Exit => 'EEE', | ||
Game::Object::LocationModifier => 'TTT', | ||
Game::Object::Trap => '###', | ||
|
||
Game::Object::Enemy => '|:P', | ||
Game::Object::Healer => '+++', | ||
Game::Object::Weapon => '+--' | ||
}.each do |module_name, tile_piece| | ||
|
||
return tile_piece if tile.has_object?(module_name) | ||
end | ||
|
||
return 'KKK' if defined?(Game::Object::Key) && tile.has_object?(Game::Object::Key) | ||
' ' | ||
end | ||
|
||
def draw_wall | ||
if tile.has_object?(Game::Object::Passage) | ||
return 'D D' if tile.passible?([]) | ||
return 'DDD' | ||
end | ||
|
||
base = { | ||
Game::Location::WALL_90 => ' | ', | ||
Game::Location::WALL_CORNER_RIGHT => ' +-', | ||
Game::Location::WALL_CORNER_LEFT => '-+ ', | ||
Game::Location::WALL_0 => '---', | ||
Game::Location::WALL_CORNER => '-+-' | ||
}[tile.location_type] || (debugger) | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.