mispy-archive / libtcod Goto Github PK
View Code? Open in Web Editor NEWRuby bindings for the libtcod roguelike library
License: MIT License
Ruby bindings for the libtcod roguelike library
License: MIT License
The example program libtcod-ruby-test
works fine on my system. However, when I exit by pressing ESC, the program closes the main window and hangs. Standard CTRL+C kills the program.
I placed a puts
at the end of the program and that executes.
I've tried recompiling libtcod from source against my system's SDL and I still get the same behaviour. Doing a backtrace in gdb shows it's hanging in pthread_join
called from SDL_WaitThread()
and (via some intermediate functions) SDL_Quit()
.
I'm running 64-bit Ubuntu 13.10 on an AMD system.
I get an error (see below) when I run the example script in the readme after gem install libtcod
(0.0.9) using Ruby 1.9.3
The error is coming from FFI. The version of FFI that came with this ruby (p545) is 1.0.9. When I upgrade to ffi-1.9.3 the error goes away.
/usr/local/var/rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/ffi-1.0.9/lib/ffi/struct_layout_builder.rb:151:in `field_for_type': invalid struct field type #<FFI::Type::Builtin:BOOL size=1 alignment=1> (TypeError)
from /usr/local/var/rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/ffi-1.0.9/lib/ffi/struct_layout_builder.rb:85:in `add'
from /usr/local/var/rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/ffi-1.0.9/lib/ffi/struct.rb:281:in `array_layout'
from /usr/local/var/rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/ffi-1.0.9/lib/ffi/struct.rb:200:in `layout'
from /usr/local/var/rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/libtcod-0.0.9/lib/libtcod/struct.rb:10:in `layout'
from /usr/local/var/rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/libtcod-0.0.9/lib/libtcod/bindings.rb:80:in `<class:Key>'
from /usr/local/var/rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/libtcod-0.0.9/lib/libtcod/bindings.rb:79:in `<module:TCOD>'
from /usr/local/var/rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/libtcod-0.0.9/lib/libtcod/bindings.rb:3:in `<top (required)>'
from /usr/local/var/rbenv/versions/1.9.3-p545/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/var/rbenv/versions/1.9.3-p545/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/var/rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/libtcod-0.0.9/lib/libtcod.rb:5:in `<top (required)>'
from /usr/local/var/rbenv/versions/1.9.3-p545/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
from /usr/local/var/rbenv/versions/1.9.3-p545/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
from /usr/local/var/rbenv/versions/1.9.3-p545/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from test.rb:1:in `<main>'
Not sure if you're still actively developing, but if you are, then you might consider sub-classing Console and get the root_console as a separate class. It'll allow you to get rid of having that third parameter in the constructor while still being able to pass rootconsoles everywhere you pass regular consoles. It seems more rubyesque to do it that way.
Here's an example from my port:
module Rogue
class RootConsole < Console
def initialze(width, height)
if width < 0
fail ArgumentError, "width must be non-negative, was #{width}"
elsif height < 0
fail ArgumentError, "width must be non-negative, was #{width}"
end
@width = width
@height = height
@clear_cell = Console.clear_cell
@out_of_bounds_cell = Console.out_of_bounds_cell
@ptr = nil
ObjectSpace.define_finalizer(self, self.class.finalize(@ptr))
end
def self.instance
@instance ||= create_instance
end
def self.create_instance
unless Rogue::System.initialized?
error_message = "Rogue::System.initialize has not been called yet."
fail error_message
end
RootConsole.new(System.SCREEN_WIDTH, System.SCREEN_HEIGHT)
end
private_class_method :create_instance
end
end
Ran the example script. Here's what I got.
PS C:\Users\TOSHIBA\desktop\Games\EZRogue> ruby rogue2.rb C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/ffi-1.9.10-x86-mingw32/lib/ffi/library.rb:133:in
block in ffi_lib'
(LoadError)open library 'libtcod-mingw': The specified module could not be found.
.
Could not open library 'libtcod-mingw.dll': The specified module could not be found.
.
Could not open library 'C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/libtcod-0.1.1/clib/i686/libtcod-mingw.dll':
The specified module could not be found.
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/ffi-1.9.10-x86-mingw32/lib/ffi/library.rb:100:in `map'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/ffi-1.9.10-x86-mingw32/lib/ffi/library.rb:100:in `ffi_
lib'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/libtcod-0.1.1/lib/libtcod/bindings.rb:23:in <module:T COD>' from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/libtcod-0.1.1/lib/libtcod/bindings.rb:3:in
<top (requ
ired)>'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in require' from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
require'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/libtcod-0.1.1/lib/libtcod.rb:5:in <top (required)>' from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in
require'
from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in rescue in require' from C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in
require'
from rogue2.rb:1:in <main>' PS C:\Users\TOSHIBA\desktop\Games\EZRogue>
I've not managed to get mouse support working. Waiting for any event will not respond to mouse events and explicitly calling mouse_get_status returns an empty struct (zeroed out by fffi I think). Has anyone else had simillar problems?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.