Class: Physicist::Laboratory::Screen

Inherits:
Dedalus::Screen
  • Object
show all
Includes:
Dedalus::Elements
Defined in:
lib/physicist/laboratory/screen.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cameraObject

Returns the value of attribute camera.



5
6
7
# File 'lib/physicist/laboratory/screen.rb', line 5

def camera
  @camera
end

#map_gridObject

Returns the value of attribute map_grid.



5
6
7
# File 'lib/physicist/laboratory/screen.rb', line 5

def map_grid
  @map_grid
end

#scientistObject

Returns the value of attribute scientist.



5
6
7
# File 'lib/physicist/laboratory/screen.rb', line 5

def scientist
  @scientist
end

Instance Method Details

#avatar_for(scientist) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/physicist/laboratory/screen.rb', line 33

def avatar_for(scientist)
  Dedalus::Elements::Sprite.new(
    path: 'media/images/walk.png',
    frame: 0,
    invert_x: false,
    asset_width: 64,
    asset_height: 64,
    scale: 2.0
  )
end

#fieldObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/physicist/laboratory/screen.rb', line 16

def field
  SpriteField.new(
    grid: map_grid,
    scale: 1.0,
    camera_location: camera,
    tiles_path: "media/images/tiles.png",
    tile_width: 64,
    tile_height: 64,
    tile_class: "Dedalus::Elements::MapTile",
    sprite_map: sprite_map
  )
end

#headingObject



44
45
46
47
48
49
# File 'lib/physicist/laboratory/screen.rb', line 44

def heading
  [
    Heading.new(text: "[Physics Laboratory]"),
    Paragraph.new(text: "Hello, #{scientist.name_with_title}")
  ]
end

#showObject



7
8
9
10
11
12
13
14
# File 'lib/physicist/laboratory/screen.rb', line 7

def show
  [
    Paragraph.new(text: "Welcome to the lab, #{scientist.display_name}!"),
    Paragraph.new(text: "Pos: #{scientist.current.position}"),
    Paragraph.new(text: "Vel: #{scientist.current.velocity}"),
    field
  ]
end

#sprite_mapObject



29
30
31
# File 'lib/physicist/laboratory/screen.rb', line 29

def sprite_map
  { scientist.current.position => [avatar_for(scientist)] }
end