fantasy 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -4
- data/lib/fantasy/actor.rb +3 -3
- data/lib/fantasy/global.rb +1 -1
- data/lib/fantasy/hud_image.rb +2 -2
- data/lib/fantasy/image.rb +42 -0
- data/lib/fantasy/sound.rb +5 -2
- data/lib/fantasy/version.rb +1 -1
- data/lib/fantasy.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98083689a972e68c27f07ae5c9c8ef9818c1b1215fbf2baccc541233efca6827
|
4
|
+
data.tar.gz: db32ef03fd54c4711b9b38b9f4e3f4ad587839fc4d78523982c6c69f85cb0ab4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a6d2c503880c672d147909cd5ab5a88639ab4e3e019ea5b81601c4aa0cc967e03e5c8b48f1994309ab379e83012f5a103043ba6b64989ba8009d2c7e3950174
|
7
|
+
data.tar.gz: 93f37ba3a6fde17d55ba7aa203a1ade6645e69af8d670d37b5a7d78442c5c1dc4bb115784520cbd5b6a9ef661b18e6dbc2b094dab4c2a54feca8d37e4c527303
|
data/README.md
CHANGED
@@ -103,9 +103,10 @@ Actors in the game will be rendered in the relative position to this camera.
|
|
103
103
|
|
104
104
|
Easy to configure 3 basic game states:
|
105
105
|
|
106
|
-
-
|
107
|
-
- Game
|
108
|
-
- Game
|
106
|
+
- Game presentation scene
|
107
|
+
- Game game scene
|
108
|
+
- Game end scene
|
109
|
+
- Other scenes, like levels or such (TODO)
|
109
110
|
|
110
111
|
Each state should be independent and unique Actors and other elements can be created and configured for each state
|
111
112
|
|
@@ -123,9 +124,17 @@ Move the core functions to the top level hierarchy so I don't need to create a `
|
|
123
124
|
|
124
125
|
Direct and easy way to play a sound
|
125
126
|
|
127
|
+
### Background
|
128
|
+
|
129
|
+
Simple way to set up:
|
130
|
+
|
131
|
+
- Background color
|
132
|
+
- Image background (TODO)
|
133
|
+
- Repeatable image background (TODO)
|
134
|
+
|
126
135
|
### Data Persistance (TODO)
|
127
136
|
|
128
|
-
Simple
|
137
|
+
Simple mechanism to save data in disk. For user preferences, game progress, high scores and others
|
129
138
|
|
130
139
|
### User Inputs
|
131
140
|
|
@@ -147,6 +156,7 @@ Easy access to keyboard and mouse inputs on any part of the code. Specially in t
|
|
147
156
|
## Bugs
|
148
157
|
|
149
158
|
- When dragging in debug mode new elements are being added to the drag (TODO)
|
159
|
+
- Rubocop is not passing
|
150
160
|
|
151
161
|
## Development
|
152
162
|
|
data/lib/fantasy/actor.rb
CHANGED
@@ -3,7 +3,7 @@ class Actor
|
|
3
3
|
attr_accessor :position, :direction, :speed, :solid, :scale, :name, :layer
|
4
4
|
|
5
5
|
def initialize(image_name)
|
6
|
-
@image =
|
6
|
+
@image = Image.new(image_name)
|
7
7
|
@name = image_name
|
8
8
|
@position = Coordinates.new(0, 0)
|
9
9
|
@direction = Coordinates.new(0, 0)
|
@@ -23,7 +23,7 @@ class Actor
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def image=(image_name)
|
26
|
-
@image =
|
26
|
+
@image = Image.new(image_name)
|
27
27
|
end
|
28
28
|
|
29
29
|
def width
|
@@ -44,7 +44,7 @@ class Actor
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def draw
|
47
|
-
@image.draw(position_in_camera.x, position_in_camera.y,
|
47
|
+
@image.draw(x: position_in_camera.x, y: position_in_camera.y, scale: @scale)
|
48
48
|
|
49
49
|
draw_debug if Global.debug
|
50
50
|
end
|
data/lib/fantasy/global.rb
CHANGED
@@ -28,7 +28,7 @@ module Global
|
|
28
28
|
@clocks = []
|
29
29
|
@last_frame_at = Time.now
|
30
30
|
@debug = false
|
31
|
-
@pixel_font = Gosu::Font.new(20, { name: "#{__dir__}
|
31
|
+
@pixel_font = Gosu::Font.new(20, { name: "#{__dir__}/../../fonts/VT323-Regular.ttf" } )
|
32
32
|
@d_key_pressed = false
|
33
33
|
@references = OpenStruct.new
|
34
34
|
@camera = Camera.new(position: Coordinates.zero)
|
data/lib/fantasy/hud_image.rb
CHANGED
@@ -4,7 +4,7 @@ class HudImage
|
|
4
4
|
attr_accessor :name, :scale, :color, :visible, :position, :layer
|
5
5
|
|
6
6
|
def initialize(position:, image_name: )
|
7
|
-
@image =
|
7
|
+
@image = Image.new(image_name)
|
8
8
|
@name = image_name
|
9
9
|
@position = position
|
10
10
|
@scale = 1
|
@@ -30,7 +30,7 @@ class HudImage
|
|
30
30
|
|
31
31
|
def draw
|
32
32
|
if visible
|
33
|
-
@image.draw(@position.x, @position.y,
|
33
|
+
@image.draw(x: @position.x, y: @position.y, scale: @scale)
|
34
34
|
end
|
35
35
|
|
36
36
|
draw_debug if Global.debug
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Image
|
2
|
+
def initialize(image_name)
|
3
|
+
@image = Image.load(image_name)
|
4
|
+
end
|
5
|
+
|
6
|
+
def draw(x:, y:, scale: 1)
|
7
|
+
@image.draw(x, y, 0, scale, scale)
|
8
|
+
end
|
9
|
+
|
10
|
+
def width
|
11
|
+
@image.width
|
12
|
+
end
|
13
|
+
|
14
|
+
def height
|
15
|
+
@image.height
|
16
|
+
end
|
17
|
+
|
18
|
+
class << self
|
19
|
+
@@images = {}
|
20
|
+
|
21
|
+
def load(image_name)
|
22
|
+
locate_image(image_name)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def locate_image(image_name)
|
28
|
+
return @@images[image_name] if @@images[image_name]
|
29
|
+
|
30
|
+
puts "Initialize image: '#{image_name}'"
|
31
|
+
|
32
|
+
base_path = "#{Dir.pwd}/images"
|
33
|
+
file_name = Dir.entries(base_path).find { |e| e.start_with?("#{image_name}.") }
|
34
|
+
|
35
|
+
raise "Image file not found with name '#{image_name}'" if file_name.nil?
|
36
|
+
|
37
|
+
@@images[image_name] = Gosu::Image.new("#{base_path}/#{file_name}", { retro: true })
|
38
|
+
|
39
|
+
return @@images[image_name]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/fantasy/sound.rb
CHANGED
@@ -11,8 +11,11 @@ module Sound
|
|
11
11
|
|
12
12
|
puts "Initialize Sound: '#{sound_name}'"
|
13
13
|
|
14
|
-
base_path = "#{
|
15
|
-
file_name = Dir.entries(base_path).find { |e| e.start_with?(sound_name) }
|
14
|
+
base_path = "#{Dir.pwd}/sounds"
|
15
|
+
file_name = Dir.entries(base_path).find { |e| e.start_with?("#{sound_name}.") }
|
16
|
+
|
17
|
+
raise "Sound file not found with name '#{sound_name}'" if file_name.nil?
|
18
|
+
|
16
19
|
@@sounds[sound_name] = Gosu::Sample.new("#{base_path}/#{file_name}")
|
17
20
|
|
18
21
|
return @@sounds[sound_name]
|
data/lib/fantasy/version.rb
CHANGED
data/lib/fantasy.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fantasy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernando Guillen
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- lib/fantasy/global.rb
|
68
68
|
- lib/fantasy/hud_image.rb
|
69
69
|
- lib/fantasy/hud_text.rb
|
70
|
+
- lib/fantasy/image.rb
|
70
71
|
- lib/fantasy/loop.rb
|
71
72
|
- lib/fantasy/sound.rb
|
72
73
|
- lib/fantasy/utils.rb
|