Ronela 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LEAME +73 -0
- data/bin/ronela +15 -0
- data/lib/ronela.rb +574 -0
- data/lib/ronela_lenguaje.rb +129 -0
- metadata +81 -0
data/LEAME
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
= *Ronela* un motor de novelas gráficas en español
|
2
|
+
|
3
|
+
En la novelas de *Ronela* interactuamos con
|
4
|
+
- Personaje
|
5
|
+
- Imagen
|
6
|
+
- Música
|
7
|
+
- Sonido
|
8
|
+
|
9
|
+
|
10
|
+
==Lenguaje Ronela
|
11
|
+
Ronela intenta tener un lenguaje de sencilla escritura, para la construcción
|
12
|
+
de las novelas.
|
13
|
+
|
14
|
+
Actualmente se puede:
|
15
|
+
Nota: lo que esta entre <> es obligatorio y [] opcional
|
16
|
+
|
17
|
+
Se crea el personaje que va a decir algo
|
18
|
+
- Personaje <nombre personaje> <apodo=...> [color=FFF|nombre color]
|
19
|
+
|
20
|
+
Se puede crear imágenes para mostrar según el caso
|
21
|
+
- Imagen <nombre imagen> <archivo=...>
|
22
|
+
|
23
|
+
Se puede ambientra con música de fondo, esta se repite hasta
|
24
|
+
cambiar la música o detenerla
|
25
|
+
- Música <nombre música> <archivo=...>
|
26
|
+
|
27
|
+
Algo que suena y no se repite
|
28
|
+
- Sonido <nombre sonido> <archivo=...>
|
29
|
+
|
30
|
+
Se muestran o ocultan las imágenes
|
31
|
+
- Mostrar <nombre imagen> [posicion=centro|izquierda|derecha|arriba|abajo]
|
32
|
+
- Ocultar <nombre imagen>
|
33
|
+
|
34
|
+
Se puede poner algo de audio, para ambientar y animar la novela
|
35
|
+
- Reproducir música <nombre música> [volumen=##]
|
36
|
+
- Reproducir sonido <nombre sonido> [volumen=##]
|
37
|
+
- Detener música <nombre música>
|
38
|
+
- Detener sonido <nombre sonido>
|
39
|
+
|
40
|
+
Para que indicar lo que dice un personaje debemos poner el apodo y acontinuación
|
41
|
+
lo que va decir, ej: perro Gua,Guaua,Guaa
|
42
|
+
|
43
|
+
- <apodo de personaje> lo que dice blabalbala en una linea....
|
44
|
+
- <apodo de personaje> "se puede en multiples lineas
|
45
|
+
siempre y cuando este entre comillas lo que dice el
|
46
|
+
personaje"
|
47
|
+
|
48
|
+
También se puede personalizar un poco Ronela através de la acción *Configurar*, esta debe ser la primera linea
|
49
|
+
del guión.
|
50
|
+
- Configurar ... mirar abajo las opciones
|
51
|
+
Pantalla
|
52
|
+
-pantalla_alto=##
|
53
|
+
-pantalla_ancho=##
|
54
|
+
GUI donde muestra lo que se dice
|
55
|
+
-desplaza_x_gui_dialogo=##
|
56
|
+
-desplaza_y_gui_dialogo=##
|
57
|
+
Las fuentes
|
58
|
+
-fuente_tamano_nombre=##
|
59
|
+
-fuente_tamano_msg=##
|
60
|
+
|
61
|
+
|
62
|
+
= Creando tu novela gráfica
|
63
|
+
|
64
|
+
Ronela espera encontrar en la carpeta donde se llama el comando *ronela*
|
65
|
+
la fuente **default.ttf** con la que renderizara los textos.
|
66
|
+
Entonces lo primero que debemos hacer es descargar la fuente que te
|
67
|
+
guste en formate TTF y ubicarla en el directorio de la novela.
|
68
|
+
|
69
|
+
Ahora crear el archivo del guión, y empieza a escribir, para más detalle
|
70
|
+
consulta Lenguaje Ronela.
|
71
|
+
|
72
|
+
Cuando tengas listo el guión, ejecutalo desde una terminal con el comando *ronela*
|
73
|
+
Ejemplo: ronela mi_guion.txt
|
data/bin/ronela
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'ronela'
|
4
|
+
|
5
|
+
|
6
|
+
r = Ronela::Ronela.new
|
7
|
+
|
8
|
+
guion = ARGV[0]
|
9
|
+
if ARGV.size != 1
|
10
|
+
|
11
|
+
abort "#{$0}: <archivo guion>"
|
12
|
+
end
|
13
|
+
abort "#{$0}: No se encontro guion #{guion}, indiquelo\n" unless File.exists? guion
|
14
|
+
|
15
|
+
r.leer_guion guion
|
data/lib/ronela.rb
ADDED
@@ -0,0 +1,574 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
Ronela un Motor de novelas gráficas.
|
4
|
+
(C) 2011 Jovany Leandro G.C <info@manadalibre.org>
|
5
|
+
|
6
|
+
This file is part of Ronela.
|
7
|
+
|
8
|
+
Ronela is free software: you can redistribute it and/or modify
|
9
|
+
it under the terms of the GNU General Public License as published by
|
10
|
+
the Free Software Foundation, either version 3 of the License, or
|
11
|
+
any later version.
|
12
|
+
|
13
|
+
Ronela is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
GNU General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License
|
19
|
+
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
=end
|
21
|
+
|
22
|
+
#agregra posibilidad de cargar
|
23
|
+
#los modulos de ronela
|
24
|
+
$: << Dir.pwd
|
25
|
+
|
26
|
+
abort "Se necesita libreria rubysdl\n instalela: gem install rubysdl" unless require 'sdl'
|
27
|
+
|
28
|
+
require "ronela_lenguaje"
|
29
|
+
|
30
|
+
#ventana
|
31
|
+
$pantalla = nil
|
32
|
+
|
33
|
+
|
34
|
+
#configuracion general de ronela
|
35
|
+
$config = {
|
36
|
+
#cuanto se desplaza la ventana
|
37
|
+
#del dialogo del personaje
|
38
|
+
:DESPLAZA_X_PERSONAJE => 5,
|
39
|
+
:DESPLAZA_Y_PERSONAJE => 200,
|
40
|
+
:PANTALLA_ANCHO => 800,
|
41
|
+
:PANTALLA_ALTO => 600,
|
42
|
+
:PANTALLA_FLAGS => SDL::HWSURFACE,
|
43
|
+
:PANTALLA_BPP => 0,
|
44
|
+
|
45
|
+
:FUENTE_TAMANO_NOMBRE => 20,
|
46
|
+
:FUENTE_TAMANO_MSG => 32
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
#:include:LEAME
|
51
|
+
module Ronela
|
52
|
+
|
53
|
+
module Color
|
54
|
+
|
55
|
+
#convierte formato fff a [255,255,255]
|
56
|
+
def Color.html_a_sdl(val)
|
57
|
+
#@todo agregar muchos más
|
58
|
+
case val.to_s
|
59
|
+
when 'rojo'
|
60
|
+
return [255, 0, 0]
|
61
|
+
when 'amarillo'
|
62
|
+
return [255, 255, 0]
|
63
|
+
when 'azul'
|
64
|
+
return [0, 0, 255]
|
65
|
+
when 'verde'
|
66
|
+
return [255, 0, 0]
|
67
|
+
end
|
68
|
+
|
69
|
+
if val.size == 6
|
70
|
+
[
|
71
|
+
(val[0] + val[1]).hex,
|
72
|
+
(val[2] + val[3]).hex,
|
73
|
+
(val[4] + val[5]).hex
|
74
|
+
]
|
75
|
+
elsif val.size == 3
|
76
|
+
[
|
77
|
+
(val[0] + val[0]).hex,
|
78
|
+
(val[1] + val[1]).hex,
|
79
|
+
(val[2] + val[2]).hex
|
80
|
+
]
|
81
|
+
else
|
82
|
+
[255,255,255]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
class Imagen
|
91
|
+
attr_accessor :fondo
|
92
|
+
attr_accessor :x, :y
|
93
|
+
attr_writer :posicion
|
94
|
+
|
95
|
+
def initialize(archivo)
|
96
|
+
@imagen = SDL::Surface.load(archivo)
|
97
|
+
@fondo = nil
|
98
|
+
@posicion = nil
|
99
|
+
@x = 0
|
100
|
+
@y = 0
|
101
|
+
end
|
102
|
+
|
103
|
+
def limpiar en
|
104
|
+
x,y = posicion_a_xy
|
105
|
+
unless @fondo.nil?
|
106
|
+
@fondo.dibujar en, [x, y, @imagen.w, @imagen.h], [x, y, @imagen.w, @imagen.h]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
#dibuja la imagen en
|
111
|
+
def dibujar en, rect=nil, srect=nil
|
112
|
+
@x,@y = posicion_a_xy
|
113
|
+
x,y = @x,@y
|
114
|
+
xs, ys = 0,0
|
115
|
+
xs, ys = srect unless srect.nil?
|
116
|
+
|
117
|
+
unless rect.nil?
|
118
|
+
SDL::Surface.blit(@imagen, xs,ys, rect[2], rect[3], en, rect[0], rect[1])
|
119
|
+
$pantalla.updateRect(rect[0], rect[1], rect[2], rect[3])
|
120
|
+
else
|
121
|
+
SDL::Surface.blit(@imagen, xs, ys, @imagen.w, @imagen.h, en, x, y)
|
122
|
+
$pantalla.flip
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
#convierte posicion palabra a arreglo
|
128
|
+
#
|
129
|
+
def posicion_a_xy
|
130
|
+
if @posicion.nil?
|
131
|
+
return [0,0]
|
132
|
+
end
|
133
|
+
|
134
|
+
case @posicion
|
135
|
+
when 'abajo'
|
136
|
+
[$config[:PANTALLA_ANCHO] / 2 - @imagen.h / 2, $config[:PANTALLA_ALTO] - @imagen.h]
|
137
|
+
when 'arriba'
|
138
|
+
[$config[:PANTALLA_ANCHO] / 2 - @imagen.h / 2, 0]
|
139
|
+
when 'derecha'
|
140
|
+
[$config[:PANTALLA_ANCHO] - @imagen.h, $config[:PANTALLA_ALTO] / 2 - @imagen.h / 2]
|
141
|
+
when 'izquierda'
|
142
|
+
[0, $config[:PANTALLA_ALTO] / 2 - @imagen.h / 2]
|
143
|
+
when 'centro'
|
144
|
+
[$config[:PANTALLA_ANCHO] / 2 - @imagen.w / 2, $config[:PANTALLA_ALTO] / 2 - @imagen.h / 2]
|
145
|
+
else
|
146
|
+
[$config[:PANTALLA_ANCHO] / 2 - @imagen.w / 2, $config[:PANTALLA_ALTO] / 2 - @imagen.h / 2]
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
#Lee variables desde RonelaLenguaje
|
151
|
+
#Variables para imagen
|
152
|
+
# - **posicion** centro|izquierda|derecha|arriba|abajo
|
153
|
+
# - **opacidad** 0..255
|
154
|
+
def cargar_variables(variables)
|
155
|
+
|
156
|
+
if variables.has_key? "posicion"
|
157
|
+
@posicion = variables["posicion"]
|
158
|
+
else
|
159
|
+
@posicion = "centro"
|
160
|
+
end
|
161
|
+
|
162
|
+
#@todo no funciona el alpha
|
163
|
+
if variables.has_key? "opacidad"
|
164
|
+
opacidad = variables["opacidad"].to_i
|
165
|
+
Kernel.puts "Opacidad #{opacidad}"
|
166
|
+
@imagen.setAlpha(SDL::SRCALPHA, opacidad)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
class Personaje
|
175
|
+
attr_accessor :fondo
|
176
|
+
|
177
|
+
def initialize(nombre, color)
|
178
|
+
@nombre = nombre
|
179
|
+
|
180
|
+
if color.nil? or color.empty?
|
181
|
+
@color = Color::html_a_sdl("f00")
|
182
|
+
else
|
183
|
+
@color = Color::html_a_sdl(color)
|
184
|
+
end
|
185
|
+
|
186
|
+
|
187
|
+
@fuente_msg = SDL::TTF.open("default.ttf", $config[:FUENTE_TAMANO_MSG], 0)
|
188
|
+
@fuente_nombre = SDL::TTF.open("default.ttf", $config[:FUENTE_TAMANO_NOMBRE], 0)
|
189
|
+
#lo que se escribio
|
190
|
+
end
|
191
|
+
|
192
|
+
|
193
|
+
#escribe mensaje y cambia de linea cuando llena al extremo de la ventana
|
194
|
+
def txt en, que, pos, fuente
|
195
|
+
r,g,b = @color
|
196
|
+
x, y = pos
|
197
|
+
xi, yi = x, y
|
198
|
+
ancho_letra, alto_letra = fuente.text_size(" ")
|
199
|
+
ancho_total = 0
|
200
|
+
alto_total = 0
|
201
|
+
ultimo_ancho = 0
|
202
|
+
que_parte = que.split
|
203
|
+
|
204
|
+
for palabra in que_parte
|
205
|
+
ancho, alto = fuente.text_size(palabra)
|
206
|
+
|
207
|
+
ancho_total += ancho + ancho_letra
|
208
|
+
|
209
|
+
if ancho_total >= $config[:PANTALLA_ANCHO] - ancho
|
210
|
+
ultimo_ancho = $config[:PANTALLA_ANCHO]
|
211
|
+
ancho_total = 0
|
212
|
+
|
213
|
+
#@todo posible bicho, cuando se crezca orizontal
|
214
|
+
y += alto_letra if y+alto_letra < $config[:PANTALLA_ALTO]
|
215
|
+
alto_total = y
|
216
|
+
x = xi
|
217
|
+
fuente.drawSolidUTF8(en, palabra, x, y, r, g, b)
|
218
|
+
else
|
219
|
+
fuente.drawSolidUTF8(en, palabra, x, y, r, g, b)
|
220
|
+
end
|
221
|
+
x += ancho + ancho_letra
|
222
|
+
end
|
223
|
+
|
224
|
+
end
|
225
|
+
|
226
|
+
#pinta donde dice el personaje
|
227
|
+
#le pone bonito
|
228
|
+
def gui_dialogo(en, x, y)
|
229
|
+
ancho = $config[:PANTALLA_ANCHO] - x
|
230
|
+
alto = $config[:PANTALLA_ALTO] - y
|
231
|
+
|
232
|
+
gui = SDL::Surface.new(SDL::HWSURFACE, ancho, alto, $pantalla.format)
|
233
|
+
|
234
|
+
gui.fillRect(5, 5, ancho-5, alto-5, gui.mapRGB(*@color))
|
235
|
+
gui.setAlpha(SDL::RLEACCEL|SDL::SRCALPHA, 15)
|
236
|
+
|
237
|
+
SDL::Surface.blit(gui,0,0, ancho, alto, en, x, y)
|
238
|
+
gui.destroy
|
239
|
+
|
240
|
+
end
|
241
|
+
|
242
|
+
#personaje dice que en donde
|
243
|
+
def dice en,que, limpiar_con=nil
|
244
|
+
lancho, lalto = @fuente_nombre.text_size(".")
|
245
|
+
x = $config[:DESPLAZA_X_PERSONAJE]
|
246
|
+
|
247
|
+
y = ($config[:PANTALLA_ALTO] / 2) + $config[:DESPLAZA_Y_PERSONAJE] #100 a ojo
|
248
|
+
yn = ($config[:PANTALLA_ALTO] / 2) + $config[:DESPLAZA_Y_PERSONAJE] - lalto
|
249
|
+
ancho = $config[:PANTALLA_ANCHO] - x
|
250
|
+
alto = $config[:PANTALLA_ALTO] - y
|
251
|
+
|
252
|
+
lr = [0, yn, $config[:PANTALLA_ANCHO], $config[:PANTALLA_ALTO] / 2]
|
253
|
+
limpiar_con.dibujar $pantalla, lr ,lr unless limpiar_con.nil?
|
254
|
+
|
255
|
+
gui_dialogo en, x, yn
|
256
|
+
txt en, @nombre, [x, yn], @fuente_nombre
|
257
|
+
txt en, que, [x,y], @fuente_msg
|
258
|
+
|
259
|
+
#actualize cuadro donde se escribio
|
260
|
+
$pantalla.updateRect(0, yn , $config[:PANTALLA_ANCHO], $config[:PANTALLA_ALTO] - yn )
|
261
|
+
|
262
|
+
end
|
263
|
+
|
264
|
+
|
265
|
+
#cargar desde RonelaLenguaje
|
266
|
+
def cargar_variables(variables)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
#Clase principal Ronela
|
273
|
+
#Un motor de novelas gráficas simple y en español
|
274
|
+
class Ronela
|
275
|
+
|
276
|
+
|
277
|
+
def Ronela.iniciar_sdl
|
278
|
+
SDL.init(SDL::INIT_VIDEO|SDL::INIT_AUDIO)
|
279
|
+
SDL::TTF.init unless SDL::TTF.init?
|
280
|
+
begin
|
281
|
+
SDL::Mixer.spec
|
282
|
+
rescue
|
283
|
+
SDL::Mixer.open
|
284
|
+
end
|
285
|
+
|
286
|
+
$pantalla = SDL.setVideoMode($config[:PANTALLA_ANCHO], $config[:PANTALLA_ALTO], $config[:PANTALLA_BPP], $config[:PANTALLA_FLAGS])
|
287
|
+
end
|
288
|
+
|
289
|
+
def initialize
|
290
|
+
Ronela.iniciar_sdl
|
291
|
+
|
292
|
+
@salir = false
|
293
|
+
|
294
|
+
#detener lectura de guion
|
295
|
+
@parar = false
|
296
|
+
#la escena que se encuentra
|
297
|
+
@escena = nil
|
298
|
+
#los personaje creados
|
299
|
+
@personajes = {}
|
300
|
+
#las imagenes cargadas
|
301
|
+
@imagenes = {}
|
302
|
+
@musicas = {}
|
303
|
+
@sonidos = {}
|
304
|
+
|
305
|
+
|
306
|
+
#Llama según invocado del guion
|
307
|
+
#Aqui es donde se contruye el lenguaje
|
308
|
+
#Ronela
|
309
|
+
@lenguaje = RonelaLenguaje.new {
|
310
|
+
|accion, resto|
|
311
|
+
|
312
|
+
if @personajes.has_key? accion
|
313
|
+
|
314
|
+
#permite multi linea
|
315
|
+
if resto[0] == '"' and resto[-1] != '"'
|
316
|
+
@fguion.each_char { |c|
|
317
|
+
if c == '"'
|
318
|
+
resto.delete! '"'
|
319
|
+
break
|
320
|
+
else
|
321
|
+
resto << c
|
322
|
+
end
|
323
|
+
}
|
324
|
+
end
|
325
|
+
|
326
|
+
#dibuja lo que dice el personaje
|
327
|
+
@personajes[accion].dice $pantalla, resto, @escena
|
328
|
+
|
329
|
+
#detiene la lectura del guion y espera accion del usuarix
|
330
|
+
@parar = true
|
331
|
+
#Se permite Comentario
|
332
|
+
elsif accion == "Comentario"
|
333
|
+
; #se omite
|
334
|
+
else
|
335
|
+
puts "Se desconoce #{accion}"
|
336
|
+
end
|
337
|
+
}
|
338
|
+
|
339
|
+
#Registra Musica
|
340
|
+
#Música <nombre música> <archivo=ruta..>
|
341
|
+
@lenguaje.Música { |variables, resto|
|
342
|
+
nombre = resto.join(" ")
|
343
|
+
archivo = variables["archivo"]
|
344
|
+
|
345
|
+
if !archivo.nil? and File.exists? archivo
|
346
|
+
@musicas[nombre].destroy if @musicas.has_key? nombre
|
347
|
+
@musicas[nombre] = SDL::Mixer::Music.load(archivo)
|
348
|
+
end
|
349
|
+
}
|
350
|
+
|
351
|
+
#Registra sonido
|
352
|
+
#Sonido <nombre sonido> <archivo=ruta...>
|
353
|
+
@lenguaje.Sonido { |variables, resto|
|
354
|
+
nombre = resto.join(" ")
|
355
|
+
archivo = variables["archivo"]
|
356
|
+
|
357
|
+
if !archivo.nil? and File.exists? archivo
|
358
|
+
@sonidos[nombre].destroy if @sonidos.has_key? nombre
|
359
|
+
@sonidos[nombre] = SDL::Mixer::Wave.load(archivo)
|
360
|
+
end
|
361
|
+
}
|
362
|
+
|
363
|
+
#Reproduce sonido o música
|
364
|
+
#Reproducir música <nombre música> [volumen=#] [efecto=entrada]
|
365
|
+
#Reproducir sonido <nombro sonido> [volumen=#] [efecto=entrada]
|
366
|
+
@lenguaje.Reproducir { |variables, resto|
|
367
|
+
sl = RonelaLenguaje.new {
|
368
|
+
|accion, resto|
|
369
|
+
Kernel.puts "No se entiende #{accion} para Reproducir"
|
370
|
+
}
|
371
|
+
|
372
|
+
resto = resto.join(" ")
|
373
|
+
|
374
|
+
vol = 100
|
375
|
+
vol = variables["volumen"].to_i if variables.has_key? "volumen"
|
376
|
+
efecto = variables["efecto"]
|
377
|
+
|
378
|
+
sl.música {|xvariables, resto|
|
379
|
+
nombre = resto.join(" ")
|
380
|
+
SDL::Mixer.setVolumeMusic(vol)
|
381
|
+
|
382
|
+
if @musicas.has_key? nombre
|
383
|
+
case efecto
|
384
|
+
when 'entrada'
|
385
|
+
SDL::Mixer.fadeInMusic(@musicas[nombre], -1, 1000)
|
386
|
+
else
|
387
|
+
SDL::Mixer.playMusic(@musicas[nombre], -1)
|
388
|
+
end
|
389
|
+
end
|
390
|
+
}
|
391
|
+
|
392
|
+
sl.sonido {|xvariables, resto|
|
393
|
+
nombre = resto.join(" ")
|
394
|
+
SDL::Mixer.setVolume(-1, vol)
|
395
|
+
|
396
|
+
if @sonidos.has_key? nombre
|
397
|
+
case efecto
|
398
|
+
when 'entrada'
|
399
|
+
SDL::Mixer.fadeInChannel(-1, @sonidos[nombre], 0, 1000)
|
400
|
+
else
|
401
|
+
SDL::Mixer.playChannel(-1, @sonidos[nombre], 0)
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
}
|
406
|
+
|
407
|
+
sl.scan resto
|
408
|
+
}
|
409
|
+
|
410
|
+
#detiene reproducion de la musica
|
411
|
+
@lenguaje.Detener { |variables, resto|
|
412
|
+
sl = RonelaLenguaje.new {
|
413
|
+
|accion, resto|
|
414
|
+
Kernel.puts "No se entiende #{accion} para Reproducir"
|
415
|
+
}
|
416
|
+
sl.música {|xvariables, resto|
|
417
|
+
if @musica.kind_of? SDL::Mixer::Music
|
418
|
+
SDL::Mixer.haltMusic(@musica)
|
419
|
+
@musica.destroy
|
420
|
+
end
|
421
|
+
}
|
422
|
+
}
|
423
|
+
|
424
|
+
#Dibuja imágen en ventana
|
425
|
+
@lenguaje.Mostrar { |variables, resto|
|
426
|
+
nombre = resto.join(" ")
|
427
|
+
|
428
|
+
if !nombre.empty? and @imagenes.has_key? nombre
|
429
|
+
@imagenes[nombre].cargar_variables variables
|
430
|
+
@imagenes[nombre].fondo = @escena
|
431
|
+
@imagenes[nombre].dibujar $pantalla
|
432
|
+
else
|
433
|
+
Kernel.puts "Imagen #{nombre} no existe"
|
434
|
+
end
|
435
|
+
}
|
436
|
+
|
437
|
+
@lenguaje.Ocultar {|variables, resto|
|
438
|
+
nombre = resto.join(" ")
|
439
|
+
if !nombre.empty? and @imagenes.has_key? nombre
|
440
|
+
@imagenes[nombre].limpiar $pantalla
|
441
|
+
else
|
442
|
+
Kernel.puts "Imagen #{nombre} no existe"
|
443
|
+
end
|
444
|
+
}
|
445
|
+
|
446
|
+
#La escena se debe dibujar siempre en el
|
447
|
+
#fondo de la ventana
|
448
|
+
@lenguaje.Escena { |variables, resto|
|
449
|
+
nombre = resto.join(" ")
|
450
|
+
|
451
|
+
if !nombre.empty? and @imagenes.has_key? nombre
|
452
|
+
@escena = @imagenes[nombre]
|
453
|
+
@escena.dibujar $pantalla
|
454
|
+
else
|
455
|
+
Kernel.puts "Imagen #{nombre} no existe"
|
456
|
+
end
|
457
|
+
}
|
458
|
+
|
459
|
+
#Crea imagen
|
460
|
+
@lenguaje.Imagen { |variables, resto|
|
461
|
+
nombre = resto.join(" ")
|
462
|
+
if variables.has_key? "archivo"
|
463
|
+
begin
|
464
|
+
@imagenes[nombre] = Imagen.new(variables["archivo"])
|
465
|
+
@imagenes[nombre].fondo = @escena
|
466
|
+
|
467
|
+
rescue
|
468
|
+
Kernel.puts "No se pudo encontrar imagen #{variables['archivo']}"
|
469
|
+
end
|
470
|
+
|
471
|
+
|
472
|
+
end
|
473
|
+
}
|
474
|
+
|
475
|
+
#Crea peronaje
|
476
|
+
@lenguaje.Personaje { |variables, resto|
|
477
|
+
nombre = resto.join(" ")
|
478
|
+
if variables.has_key? "apodo"
|
479
|
+
color = variables["color"]
|
480
|
+
else
|
481
|
+
color = "#fff"
|
482
|
+
end
|
483
|
+
|
484
|
+
if variables.has_key? "apodo"
|
485
|
+
personaje = Personaje.new(nombre, color)
|
486
|
+
personaje.cargar_variables(variables)
|
487
|
+
@personajes[variables["apodo"]] = personaje
|
488
|
+
|
489
|
+
end
|
490
|
+
}
|
491
|
+
|
492
|
+
#Personaliza el juego
|
493
|
+
@lenguaje.Configurar { |variables, resto|
|
494
|
+
pancho = variables["pantalla_ancho"].to_i
|
495
|
+
palto = variables["pantalla_alto"].to_i
|
496
|
+
|
497
|
+
pxdes = variables["desplaza_x_gui_dialogo"].to_i
|
498
|
+
pydes = variables["desplaza_y_gui_dialogo"].to_i
|
499
|
+
|
500
|
+
$config[:DESPLAZA_X_PERSONAJE] = pxdes if pxdes > 0
|
501
|
+
$config[:DESPLAZA_Y_PERSONAJE] = pydes if pydes > 0
|
502
|
+
|
503
|
+
ftnombre = variables["fuente_tamano_nombre"].to_i
|
504
|
+
ftmsg = variables["fuente_tamano_msg"].to_i
|
505
|
+
|
506
|
+
$config[:FUENTE_TAMANO_NOMBRE] = ftnombre if ftnombre > 0
|
507
|
+
$config[:FUENTE_TAMANO_MSG] = ftmsg if ftmsg > 0
|
508
|
+
|
509
|
+
|
510
|
+
$config[:PANTALLA_ANCHO] = pancho if pancho > 0
|
511
|
+
$config[:PANTALLA_ALTO] = palto if palto > 0
|
512
|
+
|
513
|
+
Ronela.iniciar_sdl if pancho > 0 or palto > 0
|
514
|
+
}
|
515
|
+
end
|
516
|
+
|
517
|
+
#Lee archivo con guion
|
518
|
+
#e interpreta
|
519
|
+
def leer_guion guion
|
520
|
+
|
521
|
+
#sale si no hay guion
|
522
|
+
abort "No se encontro guion" unless File.exists? guion
|
523
|
+
|
524
|
+
@fguion = File.open(guion,"r")
|
525
|
+
|
526
|
+
until @salir
|
527
|
+
|
528
|
+
if @fguion.eof?
|
529
|
+
@salir = true
|
530
|
+
end
|
531
|
+
|
532
|
+
linea = @fguion.gets
|
533
|
+
@lenguaje.scan linea
|
534
|
+
|
535
|
+
#se detiene hasta que alguien diga algo
|
536
|
+
if @parar
|
537
|
+
while evento = SDL::Event.wait
|
538
|
+
case evento
|
539
|
+
when SDL::Event::MouseButtonDown
|
540
|
+
#se cancela los sonidos
|
541
|
+
SDL::Mixer.halt(-1)
|
542
|
+
break
|
543
|
+
when SDL::Event::Quit
|
544
|
+
@salir = true
|
545
|
+
break
|
546
|
+
end
|
547
|
+
end
|
548
|
+
@parar = false
|
549
|
+
end
|
550
|
+
|
551
|
+
end
|
552
|
+
@fguion.close
|
553
|
+
end
|
554
|
+
|
555
|
+
end
|
556
|
+
|
557
|
+
end #end module Ronela
|
558
|
+
|
559
|
+
|
560
|
+
|
561
|
+
|
562
|
+
if $0 == __FILE__
|
563
|
+
r = Ronela::Ronela.new
|
564
|
+
|
565
|
+
guion = ARGV[0]
|
566
|
+
if ARGV.size != 1
|
567
|
+
|
568
|
+
abort "#{$0}: <archivo guion>"
|
569
|
+
end
|
570
|
+
abort "#{$0}: No se encontro guion #{guion}, indiquelo\n" unless File.exists? guion
|
571
|
+
|
572
|
+
$: << File.realpath(File.dirname(guion)).to_s
|
573
|
+
r.leer_guion guion
|
574
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
Ronela un Motor de novelas gráficas.
|
4
|
+
(C) 2011 Jovany Leandro G.C <info@manadalibre.org>
|
5
|
+
|
6
|
+
This file is part of Ronela.
|
7
|
+
|
8
|
+
Ronela is free software: you can redistribute it and/or modify
|
9
|
+
it under the terms of the GNU General Public License as published by
|
10
|
+
the Free Software Foundation, either version 3 of the License, or
|
11
|
+
any later version.
|
12
|
+
|
13
|
+
Ronela is distributed in the hope that it will be useful,
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
GNU General Public License for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License
|
19
|
+
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
=end
|
21
|
+
|
22
|
+
|
23
|
+
class RonelaLenguajePailas < Exception
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
#==Ronela Lenguaje
|
28
|
+
#Clase generica para leer lenguaje de ronela.
|
29
|
+
#el lenguaje ronela tiene las siguientes palabras claves
|
30
|
+
#
|
31
|
+
# - Personaje => Crea personaje
|
32
|
+
# - Imagen => Crea imagen desde archivo
|
33
|
+
# - Escenario => Muestra imagen como escenario
|
34
|
+
# - Mostrar => Muestra imagen
|
35
|
+
# - \w > .... => El personaje dice ...
|
36
|
+
class RonelaLenguaje
|
37
|
+
|
38
|
+
def initialize (&func)
|
39
|
+
@acciones = {}
|
40
|
+
@nada = func unless func.nil?
|
41
|
+
end
|
42
|
+
|
43
|
+
def definir_accion &func
|
44
|
+
|
45
|
+
end
|
46
|
+
def scan(string)
|
47
|
+
|
48
|
+
if string.kind_of? String
|
49
|
+
string.delete! "\n"
|
50
|
+
end
|
51
|
+
|
52
|
+
#toma primer palabra que determina que hacer
|
53
|
+
if string.nil? or string.empty?
|
54
|
+
return nil
|
55
|
+
end
|
56
|
+
|
57
|
+
partida = string.split
|
58
|
+
accion = partida[0]
|
59
|
+
|
60
|
+
unless @acciones.has_key? accion
|
61
|
+
#si se paso manejador cuando no
|
62
|
+
#se entiende la accion se llama
|
63
|
+
if !@nada.nil?
|
64
|
+
return @nada.call(accion, partida[1..-1].join(' '))
|
65
|
+
else
|
66
|
+
raise RonelaLenguajePailas, string
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
variables = {}
|
72
|
+
resto = []
|
73
|
+
|
74
|
+
for i in 1..(partida.size)
|
75
|
+
#saca variable ti color=rojo
|
76
|
+
if m = partida[i].to_s.match(/([0-9a-zA-Z\-_\/\\\.ñÑáéíóúÁÉÍÓÚ]+)=([0-9a-zA-Z\-_\/\\\.ñÑáéíóúÁÉÍÓÚ]+)/)
|
77
|
+
variables[m[1]] = m[2]
|
78
|
+
#el resto va
|
79
|
+
elsif !partida[i].to_s.empty?
|
80
|
+
resto << partida[i].to_s
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
@acciones[accion].call(variables, resto)
|
85
|
+
end
|
86
|
+
|
87
|
+
#@method indica la accion y se espera una funcion
|
88
|
+
#que será llamada cuando se encuentre la accion
|
89
|
+
#con los argumentos @variables, @resto
|
90
|
+
def method_missing(method, *args, &func)
|
91
|
+
@acciones[method.to_s] = func
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
if $0 == __FILE__
|
99
|
+
|
100
|
+
$personas = {}
|
101
|
+
|
102
|
+
|
103
|
+
p = RonelaLenguaje.new do
|
104
|
+
|accion, resto|
|
105
|
+
|
106
|
+
if $personas.has_key? accion
|
107
|
+
puts "Personaje #{$personas[accion]} dice: #{resto}"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
p.Personaje do |variables, resto|
|
113
|
+
nombre = resto.join ' '
|
114
|
+
if variables.has_key? "apodo"
|
115
|
+
$personas[variables["apodo"]] = nombre
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
#crea personaje
|
121
|
+
p.scan "Personaje jovany leandro apodo=jova"
|
122
|
+
|
123
|
+
#dice algo
|
124
|
+
p.scan "jova Hola que mas"
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Ronela
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Jovany Leandro G.C
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-10-28 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rubysdl
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 0
|
31
|
+
- 0
|
32
|
+
version: 0.0.0
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description:
|
36
|
+
email: info@manadalibre.org
|
37
|
+
executables:
|
38
|
+
- ronela
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LEAME
|
43
|
+
files:
|
44
|
+
- lib/ronela.rb
|
45
|
+
- lib/ronela_lenguaje.rb
|
46
|
+
- LEAME
|
47
|
+
- bin/ronela
|
48
|
+
has_rdoc: true
|
49
|
+
homepage: http://www.manadalibre.org/desarrollos/doku.php?id=videojuegos:ronela
|
50
|
+
licenses: []
|
51
|
+
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
requirements: []
|
74
|
+
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 1.3.7
|
77
|
+
signing_key:
|
78
|
+
specification_version: 3
|
79
|
+
summary: "Ronela un motor de novelas gr\xC3\xA1ficas en espa\xC3\xB1ol"
|
80
|
+
test_files: []
|
81
|
+
|