minigl 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c609dbc0621741237b9193a8acff2151404e8d0a
4
- data.tar.gz: c8d76c2b7804caf0fbd25025a511a8dde9068bfe
3
+ metadata.gz: 859235b4f4ca7a187676a2b0ca361c9e68342446
4
+ data.tar.gz: 3ffb1d97296310a592421f6a87f2792778f75308
5
5
  SHA512:
6
- metadata.gz: 2865a6ead36b00eb323c31d7ce95f455942b4f34e6c73d428a9ab2fb886229807b86e2f68fc621344bf15047c9c479486cbaf88e73f8c4e2facd048c5c9207f7
7
- data.tar.gz: 53ee3334a0f8a3f784c844e6823dba41b32e93a4f7856ad157974600cf72b8275cffd707e96275b1b482c57cbc5e961d3fb85a0b68780fed915226bd74e52c1e
6
+ metadata.gz: 6999c1e096ba097a8f3581ff17ca25fecbf6483c9db382f941a1721f9079f5410c12eda60d5da30d59ee81504940c8e595a44998014f09fb281a1a6756a9dc12
7
+ data.tar.gz: d095c9838aab0c9c153ef3a5bf2c6534aae66df9696afad6e9e35d27fc5024c5235cb2f9d794afa0e05bccf47bee2d94415c2943330075115f595e812a144318
data/README.md CHANGED
@@ -1,12 +1,22 @@
1
1
  # MiniGL
2
2
 
3
- MiniGL is a minimal Game Library, available as a Ruby gem, and built on top of
4
- the [Gosu](http://www.libgosu.org/) gem.
3
+ MiniGL is a minimal **2D Game** Library, available as a Ruby gem, and built on
4
+ top of the [Gosu](http://www.libgosu.org/) gem.
5
+
6
+ It provides the following features:
7
+ * Resource management (images, sounds, ...)
8
+ * Input manipulation (keyboard, mouse, ...)
9
+ * UI (text, buttons, text fields, ...)
10
+ * Basic physics and collision checking
11
+ * Animated objects
12
+
13
+ More functionalities are coming. Feel free to contribute!
5
14
 
6
15
  Please note:
7
16
 
8
17
  * The test package is not complete! Most of the functionality
9
18
  provided by the gem is difficult to test automatically, but you can check out
10
19
  this [working game example](https://github.com/victords/aventura-do-saber).
11
- * The documentation is under construction.
20
+ * The [documentation](https://github.com/victords/minigl/wiki) is under
21
+ construction.
12
22
 
Binary file
Binary file
@@ -166,6 +166,8 @@ module AGL
166
166
  @@global_imgs = Hash.new
167
167
  @@sounds = Hash.new
168
168
  @@global_sounds = Hash.new
169
+ @@fonts = Hash.new
170
+ @@global_fonts = Hash.new
169
171
  end
170
172
 
171
173
  def self.img id, global = false, tileable = false, ext = ".png"
@@ -192,29 +194,38 @@ module AGL
192
194
  a[id] = tileset
193
195
  end
194
196
 
195
- def self.sound id, global = false
197
+ def self.sound id, global = false, ext = ".wav"
196
198
  if global; a = @@global_sounds; else; a = @@sounds; end
197
199
  return a[id] if a[id]
198
- s = "data/sound/se/" + id.to_s.split('_').join('/') + ".wav"
200
+ s = "data/sound/se/" + id.to_s.split('_').join('/') + ext
199
201
  sound = Gosu::Sample.new Game.window, s
200
202
  a[id] = sound
201
203
  end
202
204
 
203
- def self.song id, global = false
205
+ def self.song id, global = false, ext = ".ogg"
204
206
  if global; a = @@global_sounds; else; a = @@sounds; end
205
207
  return a[id] if a[id]
206
- s = "data/sound/bgm/" + id.to_s.split('_').join('/') + ".ogg"
208
+ s = "data/sound/bgm/" + id.to_s.split('_').join('/') + ext
207
209
  song = Gosu::Song.new Game.window, s
208
210
  a[id] = song
209
211
  end
212
+
213
+ def self.font id, size, global = true, ext = ".ttf"
214
+ if global; a = @@global_fonts; else; a = @@fonts; end
215
+ return a[id] if a[id]
216
+ s = "data/font/" + id.to_s.split('_').join('/') + ext
217
+ font = Gosu::Font.new Game.window, s, size
218
+ a[id] = font
219
+ end
210
220
 
211
221
  # def self.text id
212
222
  # G.texts[G.lang][id.to_sym]
213
223
  # end
214
224
 
215
225
  def self.clear
216
- @imgs.clear
217
- @sounds.clear
226
+ @@imgs.clear
227
+ @@sounds.clear
228
+ @@fonts.clear
218
229
  end
219
230
  end
220
231
  end
@@ -0,0 +1,40 @@
1
+ require_relative '../lib/minigl'
2
+ include AGL
3
+
4
+ class MyGame < Gosu::Window
5
+ def initialize
6
+ super 800, 600, false # creating a 800 x 600 window, not full screen
7
+ Game.initialize self # initializing MiniGL for this window
8
+
9
+ @img = Res.img :img1
10
+ @font = Res.font :font1, 20
11
+ @x = 0
12
+ @y = 0
13
+ end
14
+
15
+ def needs_cursor?
16
+ true
17
+ end
18
+
19
+ def update
20
+ KB.update
21
+ @y -= 1 if KB.key_down? Gosu::KbUp
22
+ @x += 1 if KB.key_down? Gosu::KbRight
23
+ @y += 1 if KB.key_down? Gosu::KbDown
24
+ @x -= 1 if KB.key_down? Gosu::KbLeft
25
+
26
+ Mouse.update
27
+ if Mouse.button_pressed? :left
28
+ @x = Mouse.x - @img.width / 2
29
+ @y = Mouse.y - @img.height / 2
30
+ end
31
+ end
32
+
33
+ def draw
34
+ @img.draw @x, @y, 0
35
+ @font.draw "Testing fonts", 20, 560, 0
36
+ end
37
+ end
38
+
39
+ game = MyGame.new
40
+ game.show
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minigl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor David Santos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-25 00:00:00.000000000 Z
11
+ date: 2014-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gosu
@@ -30,7 +30,7 @@ dependencies:
30
30
  - - '>='
31
31
  - !ruby/object:Gem::Version
32
32
  version: 0.7.50
33
- description: A minimal Game Library built on top of the Gosu gem.
33
+ description: A minimal 2D Game Library built on top of the Gosu gem.
34
34
  email: victordavidsantos@gmail.com
35
35
  executables: []
36
36
  extensions: []
@@ -39,7 +39,9 @@ files:
39
39
  - LICENSE
40
40
  - README.md
41
41
  - Rakefile
42
+ - data/font/font1.ttf
42
43
  - data/img/image.png
44
+ - data/img/img1.png
43
45
  - lib/minigl.rb
44
46
  - lib/minigl/forms.rb
45
47
  - lib/minigl/game_object.rb
@@ -47,6 +49,7 @@ files:
47
49
  - lib/minigl/map.rb
48
50
  - lib/minigl/movement.rb
49
51
  - lib/minigl/text.rb
52
+ - test/game.rb
50
53
  - test/game_object_tests.rb
51
54
  - test/map_tests.rb
52
55
  - test/movement_tests.rb
@@ -77,4 +80,5 @@ summary: MiniGL
77
80
  test_files:
78
81
  - test/movement_tests.rb
79
82
  - test/map_tests.rb
83
+ - test/game.rb
80
84
  - test/game_object_tests.rb