class Core::Game::Player
Attributes
x[RW]
y[RW]
Public Class Methods
new(x=0, y=0)
click to toggle source
Calls superclass method
# File lib/game/map/player.rb, line 12 def initialize(x=0, y=0) super(x, y, {:file => Core.window.state.party.player.charset}) @speed = 2 @x, @y = x, y @name = "player" @gamename = Core.window.state.party.player.name end
Public Instance Methods
teleport(tx, ty)
click to toggle source
# File lib/game/map/player.rb, line 59 def teleport(tx, ty) if tx < @tx Core.window.state.map.xoff += (@tx - tx) * 32 elsif @tx < tx Core.window.state.map.xoff -= (tx - @tx) * 32 end if ty < @ty Core.window.state.map.yoff += (@ty - ty) * 32 elsif @ty < ty Core.window.state.map.yoff -= (ty - @ty) * 32 end @tx = tx @ty = ty @x = @tx * 32 @y = @ty * 32 end
update()
click to toggle source
Calls superclass method
# File lib/game/map/player.rb, line 20 def update window = Core.window if @dx == 0 and @dy == 0 if window.button_down?(KbLeft) @dx = -32 @dy = 0 destroy_goal elsif window.button_down?(KbRight) @dx = 32 @dy = 0 destroy_goal elsif window.button_down?(KbUp) @dx = 0 @dy = -32 destroy_goal elsif window.button_down?(KbDown) @dx = 0 @dy = 32 destroy_goal end end if window.pressed?(KbSpace) or window.pressed?(KbReturn) or window.pressed?(KbEnter) update_trigger end super if @stepped if @dx < 0 Core.window.state.map.xoff += @speed elsif @dx > 0 Core.window.state.map.xoff -= @speed end if @dy < 0 Core.window.state.map.yoff += @speed elsif @dy > 0 Core.window.state.map.yoff -= @speed end end end