Ronela 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/bin/ronela +18 -3
  2. data/lib/ronela.rb +93 -12
  3. metadata +4 -4
data/bin/ronela CHANGED
@@ -1,16 +1,31 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'rubygems'
3
3
  require 'ronela'
4
-
4
+ require 'optparse'
5
5
 
6
6
  Ronela::Ronela.iniciar_sdl
7
7
  r = Ronela::Ronela.new
8
8
 
9
9
  guion = ARGV[0]
10
- if ARGV.size != 1
10
+ if ARGV.size < 1
11
11
 
12
12
  abort "#{$0}: <archivo guion>"
13
13
  end
14
14
  abort "#{$0}: No se encontro guion #{guion}, indiquelo\n" unless File.exists? guion
15
15
 
16
- r.leer_guion guion
16
+
17
+ opciones = {}
18
+ OptionParser.new do |opts|
19
+ opts.banner = "#{$0}: [opciones] <archive guion>"
20
+
21
+ opts.on("--guardar-bmp") do |v|
22
+ opciones[:guardar] = true
23
+ end
24
+ end
25
+
26
+ unless opciones[:guardar].nil?
27
+ r.guardar_bmp_guion guion
28
+ else
29
+ r.leer_guion guion
30
+ end
31
+
data/lib/ronela.rb CHANGED
@@ -197,23 +197,32 @@ module Ronela
197
197
  attr_accessor :fondo
198
198
  attr_accessor :x, :y
199
199
  attr_writer :posicion
200
- attr_reader :mostrando,:imagen
200
+ attr_reader :mostrando,:imagen, :tipo
201
201
  #attr_accessor :mostrando #se esta mostrano?
202
202
 
203
- def initialize(archivo)
203
+ def initialize(archivo, tipo=:imagen)
204
204
  @imagen = SDL::Surface.load(archivo)
205
205
  @fondo = nil
206
206
  @posicion = nil
207
207
  @x = 0
208
208
  @y = 0
209
209
  @mostrando = false
210
+ @tipo = tipo
210
211
  end
211
212
 
213
+ def es_escena
214
+ @tipo = :escena
215
+ end
216
+
217
+ def es_imagen
218
+ @tipo = :imagen
219
+ end
212
220
 
213
221
  #borra en la posicion actual
214
222
  def limpiar_de_antes en
215
223
  unless @fondo.nil?
216
224
  SDL::Surface.blit(@fondo.imagen, @x, @y, @imagen.w, @imagen.h, en, @x, @y)
225
+ $pantalla.updateRect(x, y, @imagen.w, @imagen.h)
217
226
  end
218
227
  end
219
228
 
@@ -222,6 +231,7 @@ module Ronela
222
231
  x,y = posicion_a_xy
223
232
  unless @fondo.nil?
224
233
  @fondo.dibujar en, [x, y, @imagen.w, @imagen.h], [x, y, @imagen.w, @imagen.h]
234
+ $pantalla.updateRect(x, y, @imagen.w, @imagen.h)
225
235
  end
226
236
  @mostrando = false
227
237
  end
@@ -229,24 +239,27 @@ module Ronela
229
239
 
230
240
  #dibuja la imagen en
231
241
  def dibujar en, rect=nil, srect=nil
242
+ #si se vuelve a mostrar se borra donde estaba
243
+ #esto permite que solo exista una sola imagen presentada en pantalla referencida por Imagen
244
+ if @mostrando and @tipo != :escena
245
+ limpiar_de_antes en
246
+ end
247
+
248
+ @mostrando = true
232
249
  @x,@y = posicion_a_xy
233
250
  x,y = @x,@y
234
251
  xs, ys = 0,0
235
252
  xs, ys = srect unless srect.nil?
236
253
 
237
- #si se vuelve a mostrar se borra donde estaba
238
- if @mostrando
239
- limpiar_de_antes en
240
- end
241
-
242
254
  unless rect.nil?
243
255
  SDL::Surface.blit(@imagen, xs,ys, rect[2], rect[3], en, rect[0], rect[1])
244
256
  $pantalla.updateRect(rect[0], rect[1], rect[2], rect[3])
245
- else
257
+ else
258
+
246
259
  SDL::Surface.blit(@imagen, xs, ys, @imagen.w, @imagen.h, en, x, y)
247
- $pantalla.flip
260
+ $pantalla.updateRect(x, y, @imagen.w, @imagen.h)
248
261
  end
249
- @mostrando = true
262
+
250
263
  end
251
264
 
252
265
  #convierte posicion palabra a arreglo
@@ -294,6 +307,7 @@ module Ronela
294
307
 
295
308
  end
296
309
 
310
+
297
311
  #Como imagen pero de un solo color
298
312
  class ImagenColor < Imagen
299
313
 
@@ -583,6 +597,7 @@ module Ronela
583
597
  @imagenes[nombre].cargar_variables variables
584
598
  @imagenes[nombre].fondo = @escena
585
599
  @imagenes[nombre].dibujar $pantalla
600
+
586
601
  else
587
602
  Kernel.puts "Imagen #{nombre} no existe"
588
603
  end
@@ -604,6 +619,7 @@ module Ronela
604
619
 
605
620
  if !nombre.empty? and @imagenes.has_key? nombre
606
621
  @escena = @imagenes[nombre]
622
+ @escena.es_escena
607
623
  @escena.dibujar $pantalla
608
624
  @imagenes.each { |k,i|
609
625
  i.fondo = @escena
@@ -622,7 +638,7 @@ module Ronela
622
638
  begin
623
639
  imagen = Imagen.new(variables["archivo"])
624
640
  imagen.fondo = @escena
625
-
641
+ imagen.es_imagen
626
642
  rescue
627
643
  Kernel.puts "No se pudo encontrar imagen #{variables['archivo']}"
628
644
  end
@@ -715,8 +731,57 @@ module Ronela
715
731
  end
716
732
  @fguion.close
717
733
  end
734
+
718
735
 
736
+ #Guarda imagenes del guion en bmp
737
+ #creando un directorio del mismo nombre al guion
738
+ def guardar_bmp_guion guion
739
+
740
+ #sale si no hay guion
741
+ abort "No se encontro guion" unless File.exists? guion
742
+
743
+ @fguion = File.open(guion,"r")
744
+
745
+ dir_bmps = "bmp_#{File.basename(guion)}"
746
+ unless File.directory?(dir_bmps)
747
+ Dir.mkdir(dir_bmps)
748
+ end
749
+ conteo_bmps = 0
750
+
751
+ until @salir
752
+
753
+ if @fguion.eof?
754
+ @salir = true
755
+ end
756
+
757
+ linea = @fguion.gets
758
+ @lenguaje.scan linea
759
+
760
+ #se detiene hasta que alguien diga algo
761
+ if @parar
762
+ while evento = SDL::Event.wait
763
+ case evento
764
+ when SDL::Event::MouseButtonDown
765
+ #se cancela los sonidos
766
+ SDL::Mixer.halt(-1)
767
+ break
768
+ when SDL::Event::Quit
769
+ @salir = true
770
+ break
771
+ end
772
+ end
773
+ @parar = false
774
+ $pantalla.saveBMP(File.join(dir_bmps, "#{conteo_bmps}.bmp"))
775
+ conteo_bmps += 1
776
+
777
+ end
778
+
779
+ end
780
+ @fguion.close
781
+ end
782
+
719
783
  end
784
+
720
785
 
721
786
  end #end module Ronela
722
787
 
@@ -724,6 +789,7 @@ end #end module Ronela
724
789
 
725
790
 
726
791
  if $0 == __FILE__
792
+ require 'optparse'
727
793
  r = Ronela::Ronela.new
728
794
 
729
795
  guion = ARGV[0]
@@ -734,5 +800,20 @@ if $0 == __FILE__
734
800
  abort "#{$0}: No se encontro guion #{guion}, indiquelo\n" unless File.exists? guion
735
801
 
736
802
  $: << File.realpath(File.dirname(guion)).to_s
737
- r.leer_guion guion
803
+
804
+ opciones = {}
805
+ OptionParser.new do |opts|
806
+ opts.banner = "#{$0}: [opciones] <archive guion>"
807
+
808
+ opts.on("--guardar-bmp") do |v|
809
+ opciones[:guardar] = true
810
+ end
811
+ end
812
+
813
+ unless opciones[:guardar].nil?
814
+ r.guardar_bmp_guion guion
815
+ else
816
+ r.leer_guion guion
817
+ end
818
+
738
819
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Ronela
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-28 00:00:00.000000000 Z
12
+ date: 2011-11-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubysdl
16
- requirement: &81259190 !ruby/object:Gem::Requirement
16
+ requirement: &82123580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 0.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *81259190
24
+ version_requirements: *82123580
25
25
  description:
26
26
  email: info@manadalibre.org
27
27
  executables: