Class: Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/processor.rb

Overview

transitions and keeping track of windows

Constant Summary collapse

Screen =
[1024, 768, false]
TileSize =
48
Caption =
"Blast Mavens: Multiplayer Beta v0.1.4"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.playersObject

Returns the value of attribute players.



19
20
21
# File 'lib/processor.rb', line 19

def players
  @players
end

.windowObject (readonly)

Returns the value of attribute window.



18
19
20
# File 'lib/processor.rb', line 18

def window
  @window
end

Class Method Details

.all_bombsObject



47
48
49
# File 'lib/processor.rb', line 47

def all_bombs
  players.map {|p| p.bombs}.flatten
end

.allow_multiplayer?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/processor.rb', line 31

def allow_multiplayer?
  true
end

.center_for(x, y) ⇒ Object



43
44
45
# File 'lib/processor.rb', line 43

def center_for(x, y)
  [center_for_coord(x), center_for_coord(y)]
end

.center_mapObject



35
36
37
38
39
40
41
# File 'lib/processor.rb', line 35

def center_map
  @center_map ||={}.tap do |center_coords|
    (0...768).each_slice(48) do |coords_range|
      center_coords[coords_range[24]] = coords_range
    end
  end
end

.closeObject



60
61
62
# File 'lib/processor.rb', line 60

def close
  @window.close
end

.game_over(death_toll) ⇒ Object



56
57
58
# File 'lib/processor.rb', line 56

def game_over(death_toll)
  @window.set_delegate("GameOver", death_toll)
end

.has_at_least_one_player?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/processor.rb', line 27

def has_at_least_one_player?
  !players.empty?
end

.newObject



21
22
23
24
25
# File 'lib/processor.rb', line 21

def new
  @players = []
  @window = Window.new("Menu")
  @window.show
end

.solid_at?(x, y) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/processor.rb', line 64

def solid_at?(x,y)
  @window.map ? @window.map.solid_at?(x,y) : false
end

.start_gameObject



51
52
53
54
# File 'lib/processor.rb', line 51

def start_game
  2.times { @players << Player.new }
  @window.set_delegate("Game")
end