require 'eventmachine'
require 'gosu'
class Window < Gosu::Window
def initialize
super(640, 480)
end
def update
begin
0 / 0 # Generate error.
rescue => e
p e
self.close
EM.stop
end
end
end
$window = Window.new
EM.run do
EM.add_periodic_timer(1 / 60.0) { $window.tick }
end
EM.add_periodic_timer(1 / 60.0) { $window.tick unless $window.closed? }
require 'eventmachine'
require 'gosu'
class Window < Gosu::Window
def initialize
super(640, 480)
end
def update
0 / 0 # Generate error.
end
end
$window = Window.new
EM.run do
EM.add_periodic_timer(1 / 60.0) { $window.tick }
end
class MW < Gosu::Window
def initialize
super 640, 480
@song = Gosu::Song.new("alert2.mp3")
@song.play
end
end
window = MW.new
window.show
if compare_img(img) == :face
Gosu::Song.new("alert2.mp3").play
end
@song.play
, sorry i forgot it.
window.show
Thread.new do
song = Gosu::Song.new("file.mp3")
song.play
loop do
song.update
break unless song.playing?
end
end
Gosu::Song
:song = Gosu::Simple.new("file.mp3") # => RuntimeError: File contains data in an unknown format.
Microsoft Windows [Versión 6.3.9600]
(c) 2013 Microsoft Corporation. Todos los derechos reservados.
C:\Users\Gordon>gem install gosu
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing gosu:
ERROR: Failed to build gem native extension.
current directory: C:/Ruby23/lib/ruby/gems/2.3.0/gems/gosu-0.10.7/ext/gosu
C:/Ruby23/bin/ruby.exe -r ./siteconf20160426-2900-1dlz4st.rb extconf.rb
This gem is not meant to be installed on Windows. Instead, please use:
gem install gosu --platform=i386-mingw32
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby23/lib/ruby/gems/2.3.0/gems/gosu-0.10.
7 for inspection.
Results logged to C:/Ruby23/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/gos
u-0.10.7/gem_make.out
C:\Users\Gordon>
Microsoft Windows XP [Versión 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Ruby193>ruby test.rb
test.rb:9: [BUG] Segmentation fault
ruby 1.9.3p551 (2014-11-13) [i386-mingw32]
-- Control frame information -----------------------------------------------
c:0014 p:---- s:0041 b:0041 l:000040 d:000040 CFUNC :draw
c:0013 p:0021 s:0034 b:0034 l:000033 d:000033 METHOD test.rb:9
c:0012 p:0031 s:0031 b:0031 l:000cbc d:000030 LAMBDA C:/Ruby193/lib/ruby/gems/1.
9.1/gems/gosu-0.10.6-x86-mingw32/lib/gosu/swig_patches.rb:28
c:0011 p:---- s:0027 b:0027 l:000026 d:000026 FINISH
c:0010 p:0011 s:0025 b:0025 l:000024 d:000024 METHOD C:/Ruby193/lib/ruby/gems/1.
9.1/gems/gosu-0.10.6-x86-mingw32/lib/gosu/swig_patches.rb:38
c:0009 p:---- s:0022 b:0022 l:000021 d:000021 FINISH
c:0008 p:---- s:0020 b:0020 l:000019 d:000019 CFUNC :tick
c:0007 p:0027 s:0017 b:0017 l:000016 d:000016 METHOD C:/Ruby193/lib/ruby/gems/1.
9.1/gems/gosu-0.10.6-x86-mingw32/lib/gosu/patches.rb:135
c:0006 p:---- s:0014 b:0014 l:000013 d:000013 FINISH
c:0005 p:---- s:0012 b:0012 l:000011 d:000011 CFUNC :show
c:0004 p:0011 s:0009 b:0009 l:000008 d:000008 METHOD C:/Ruby193/lib/ruby/gems/1.
9.1/gems/gosu-0.10.6-x86-mingw32/lib/gosu/swig_patches.rb:45
c:0003 p:0051 s:0006 b:0006 l:00233c d:00107c EVAL test.rb:12
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:00233c d:00233c TOP
-- Ruby level backtrace information ----------------------------------------
test.rb:12:in <main>'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/gosu-0.10.6-x86-mingw32/lib/gosu/swig_patche
s.rb:45:in
show'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/gosu-0.10.6-x86-mingw32/lib/gosu/swig_patche
s.rb:45:in show'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/gosu-0.10.6-x86-mingw32/lib/gosu/patches.rb:
135:in
tick'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/gosu-0.10.6-x86-mingw32/lib/gosu/patches.rb:
135:in tick'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/gosu-0.10.6-x86-mingw32/lib/gosu/swig_patche
s.rb:38:in
protected_draw_2'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/gosu-0.10.6-x86-mingw32/lib/gosu/swig_patche
s.rb:28:in block (2 levels) in <class:Window>'
test.rb:9:in
draw'
test.rb:9:in `draw'
-- C level backtrace information -------------------------------------------
C:\WINDOWS\system32\ntdll.dll(KiFastSystemCallRet+0x0) [0x7c91e514]
C:\WINDOWS\system32\kernel32.dll(WaitForSingleObject+0x12) [0x7c802542]
C:\Ruby193\bin\msvcrt-ruby191.dll(rb_vm_bugreport+0xf9) [0x62e7c9d9]
C:\Ruby193\bin\msvcrt-ruby191.dll(rb_name_err_mesg_new+0x186) [0x62d41436]
C:\Ruby193\bin\msvcrt-ruby191.dll(rb_bug+0x2f) [0x62d4229f]
C:\Ruby193\bin\msvcrt-ruby191.dll(rb_check_safe_str+0x1f0) [0x62e04220]
[0x004011e6]
[0x09527d62]
C:\WINDOWS\system32\kernel32.dll(UnhandledExceptionFilter+0x1c7) [0x7c864771]
-- Other runtime information -----------------------------------------------
* Loaded script: test.rb
* Loaded features:
0 enumerator.so
1 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/encdb.so
2 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/iso_8859_1.so
3 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/trans/transdb.so
4 C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/defaults.rb
5 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/rbconfig.rb
6 C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/deprecate.rb
7 C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/exceptions.rb
8 C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/defaults/operating_system.rb
9 C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb
10 C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems.rb
11 C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/version.rb
12 C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/requirement.rb
13 C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/platform.rb
14 C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb
15 C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/path_support.rb
16 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/utf_16le.so
17 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/trans/utf_16_32.so
18 C:/Ruby193/lib/ruby/1.9.1/i386-mingw32/enc/trans/single_byte.so
19 C:/Ruby193/lib/ruby/gems/1.9.1/gems/gosu-0.10.6-x86-mingw32/lib/1.9/gosu.s
o
20 C:/Ruby193/lib/ruby/gems/1.9.1/gems/gosu-0.10.6-x86-mingw32/lib/gosu/swig_
patches.rb
21 C:/Ruby193/lib/ruby/gems/1.9.1/gems/gosu-0.10.6-x86-mingw32/lib/gosu/patch
es.rb
22 C:/Ruby193/lib/ruby/gems/1.9.1/gems/gosu-0.10.6-x86-mingw32/lib/gosu.rb
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
C:\Ruby193>
require "gosu"
class Game_Window < Gosu::Window
def initialize
super(640, 480)
@font = Gosu::Font.new(self, "Arial", 18)
end
def draw
@font.draw("Text", 0, 0, 0) # Error
end
end
Game_Window.new.show
~$ sudo gem install gosu
Building native extensions. This could take a while...
ERROR: Error installing gosu:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
The Gosu gem requires some libraries to be installed system-wide.
See the following site for a list:
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in
require'
from extconf.rb:62:in `<main>'
https://github.com/jlnr/gosu/wiki/Getting-Started-on-Linux
Gem files will remain installed in /var/lib/gems/1.9.1/gems/gosu-0.10.5 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/gosu-0.10.5/ext/gosu/gem_make.out
sudo apt-get install build-essential libsdl2-dev libsdl2-ttf-dev libpango1.0-dev \libgl1-mesa-dev libfreeimage-dev libopenal-dev libsndfile-dev
def button_down(key)
char = (key + 93).chr
end
@data = Array.new(width, Array.new(height, default_value))
@data[x][y] = terrain_id
@data[0][1] = 0 # [
[nil, 1, nil], # XY: 0, 1
[nil, 1, nil], # XY: 1, 1
[nil, 1, nil] # XY: 2, 1
]
class Data_Tilemap
attr_reader(:data)
attr_accessor(:default_value)
def initialize(width, height, default_value = 0)
@width = width
@height = height
@default_value = default_value
#@data = Array.new(width, Array.new(height, default_value))
@data = []
width.times { @data.push(Array.new) }
end
def [](x, y)
if x.between?(0, @width - 1) and y.between?(0, @height - 1)
return @data[x][y]
else
return @default_value
end
end
def []=(x, y, value)
@data[x][y] = value if x.between?(0, @width - 1) and y.between?(0, @height - 1)
print(
@data[0].object_id, " ", #=> 21483444
@data[1].object_id, " ", #=> 21483444
@data[2].object_id) #=> 21483444
puts
end
def resize(width, height)
new_data = Array.new(width, Array.new(height, @default_value))
for x in 0...@width
for y in 0...@height
if x.between?(0, width - 1) and y.between?(0, height - 1)
new_data[x][y] = @data[x][y]
end
end
end
@data = new_data
@width = width
@height = height
end
end
file = File.open(filename, "wb")
Marshal.dump(data, file)
file.close
file = File.open(@filename, "rb")
@data = Marshal.load(file)
file.close
require 'gosu'
: Look the picture./\[\d+\]/.match("text[2]") # => "2" Nice!
/\[\d+\]/.match("text[2]_plus[4]") # => "2" # Problem
/\[\d+\]+/.match("text[2]_plus[4]") # => "2" Problem i need "4", the last
gem uninstall ruby-opengl-0.60.1-x86-mingw32-ruby19.gem
but => INFO: gem "ruby-opengl-0.60.1-x86-mingw32-ruby19.gem" is not installed# enable RubyInstaller DevKit usage as a vendorable helper library
unless ENV['PATH'].include?('C:\\Ruby1.9.3\\Nueva carpeta\\mingw\\bin') then
puts 'Temporarily enhancing PATH to include DevKit...'
ENV['PATH'] = 'C:\\Ruby1.9.3\\Nueva carpeta\\bin;C:\\Ruby1.9.3\\Nueva carpeta\\mingw\\bin;' + ENV['PATH']
end
ENV['RI_DEVKIT'] = 'C:\\Ruby1.9.3\\Nueva carpeta'
ENV['CC'] = 'gcc'
ENV['CXX'] = 'g++'
ENV['CPP'] = 'cpp'
require 'rubygems'
require 'gosu'
gets
require 'rubygems'
require 'opengl'
gets
def draw_text(x, y, string)
text = Gosu::Image.from_text(@window, string, "Arial", 18)
@image.splice(text, x, y, :chroma_key => [0, 0, 0, 1])
end
@sprite = Sprite.new # => Make
@sprite.x = x # => Make
@sprite.y = y # => Make
@sprite.z = z # => Make
@sprite.ox = ox # => Make
@sprite.oy = oy # => Make
@sprite.visible = visible # => Make
@sprite.zoom_x = zoom_x # => Make
@sprite.zoom_y = zoom_y # => Make
@sprite.angle = angle # => Make
@sprite.tone = Color.new(red, green, blue[, alpha = 255]) # => Make
@sprite.bitmap = Bitmap.new(width, height) or Bitmap.new(filename) # => Make
@sprite.bitmap.set_pixel(x, y, color) # => Make
@sprite.bitmap.get_pixel(x, y) # => Make
@sprite.bitmap.set_rect(x, y, width, height, color, fill) or @sprite.bitmap.set_rect(Rect.new(x, y, width, height), color, fill) # => Make
@sprite.bitmap.src_rect = Rect.new(x, y, width, height) # => Make
@sprite.bitmap.blt(x, y, Bitmap.new('image.png')[, Rect.new(x, y, width, height) = Rect.new(0, 0, bitmap.width, bitmap.height)]) # => Make
@sprite.bitmap.clear # => Make
Keyboard.trigger?(key) # => Make
Keyboard.trigger_release?(key) # => Make
Keyboard.press?(key) # => Make
Mouse.trigger?(key) # => Make
Mouse.trigger_release?(key) # => Make
Mouse.press?(key) # => Make
@text = Image.from_text(@window, "Some text", font, 10)
for x in 0..@text.width
for y in 0..@text.height
color = @text.get_pixel(x, y)
if color == [0, 0, 0, 1]
@text.set_pixel(x, y, [0, 0, 0, 0]
end
end
end
@image = Gosu::Image.new(@window, 'media/image.png')
@image.draw_text(0, 0, 'Name: Orc')
class Window_Command < Window_Base
def initialize(width, commands)
self.width = width
self.height = 64 # Window height
@index = 0
@commads = commands
@cursor = Sprite.new
@cursor.bitmap = Bitmap.new('cursor.png') # Bitmap is equal Gosu::Image but Bitmap is created by my.
self.contents = Bitmap.new(width, commands.length * 32) # width = 192; height = 96
self.contents.src_rect = Rect.new(0, 0, self.width, self.height) # Not show beyond the window height.
refresh
end
def refresh
self.contents.clear
for c in 0...@commands.length # 0, 1, 2
draw_item(@commands[c], c)
end
end
def draw_item(text, index)
self.contents.draw_text(0, index * 32, text) # (x, y, string) I need to create this method.
end
def update
if Keyboard.trigger?(:Down)
@index += 1
elsif Keyboard.trigger?(:Up)
@index -= 1
end
@cursor.y = @index * 32
update_src_rect
end
def update_src_rect
case @index
when 0..1 then self.contents.src_rect.y = 0
when 3 then self.contents.src_rect.y = 32
end
end
end
window_commands = Window_Command(192, ['New Game', 'Continue', 'Exit'])
if Keyboard.trigger?(:Enter)
case window_commands.index
when 0 # New Game
when 1 # Continue
when 2 # Exit
end
end
require 'gosu'
require 'texplay'
class Window < Gosu::Window
def initialize
super(640, 480, false)
# Try this code
@original_image = TexPlay.create_image(self, 32, 32)
@original_image.rect(0, 0, 5, 5, :color => :red) # later: Comment this line.
@original_image.insert(Gosu::Image.new(self, 'image.png'), 6, 0)
@cropped_image = TexPlay.create_image(self, 100, 100)
@cropped_image.splice(@original_image, 0, 0)
end
def draw
@cropped_image.draw(0, 0, 0)
end
end
Window.new.show
@original_image.insert(image, x, y)
@cropped_image.splice(@original_image, x, y)
@image.rect_x = x
@image.rect_y = y
@image.rect_width = width
@image.rect_height = height
@image.set_rect(x, y, width, height)
@image = Gosu::Image.new(window, EmptyImageSource.new(100, 100), tileable, rect_x, rect_y, rect_width, rect_height)
@image.rect_x = x
@image.rect_y = y
@image.rect_width = width
@image.rect_height = height
@image.set_rect(x, y, width, height)
x = 50
y = 50
color = rand(100) > 50 ? :red : [1, 0, 0, 1]
@image.pixel(x, y, color)
x = 50
y = 50
color = rand(100) > 50 ? :red : [1, 0, 0, 1]
@image.pixel(x, y, :color => color)
:color => color
.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill