Ronela 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LEAME +1 -1
- data/lib/ronela.rb +66 -14
- metadata +2 -2
data/LEAME
CHANGED
@@ -18,7 +18,7 @@ Se crea el personaje que va a decir algo
|
|
18
18
|
- Personaje <nombre personaje> <apodo=...> [color=FFF|nombre color]
|
19
19
|
|
20
20
|
Se puede crear imágenes para mostrar según el caso
|
21
|
-
- Imagen <nombre imagen> <archivo
|
21
|
+
- Imagen <nombre imagen> <archivo=...>|<color=....>
|
22
22
|
|
23
23
|
Se puede ambientra con música de fondo, esta se repite hasta
|
24
24
|
cambiar la música o detenerla
|
data/lib/ronela.rb
CHANGED
@@ -86,34 +86,54 @@ module Ronela
|
|
86
86
|
end
|
87
87
|
|
88
88
|
|
89
|
-
|
89
|
+
|
90
|
+
|
90
91
|
class Imagen
|
91
92
|
attr_accessor :fondo
|
92
93
|
attr_accessor :x, :y
|
93
94
|
attr_writer :posicion
|
94
|
-
|
95
|
+
attr_reader :mostrando,:imagen
|
96
|
+
#attr_accessor :mostrando #se esta mostrano?
|
97
|
+
|
95
98
|
def initialize(archivo)
|
96
99
|
@imagen = SDL::Surface.load(archivo)
|
97
100
|
@fondo = nil
|
98
101
|
@posicion = nil
|
99
102
|
@x = 0
|
100
103
|
@y = 0
|
104
|
+
@mostrando = false
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
#borra en la posicion actual
|
109
|
+
def limpiar_de_antes en
|
110
|
+
unless @fondo.nil?
|
111
|
+
SDL::Surface.blit(@fondo.imagen, @x, @y, @imagen.w, @imagen.h, en, @x, @y)
|
112
|
+
end
|
101
113
|
end
|
114
|
+
|
102
115
|
|
103
116
|
def limpiar en
|
104
117
|
x,y = posicion_a_xy
|
105
118
|
unless @fondo.nil?
|
106
119
|
@fondo.dibujar en, [x, y, @imagen.w, @imagen.h], [x, y, @imagen.w, @imagen.h]
|
107
120
|
end
|
121
|
+
@mostrando = false
|
108
122
|
end
|
109
123
|
|
124
|
+
|
110
125
|
#dibuja la imagen en
|
111
126
|
def dibujar en, rect=nil, srect=nil
|
112
127
|
@x,@y = posicion_a_xy
|
113
128
|
x,y = @x,@y
|
114
129
|
xs, ys = 0,0
|
115
130
|
xs, ys = srect unless srect.nil?
|
116
|
-
|
131
|
+
|
132
|
+
#si se vuelve a mostrar se borra donde estaba
|
133
|
+
if @mostrando
|
134
|
+
limpiar_de_antes en
|
135
|
+
end
|
136
|
+
|
117
137
|
unless rect.nil?
|
118
138
|
SDL::Surface.blit(@imagen, xs,ys, rect[2], rect[3], en, rect[0], rect[1])
|
119
139
|
$pantalla.updateRect(rect[0], rect[1], rect[2], rect[3])
|
@@ -121,7 +141,7 @@ module Ronela
|
|
121
141
|
SDL::Surface.blit(@imagen, xs, ys, @imagen.w, @imagen.h, en, x, y)
|
122
142
|
$pantalla.flip
|
123
143
|
end
|
124
|
-
|
144
|
+
@mostrando = true
|
125
145
|
end
|
126
146
|
|
127
147
|
#convierte posicion palabra a arreglo
|
@@ -169,7 +189,26 @@ module Ronela
|
|
169
189
|
|
170
190
|
end
|
171
191
|
|
172
|
-
|
192
|
+
#Como imagen pero de un solo color
|
193
|
+
class ImagenColor < Imagen
|
194
|
+
|
195
|
+
def initialize(color, ancho=nil, alto=nil)
|
196
|
+
|
197
|
+
iancho = $config[:PANTALLA_ANCHO]
|
198
|
+
ialto = $config[:PANTALLA_ALTO]
|
199
|
+
iancho = ancho if !ancho.nil? and ancho > 0
|
200
|
+
ialto = alto if !alto.nil? and alto > 0
|
201
|
+
|
202
|
+
@imagen = SDL::Surface.new($pantalla.flags, iancho, ialto, $pantalla.format)
|
203
|
+
@imagen.fillRect(0, 0, iancho, ialto, Color::html_a_sdl(color))
|
204
|
+
@fondo = nil
|
205
|
+
@posicion = nil
|
206
|
+
@x = 0
|
207
|
+
@y = 0
|
208
|
+
@mostrando = false
|
209
|
+
@color = color
|
210
|
+
end
|
211
|
+
end
|
173
212
|
|
174
213
|
class Personaje
|
175
214
|
attr_accessor :fondo
|
@@ -240,7 +279,7 @@ module Ronela
|
|
240
279
|
end
|
241
280
|
|
242
281
|
#personaje dice que en donde
|
243
|
-
def dice en,que, limpiar_con=nil
|
282
|
+
def dice en, que, limpiar_con=nil
|
244
283
|
lancho, lalto = @fuente_nombre.text_size(".")
|
245
284
|
x = $config[:DESPLAZA_X_PERSONAJE]
|
246
285
|
|
@@ -251,6 +290,8 @@ module Ronela
|
|
251
290
|
|
252
291
|
lr = [0, yn, $config[:PANTALLA_ANCHO], $config[:PANTALLA_ALTO] / 2]
|
253
292
|
limpiar_con.dibujar $pantalla, lr ,lr unless limpiar_con.nil?
|
293
|
+
#limpiar_con.dibujar $pantalla unless limpiar_con.nil?
|
294
|
+
|
254
295
|
|
255
296
|
gui_dialogo en, x, yn
|
256
297
|
txt en, @nombre, [x, yn], @fuente_nombre
|
@@ -278,9 +319,10 @@ module Ronela
|
|
278
319
|
SDL.init(SDL::INIT_VIDEO|SDL::INIT_AUDIO)
|
279
320
|
SDL::TTF.init unless SDL::TTF.init?
|
280
321
|
begin
|
281
|
-
SDL::Mixer.spec
|
282
|
-
rescue
|
283
322
|
SDL::Mixer.open
|
323
|
+
@audio = true
|
324
|
+
rescue
|
325
|
+
@audio = false
|
284
326
|
end
|
285
327
|
|
286
328
|
$pantalla = SDL.setVideoMode($config[:PANTALLA_ANCHO], $config[:PANTALLA_ALTO], $config[:PANTALLA_BPP], $config[:PANTALLA_FLAGS])
|
@@ -342,7 +384,7 @@ module Ronela
|
|
342
384
|
nombre = resto.join(" ")
|
343
385
|
archivo = variables["archivo"]
|
344
386
|
|
345
|
-
if !archivo.nil? and File.exists? archivo
|
387
|
+
if @audio and !archivo.nil? and File.exists? archivo
|
346
388
|
@musicas[nombre].destroy if @musicas.has_key? nombre
|
347
389
|
@musicas[nombre] = SDL::Mixer::Music.load(archivo)
|
348
390
|
end
|
@@ -354,7 +396,7 @@ module Ronela
|
|
354
396
|
nombre = resto.join(" ")
|
355
397
|
archivo = variables["archivo"]
|
356
398
|
|
357
|
-
if !archivo.nil? and File.exists? archivo
|
399
|
+
if @audio and !archivo.nil? and File.exists? archivo
|
358
400
|
@sonidos[nombre].destroy if @sonidos.has_key? nombre
|
359
401
|
@sonidos[nombre] = SDL::Mixer::Wave.load(archivo)
|
360
402
|
end
|
@@ -451,6 +493,10 @@ module Ronela
|
|
451
493
|
if !nombre.empty? and @imagenes.has_key? nombre
|
452
494
|
@escena = @imagenes[nombre]
|
453
495
|
@escena.dibujar $pantalla
|
496
|
+
@imagenes.each { |k,i|
|
497
|
+
i.fondo = @escena
|
498
|
+
i.dibujar $pantalla if i.mostrando
|
499
|
+
}
|
454
500
|
else
|
455
501
|
Kernel.puts "Imagen #{nombre} no existe"
|
456
502
|
end
|
@@ -459,17 +505,23 @@ module Ronela
|
|
459
505
|
#Crea imagen
|
460
506
|
@lenguaje.Imagen { |variables, resto|
|
461
507
|
nombre = resto.join(" ")
|
508
|
+
imagen = nil
|
462
509
|
if variables.has_key? "archivo"
|
463
510
|
begin
|
464
|
-
|
465
|
-
|
511
|
+
imagen = Imagen.new(variables["archivo"])
|
512
|
+
imagen.fondo = @escena
|
466
513
|
|
467
|
-
|
514
|
+
rescue
|
468
515
|
Kernel.puts "No se pudo encontrar imagen #{variables['archivo']}"
|
469
516
|
end
|
470
517
|
|
471
|
-
|
518
|
+
|
519
|
+
elsif variables.has_key? "color"
|
520
|
+
imagen = ImagenColor.new(variables["color"])
|
521
|
+
imagen.fondo = @escena
|
472
522
|
end
|
523
|
+
|
524
|
+
@imagenes[nombre] = imagen unless imagen.nil?
|
473
525
|
}
|
474
526
|
|
475
527
|
#Crea peronaje
|