Class: AGL::Res

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

Class Method Summary collapse

Class Method Details

.clearObject

def self.text id G.texts[id.to_sym] end



236
237
238
239
240
241
# File 'lib/minigl/global.rb', line 236

def self.clear
	@@imgs.clear
	@@tilesets.clear
	@@sounds.clear
	@@fonts.clear
end

.font(id, size, global = true, ext = ".ttf") ⇒ Object



223
224
225
226
227
228
229
230
# File 'lib/minigl/global.rb', line 223

def self.font id, size, global = true, ext = ".ttf"
	if global; a = @@global_fonts; else; a = @@fonts; end
	id_size = "#{id}_#{size}"
	return a[id_size] if a[id_size]
	s = "data/font/" + id.to_s.split('_').join('/') + ext
	font = Gosu::Font.new Game.window, s, size
	a[id_size] = font
end

.img(id, global = false, tileable = false, ext = ".png") ⇒ Object



183
184
185
186
187
188
189
# File 'lib/minigl/global.rb', line 183

def self.img id, global = false, tileable = false, ext = ".png"
	if global; a = @@global_imgs; else; a = @@imgs; end
	return a[id] if a[id]
	s = "data/img/" + id.to_s.split('_').join('/') + ext
	img = Gosu::Image.new Game.window, s, tileable
	a[id] = img
end

.imgs(id, sprite_cols, sprite_rows, global = false, ext = ".png") ⇒ Object



191
192
193
194
195
196
197
# File 'lib/minigl/global.rb', line 191

def self.imgs id, sprite_cols, sprite_rows, global = false, ext = ".png"
	if global; a = @@global_imgs; else; a = @@imgs; end
	return a[id] if a[id]
	s = "data/img/" + id.to_s.split('_').join('/') + ext
	imgs = Gosu::Image.load_tiles Game.window, s, -sprite_cols, -sprite_rows, false
	a[id] = imgs
end

.initializeObject



172
173
174
175
176
177
178
179
180
181
# File 'lib/minigl/global.rb', line 172

def self.initialize
	@@imgs = Hash.new
	@@global_imgs = Hash.new
	@@tilesets = Hash.new
	@@global_tilesets = Hash.new
	@@sounds = Hash.new
	@@global_sounds = Hash.new
	@@fonts = Hash.new
	@@global_fonts = Hash.new
end

.song(id, global = false, ext = ".ogg") ⇒ Object



215
216
217
218
219
220
221
# File 'lib/minigl/global.rb', line 215

def self.song id, global = false, ext = ".ogg"
	if global; a = @@global_sounds; else; a = @@sounds; end
	return a[id] if a[id]
	s = "data/song/" + id.to_s.split('_').join('/') + ext
	song = Gosu::Song.new Game.window, s
	a[id] = song
end

.sound(id, global = false, ext = ".wav") ⇒ Object



207
208
209
210
211
212
213
# File 'lib/minigl/global.rb', line 207

def self.sound id, global = false, ext = ".wav"
	if global; a = @@global_sounds; else; a = @@sounds; end
	return a[id] if a[id]
	s = "data/sound/" + id.to_s.split('_').join('/') + ext
	sound = Gosu::Sample.new Game.window, s
	a[id] = sound
end

.tileset(id, tile_width = 32, tile_height = 32, global = false, ext = ".png") ⇒ Object



199
200
201
202
203
204
205
# File 'lib/minigl/global.rb', line 199

def self.tileset id, tile_width = 32, tile_height = 32, global = false, ext = ".png"
	if global; a = @@global_tilesets; else; a = @@tilesets; end
	return a[id] if a[id]
	s = "data/tileset/" + id.to_s.split('_').join('/') + ext
	tileset = Gosu::Image.load_tiles Game.window, s, tile_width, tile_height, true
	a[id] = tileset
end