Git Product home page Git Product logo

ruby2d's Introduction

Welcome to Ruby 2D!

Gem Build Status Discord

This is the Ruby 2D gem. Check out the Ruby 2D website to learn how to get started building 2D apps in Ruby.

Development

To work on the gem locally, first clone this repo using:

git clone --recursive https://github.com/ruby2d/ruby2d.git

To keep the size of this source code repository small, Git submodules are used to reference assets. The --recursive flag ensures submodules are initialized and updated when this repo is cloned. If you happened to clone this repo without the --recursive flag, you can still initialize and update submodules with:

git submodule init
git submodule update --remote

Update these submodules at any time using git submodule update --remote or the rake update task.

Next, install dependencies with Bundler by running bundle install to get the development gems.

Finally, run rake to build and install the gem locally. Use rake dev to build referencing user-installed libraries (e.g. SDL).

Tests

Ruby 2D uses a combination of automated tests via RSpec and manual, interactive tests to verify the correctness of visual, audio, and input functionality. Build the gem and run all automated tests using the rake command. Build and run an interactive test in the test/ directory using rake test:<target> <name_of_test>, for example:

# Run `test/testcard.rb` using the standard Ruby interpreter, MRI (CRuby)
rake test:cruby testcard  # `test:mri` or just `test` work also

# Build `test/audio.rb` using mruby and run
rake test:mruby audio

# Build `test/mouse.rb` for the web using WebAssembly and run in the default browser
rake test:wasm mouse

Contribute

Ruby 2D is an entirely open-source project (including its dependencies) built by dedicated folks who believe creating 2D applications should be simple, natural, and joyful, in the spirit of the Ruby language itself.

If you'd like to get involved, there are a number of ways to do so:

  • Suggest and implement new features. 🌟 Ruby 2D already does a lot, but there are plenty of new things it could do. If you have a feature request, or a suggestion on how to improve the domain-specific language, or something else to add, remove, or change, open a new issue and tell us about it. If you just want to casually talk through an idea without the pressure of opening an issue, send a note to the mailing list or chat with us on Gitter.

  • Add support for more platforms. 💻 Ruby 2D aims to be entirely cross platform. Help us test and improve the developer experience on existing platforms and add new ones.

  • Find and fix issues. 🐛 Your help identifying and fixing bugs, and improving performance along the way, will be critical to ensuring others have a solid experience using the library. Check out the issue tracker and have at it!

  • Write and review documentation. 📚 Vitally important to the success of every open-source project is documentation. We're off to a decent start, but there's always more to write and edit. Browse through the Ruby 2D website and help us identify areas to add clarity or fill in gaps. At the top of most pages, you'll see a link to "suggest an edit" which goes directly to the source file in the website repo.

  • Create and improve examples. 👾 We're currently a little light on sample applications to help folks get started. We'd love to get your ideas for small, single-file apps to guide users through specific features or techniques, which we collect in the examples repository. Check out the showcase to see what people are building and get some inspiration.

Technical contributions

In order to achieve such simplicity, a lot has to happen under the hood. Whether adding a feature or fixing a bug, try to do the following to ensure your pull request gets merged. Some of these might seem daunting, but we're happy to help along the way!

  • Check if there is an existing issue, and if not, open a new one to start a discussion. Before dedicating time and energy to an idea or fix, let's make sure it's consistent with the principles and goals of the project, and that we have a solid strategy in place to implement and test.

  • Use a subset of Ruby that works everywhere. Ruby 2D applications are, of course, written in Ruby. Some users may choose to harness the full power of the language, standard library, and ecosystem of gems by writing interpreted apps targeting the standard implementation, MRI. Others may want to target the web via WebAssembly, mobile devices, or build native desktop applications, all which make use of a different Ruby implementation called mruby. Ruby 2D aims to support all of these use cases, even with the same app codebase. Your contribution must support a subset of Ruby that is compatible with and behaves similarly across MRI/CRuby and mruby. Beyond reading the documentation for each Ruby implementation, you can also try out code snippets on the command line using their respective REPLs: irb for MRI, and mirb for mruby.

  • Comprehensively test your change. Unlike other Ruby libraries, not everything here can be easily covered with unit tests alone. We also need to make sure things look and sound right, inputs work as expected, and behavior is consistent across all platforms Ruby 2D supports.

Updating Ruby 2D

  1. Update the assets repo, follow the instructions in the README
  2. Run rake update to update the submodules

Preparing a release

  1. Run tests on all supported platforms
  2. Update the version number in version.rb, commit changes
  3. Create a new release in GitHub, with tag in the form v#.#.#, and write a little release note
  4. Run rake release to build the gem, then push it to rubygems.org with gem push ruby2d-#.#.#.gem
  5. 🎉

ruby2d's People

Contributors

aekobear avatar ajbdev avatar alexdovzhanyn avatar alexvpopov avatar andrewhavens avatar blacktm avatar caporta avatar cdlm avatar collindonnell avatar compufox avatar dwu185 avatar grzegorz-jakubiak avatar heitorado avatar mariovisic avatar mikeappell avatar nogginly avatar orangejulius avatar pusewicz avatar sreejakshetty avatar timgates42 avatar tlrasor avatar wmoxam avatar yumetodo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ruby2d's Issues

Opal doesn't seem to know where my gems are

Hey

I added a gem to the lib using ruby2d and Opal is unable to produce the build, because of the following:

/home/killa/.rvm/gems/ruby-2.2.4/gems/opal-0.10.3/lib/opal/builder.rb:118:in `read': A file required by "build/src.rb" wasn't found. (Opal::Builder::MissingRequire)
can't find file: "perlin_noise" in ["/home/killa/.rvm/gems/ruby-2.2.4/gems/opal-0.10.3/opal", "/home/killa/.rvm/gems/ruby-2.2.4/gems/opal-0.10.3/stdlib", "/home/killa/.rvm/gems/ruby-2.2.4/gems/opal-0.10.3/lib"]

Assuming expected behavior is for opal to look for gems where mri is looking for gems, I will try to fiddle with Opals configuration in incoming days.

Bitmap?

I'm thinking about writing a maze/cave generator for my game. Check this link: https://gamedevelopment.tutsplus.com/tutorials/generate-random-cave-levels-using-cellular-automata--gamedev-9664

For the generation, I would like to see a big overview of the result, like available on that link. However, if I were to construct it from squares or rectangles, it would have very poor performance.

Is there an option to have a sort of a bitmap, where I would be able to decide bitmap pixel size, which pixels are on, which off, and what the color of pixels off is? Or is there another solution for doing this efficiently?

Set window flags, options

User Story

As a user, I want the ability to set various options for the window, like making it borderless, resizable, or fullscreen, so that I can create the perfect experience.

Tasks

Fails to install on MacOS 10.12.3 and Ruby 2.3.3

$ brew install simple2d
Warning: simple2d/tap/simple2d-0.5.0 already installed

$ gem install ruby2d
Building native extensions.  This could take a while...
ERROR:  Error installing ruby2d:
	ERROR: Failed to build gem native extension.

    current directory: /Users/wes/.rvm/gems/ruby-2.3.3/gems/ruby2d-0.2.1/ext/ruby2d
/Users/wes/.rvm/rubies/ruby-2.3.3/bin/ruby -r ./siteconf20170201-25026-8k7449.rb extconf.rb
creating Makefile

current directory: /Users/wes/.rvm/gems/ruby-2.3.3/gems/ruby2d-0.2.1/ext/ruby2d
make "DESTDIR=" clean

current directory: /Users/wes/.rvm/gems/ruby-2.3.3/gems/ruby2d-0.2.1/ext/ruby2d
make "DESTDIR="
compiling ruby2d.c
ruby2d.c:262:18: warning: incompatible pointer types assigning to 'S2D_On_Key' (aka 'void (*)(int, const char *)') from 'void (const char *)' [-Wincompatible-pointer-types]
  window->on_key = on_key;
                 ^ ~~~~~~
ruby2d.c:263:11: error: no member named 'on_key_down' in 'S2D_Window'
  window->on_key_down = on_key_down;
  ~~~~~~  ^
ruby2d.c:264:25: warning: incompatible pointer types assigning to 'S2D_On_Controller' (aka 'void (*)(int, bool, int, int, bool, int, bool)') from 'void (bool, int, int, bool, int)' [-Wincompatible-pointer-types]
  window->on_controller = on_controller;
                        ^ ~~~~~~~~~~~~~
2 warnings and 1 error generated.
make: *** [ruby2d.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/wes/.rvm/gems/ruby-2.3.3/gems/ruby2d-0.2.1 for inspection.
Results logged to /Users/wes/.rvm/gems/ruby-2.3.3/extensions/x86_64-darwin-15/2.3.0/ruby2d-0.2.1/gem_make.out

Error Installing `ruby2d` on Ubuntu 14.04

Hi @blacktm : Sorry to bother you, I am getting following error while try to install ruby2d gem on my Ubuntu 14.04

Building native extensions.  This could take a while...
ERROR:  Error installing ruby2d:
    ERROR: Failed to build gem native extension.

    /home/rishi/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20160401-21057-yotffi.rb extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling ruby2d.c
ruby2d.c: In function ‘render’:
ruby2d.c:133:3: error: ‘for’ loop initial declarations are only allowed in C99 mode
   for (int i = 0; i < num_objects; ++i) {
   ^
ruby2d.c:133:3: note: use option -std=c99 or -std=gnu99 to compile your code
ruby2d.c:215:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
         struct image_data *data;
         ^
ruby2d.c:234:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
         struct text_data *data;
         ^
ruby2d.c: In function ‘ruby2d_show’:
ruby2d.c:253:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
   char *title = RSTRING_PTR(rb_iv_get(self, "@title"));
   ^
make: *** [ruby2d.o] Error 1

make failed, exit code 2

Gem files will remain installed in /home/rishi/.rvm/gems/ruby-2.2.1/gems/ruby2d-0.2.0 for inspection.
Results logged to /home/rishi/.rvm/gems/ruby-2.2.1/extensions/x86_64-linux/2.2.0/ruby2d-0.2.0/gem_make.out

It would be great if you can give me some suggestions!

P.S. I had successfully installed simple2d gem in my machine by follow all the steps given over simple2d GitHub Page

Thanks in advance 😊

Switch all constructors to named params?

There is a great deal of informations passed into renderable objects, and more are coming, as the gem matures. It is becoming increasingly difficult to manage it. Many libraries, with ActiveRecord leading, use named params, or just initialization by hash to manage large amount of data in constructors. Maybe this would be a good idea to use this approach? Would you be interested in seeing some examples of how this would look like?

unable to install gem

getting an error when compiling native extensions.

I'm using rvm and brew was installed by rvm, so I'm suspicious that this may be an issue related to a non-standard install of brew.

it's unable to include simple2d.h which I do have installed, so it's probably just unable to find the header file as it's in a non-standard location...at least that's my suspicion.

Here's the full dump of the error...

$ gem install ruby2d
Building native extensions.  This could take a while...
ERROR:  Error installing ruby2d:
    ERROR: Failed to build gem native extension.

    /Users/ericslick/.rvm/rubies/ruby-2.2.4/bin/ruby -r ./siteconf20160103-78885-t55gek.rb extconf.rb
Cloning into '/Users/ericslick/.homebrew/Library/Taps/simple2d/homebrew-tap'...
Error: simple2d/tap/simple2d 0.0.4 already installed
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling ruby2d.c
ruby2d.c:2:10: fatal error: 'simple2d.h' file not found
#include <simple2d.h>
         ^
1 error generated.
make: *** [ruby2d.o] Error 1

make failed, exit code 2

I was interested in your library as it seemed to be a newer project, the graphics I need to do are plenty simple enough for what's implemented and it's not a production project,. I simply need to visualize something pretty basic (lots of little bocks).

Feature Request: catch-all on_key and on_controller callbacks

I'm working on building an app with Ruby2D. In the process, I've found a few cases where I need to register a generic callback for handling lots of different keys/buttons without knowing which one will be pressed. I can create a monkey patch in the short term, but I was wondering if a catch-all callback would fit in with your design goals?

For example:

on_key do |key|
  if key == "something"
    # etc...
  end
end

on_controller do |is_axis, axis, val, is_btn, btn|
  # do something
end

Native file exits without crash

Hi

I'm experimenting with ruby2d a little bit and I'm having a problem. This program:

require 'ruby2d'

@fps_text = Text.new(15, 15, "fps: 0", 40, "fonts/arial.ttf")

update do
  fps = get(:fps)
  @fps_text.remove
  @fps_text.text = fps.to_s
  @fps_text.add
end

show

Is executing properly (provided there is font in proper place) under MRI, is being built properly with ruby2d build command, but when I'm tring to open the compiled problem, it opens the window for a split second and closes without any exception.

What behavior should I be expecting here?

Build native Ruby 2D apps

User Story

As a user, I want to compile my Ruby 2D app to native code, so that I can run it anywhere, particularly where a Ruby interpreter isn't available or perhaps practical.

Notes

This would use mruby. I know this is possible, but is still going to be fairly challenging, so you've been warned ⚠️

Add support for iOS, tvOS

SDL supports iOS, and there's some prereleased tvOS support as well with sample Xcode projects. In this issue, we can explore how to add support for these platforms natively.

Is it possible to return a width of rendered text?

I would like to use Text#width feature. Is it possible to return something like this from rendered Text element?

I need this, for example, to be able to render buttons. If I want to have a nice button background, I need to be able to know how wide it needs to be.

`Ruby2D::Text#text=` crashes upon receiving non-strings

Simplest replication would be (provided there is font properly sent) :

require 'ruby2d'

@text = Text.new(15, 15, "test", 40, "fonts/arial.ttf")

update do
  @text.text = 1
end

show

This segfaults the program on MRI. If I set set the text to Time.now, id does not segfault, but garbage is seen. I believe the solution here is to call #to_s on input internally on #text method.

What do you think about that? It is natural for me to just pass whatever I want to the method and assume it will do the necessary formatting.

I wanted to provide a PR with it, but I don't see the implementation of that method in https://github.com/ruby2d/ruby2d/blob/master/lib/ruby2d/text.rb, there is only reader defined...

Image rotation

Hi again!

Would it be possible to change rotation of images? In my example I would like to rotate image of a character 90 degrees right to indicate that the character is sleeping.

I don't see any code I would be able to use in current code, maybe this would be easy to add with some additions to the c layer?

Setting image width, height and color in constructor

Every other renderable class has the ability to set those attributes on initialization, and image does not. I personally would use this in my code, and it even happens in testcard. Should we provide an ability to do this?

Add sound

User Story

As a user, I want a Sound class, so that I can load and play short audio samples.

Tasks

Release v0.4.0

This issue is for capturing tasks to prepare for the next release of Ruby 2D.

Simple 2D

  • Implement #52, resize sprite
  • Fix (SDL_Init) No available video device on Raspberry Pi (see mailing list) — PR #54, ready to test
  • Update documentation for new API
  • Write release notes
  • Prepare v0.6.0 release

Simple2D.js

  • Make sure API is updated/consistent with Simple 2D
  • Release v0.2.0 to npm

Ruby 2D

  • Merge #61, contains?
  • Merge #53, default font — If we can't get working for MRuby, just target MRI for now
    • Skipping, just checking if font file exists for now
  • Make PR for named parameters, #48
  • Write release notes
  • Prepare release and push v0.4.0 RubyGems
  • Update docs on ruby2d.com

Is it possible to have different bindings for mouse key up and mouse key down?

I seem to be only able to do

on(mouse: 'any') do
  ...
end

Which is good and nice, but I would also be able to make a good use of being able to differentiate between mouse up and mouse down events. I'm not sure if I understand the implementation properly, but it seems that only one event is called.

Is it possible to have a distinction between different mouse events?

EDIT

Also I noticed left and right keys are treated the same, would it be possible to have this recognised?

On key up and on key down keyboard events?

Hey

on_key seems to be called repeatedly for as long, as long the key is down. I would like to ask if this is expected behavior or a bug. It makes it difficult to implement a feature like pausing on space ( and unpausing on next space), since it's called random amount of times when I press the space button, and it randomly leaves the game in either paused or unpaused state.

Running on Windows Subsystem for Linux

The current version of WSL has no problems installing Ruby. I used rbenv to test different versions, but all of them fail to produce any form of output.
Running ruby -v testing.rb, where testing.rb is the standard triangle example, produces the following

ruby 2.3.6p384 (2017-12-14 revision 61254) [x86_64-linux]
/home/user/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/ruby2d-0.5.0/lib/ruby2d/line.rb:20: warning: method redefined; discarding old color=

which seems to be an unrelated warning.
Interrupting with CTRL+C produces the following output:

^C/home/user/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/ruby2d-0.5.0/lib/ruby2d/window.rb:in `block in initialize': Interrupt
        from /home/user/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/ruby2d-0.5.0/lib/ruby2d/window.rb:233:in `update_callback'
        from /home/user/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/ruby2d-0.5.0/lib/ruby2d/window.rb:237:in `ext_show'
        from /home/user/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/ruby2d-0.5.0/lib/ruby2d/window.rb:237:in `show'
        from /home/user/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/ruby2d-0.5.0/lib/ruby2d/application.rb:40:in `show'
        from /home/user/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/ruby2d-0.5.0/lib/ruby2d/dsl.rb:29:in `show'
        from testing.rb:12:in `<main>'

The culprit seems to be @update_proc = Proc.new {} in window.rb.

Using irb

$ irb
irb(main):001:0> require 'ruby2d'
=> true
irb(main):002:0> show

also waits indefinitely, until interruption.

I assume this has something to do with WSL and window creation, but I'm curious why it produces an error on the given line. I got the same results for Ruby 2.3.6, 2.4.3 and 2.5.0.
Using ruby2d build --all testing.rb, I can build the web version without a problem. Trying to run the generated app file using ./build/app produces no output and hangs. It doesn't generate a .exe, either.

I'm hopeful that WSL can be a valid alternative for people who want to manage different versions of Ruby and not have to install them separately for Windows!

The library crashes (Ubuntu 16.04.3 64bits), undefined symbol : glGenVertexArrays

Hi,

I hope this is the right place to report this. Yesterday I installed the gem and tried the triangle test (app.rb ) which worked fine. But a bit later on (I may have updated Ubuntu in between) when launching it I got the following error :

/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': /var/lib/gems/2.3.0/gems/ruby2d-0.4.2/lib/ruby2d/ruby2d.so: undefined symbol: glGenVertexArrays - /var/lib/gems/2.3.0/gems/ruby2d-0.4.2/lib/ruby2d/ruby2d.so (LoadError)
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /var/lib/gems/2.3.0/gems/ruby2d-0.4.2/lib/ruby2d.rb:19:in `<top (required)>'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
	from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
	from app.rb:1:in `<main>'

I tried updating ubuntu, uninstalling and reinstalling the gem but I always get the same error.

Change text color

User Story

As a user, I want to change the color of text I create, so that I'm not stuck with just boring white.

Tasks

  • Design the Ruby 2D API, probably should look something like:

    t = Text.new(0, 0, 20, "Hello Ruby 2D!")
    
    # change text color
    t.color = 'red'
  • Interface with Simple 2D’s text API

  • Write manual tests and RSpec tests (if possible)

Missing dependencies when trying to install on Raspbian Stretch

I recently installed Raspbian Stretch on a Raspberry Pi Zero. I was happy to see that Ruby 2.3 was already installed, however, I quickly realized that Ruby2D requires additional dependencies (in addition to Simple2D) that were not already installed. Maybe we should consider adding checks for these things in ext/ruby2d/extconf.rb:

  • Missing ruby.h header.
    • Ran sudo apt-get install ruby2.3-dev to install it.
  • Missing GLES2/gl2platform.h.
    • Ran sudo apt-get install libgles2-mesa-dev to install it.

After that, Ruby2D installed successfully.

getting started : Ruby 2D Error: `["red", "green", "blue"]` is not a valid color

The example provided in 'gettting started' section of the website does not work for me.

  • Linux Mint 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64
  • ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux] via RVM
> ruby app.rb 
Ruby 2D Error: `["red", "green", "blue"]` is not a valid color
Occurred in:
  app.rb:6:in `<main>'

/home/jcll/.rvm/gems/ruby-2.4.0/gems/ruby2d-0.2.1/lib/ruby2d/color.rb:32:in `initialize': `["red", "green", "blue"]` is not a valid color (Ruby2D::Error)
	from /home/jcll/.rvm/gems/ruby-2.4.0/gems/ruby2d-0.2.1/lib/ruby2d/triangle.rb:44:in `new'
	from /home/jcll/.rvm/gems/ruby-2.4.0/gems/ruby2d-0.2.1/lib/ruby2d/triangle.rb:44:in `update_color'
	from /home/jcll/.rvm/gems/ruby-2.4.0/gems/ruby2d-0.2.1/lib/ruby2d/triangle.rb:17:in `initialize'
	from app.rb:6:in `new'
	from app.rb:6:in `<main>'

Add OS X `.app` packaging

User Story

As an OS X developer, I want to be able to package my Ruby 2D app as a .app, so that I can distribute a more polished version of my app to users.

Notes

This was started in the CLI, but needs work.

Change text content dynamically

User Story

As a user, I want the ability to change the content of Text after it's been initialized, so that I can update the text content dynamically and not have to destroy and create another Text object.

Tasks

  • Design the Ruby 2D API, probably should look something like:

    t = Text.new(0, 0, 20, "Hello Ruby 2D!")
    
    # change the text content
    t.text = "A different message!"
  • Interface with Simple 2D’s text API

  • Write manual tests and RSpec tests (if possible)

New APIs for Renderable module

Continuing discussion on #38, what I would like to see for renderable objects is to be able to explicitly ask objects to be rendered above or below other objects.
Renderable#above(other) and Renderable#below(other) seems like a reasonable API.

I will try looking into the ruby code and try to figure out if I can do it without touching native extensions.

Are Sound Instances freed ?

I just noticed that, after precisely 33 Sound objects being played, the background Music stops.

Let me explain my case:
I wrote a simple point & click engine project with your gem.
When starting the game, the background music starts and loops. There is a clicking Sound effect when clicking a direction arrow.
However, if i click a direction arrow precisely 33 times, the background music suddenly stops. The Sound object still work like a charm though.

Any idea where that could come from?

Allow colors to be created with RGB hex values

See example RGB hex values in this article.

User Story

As a user, I want to create new Color objects using hex values, so that it's more familiar to us web developers.

Tasks

  • Figure out algorithm for converting hex values to red / green / blue Float values (added in #15)
    • Determine if we should support the three-character notation in the CSS spec
  • Extend Color class to accept hex values and convert
  • Write RSpec tests
    • One idea for a testing strategy could be changing the string names in color.rb back to their original hex values from clrs.cc, then write RSpec tests to validate the path from string, to hex, to eventual Float values.

Text#text= leaks memory

If you check this code:

require "ruby2d"

text = Text.new(0, 0, "", 40, "media/bitstream_vera/vera.ttf")

update do 
  100.times do 
    text.text = "memory leak!"
  end
end

show

You will notice that the process gains memory really, really, really fast, and never releases it.
I am fairly certain that this is the faulty line: https://github.com/ruby2d/ruby2d/blob/master/ext/ruby2d/ruby2d.c#L255
Which calls this: https://github.com/simple2d/simple2d/blob/master/src/text.c#L60

This is, however, where my journey ends, I'm not able to help any further: (

Error installing on Windows - cannot find -lSDL2main

Hi, thanks for this library!

I am having problem installing it on Windows 7 64 bit.
My Ruby environment:

ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]

Devkit is installed and working.
I installed simple2d libraries following the Getting Started guide on Ruby2d website.

But when I try to run gem install ruby2d this is what I get:

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing ruby2d:
        ERROR: Failed to build gem native extension.

    current directory: C:/dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/ext/ruby2d
C:/dev/ruby/Ruby23-x64/bin/ruby.exe -r ./siteconf20170324-1716-1angnxw.rb extconf.rb
creating Makefile

current directory: C:/dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/ext/ruby2d
make "DESTDIR=" clean

current directory: C:/dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/ext/ruby2d
make "DESTDIR="
generating ruby2d-x64-mingw32.def
compiling ruby2d.c
In file included from c:/dev/ruby/Ruby23-x64/include/ruby-2.3.0/ruby/win32.h:41:0,
                 from c:/dev/ruby/Ruby23-x64/include/ruby-2.3.0/ruby/defines.h:168,
                 from c:/dev/ruby/Ruby23-x64/include/ruby-2.3.0/ruby/ruby.h:36,
                 from c:/dev/ruby/Ruby23-x64/include/ruby-2.3.0/ruby.h:33,
                 from ruby2d.c:16:
c:\dev\ruby\ruby-devkit-64-4.7.2\mingw\bin\../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x86_64-w64-mingw32/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]
ruby2d.c: In function 'ruby2d_image_init':
ruby2d.c:159:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby2d.c: In function 'ruby2d_sprite_init':
ruby2d.c:193:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby2d.c: In function 'ruby2d_text_init':
ruby2d.c:226:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby2d.c: In function 'ruby2d_text_equals':
ruby2d.c:252:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby2d.c: In function 'ruby2d_sound_init':
ruby2d.c:288:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby2d.c: In function 'ruby2d_music_init':
ruby2d.c:337:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby2d.c: In function 'render':
ruby2d.c:500:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby2d.c:587:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby2d.c:592:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby2d.c:628:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby2d.c: In function 'ruby2d_show':
ruby2d.c:657:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby2d.c:678:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby2d.c: In function 'Init_ruby2d':
ruby2d.c:740:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby2d.c:746:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby2d.c:755:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby2d.c:764:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
ruby2d.c:785:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
linking shared-object ruby2d/ruby2d.so
c:/dev/ruby/ruby-devkit-64-4.7.2/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lSDL2main
collect2.exe: error: ld returned 1 exit status
make: *** [ruby2d.so] Error 1

make failed, exit code 2

I hope it's something that can be fixed soon! Because Ruby's world desperately needs a stable, cross-platform library for working with graphics and audio! :)
Thanks a lot!

Add mouse events

User Story

As a user, I want a DSL for mouse inputs, so that I can capture button clicks and other events.

DSL Ideas

Here are some examples of how the DSL could look:

on mouse: 'left' do
  puts "mouse left"
end

on mouse: 'right' do
  puts "mouse right"
end

on mouse: 'down' do
  puts "mouse down"
end

on mouse: 'up' do
  puts "mouse up"
end

on mouse: 'any' do
  puts "mouse any"
end

Tasks

Providing default font for text

Hey

It seems counter-productive for me to be forced to fetch font from internet and learn about font types so that I can write something. I would suggest that the system should pick a system font by default, and provide features to inquire about available system fonts, which would then be allowed to use.

I believe I can write a PR with a suggestion for such system, at least in pure ruby version. Would you be ok with me providing such suggestion?

Drawing lines?

What about drawing lines? Would be useful for some applications, like performing delaunay triangulation and voronoi diagrams for map generation : )

Segfault with Text#new when font file is missing from given path

O.S: Windows 7

ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]

require 'ruby2d'
set title: "Hello World!"
set width: 768, height: 300
t =  Text.new(15, 15, "test", 40, "fonts/arial.ttf")

# also happens with just 
# t = Text.new

show

Output:


C:\Users\xxx\Downloads>ruby ruby2d-hello.rb
C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/application.rb:44: [BUG] Segmentation fault
ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]

-- Control frame information -----------------------------------------------
c:0005 p:---- s:0014 e:000013 CFUNC  :show
c:0004 p:0009 s:0011 e:000010 METHOD C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/application.rb:44
c:0003 p:0014 s:0008 e:000007 METHOD C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/dsl.rb:33
c:0002 p:0080 s:0005 E:0011e8 EVAL   ruby2d-hello.rb:13 [FINISH]
c:0001 p:0000 s:0002 E:000800 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
ruby2d-hello.rb:13:in `<main>'
C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/dsl.rb:33:in `show'
C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/application.rb:44:in `show'
C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/application.rb:44:in `show'

-- C level backtrace information -------------------------------------------
C:\Windows\SYSTEM32\ntdll.dll(ZwWaitForSingleObject+0xa) [0x000000007721BD7A]
C:\Windows\system32\KERNELBASE.dll(WaitForSingleObjectEx+0x9c) [0x000007FEFD0310AC]
C:\Dev\ruby\Ruby23-x64\bin\x64-msvcrt-ruby230.dll(rb_vm_bugreport+0xa4) [0x000000006E6AF354]
C:\Dev\ruby\Ruby23-x64\bin\x64-msvcrt-ruby230.dll(rb_bug_context+0x68) [0x000000006E54B6B8]
C:\Dev\ruby\Ruby23-x64\bin\x64-msvcrt-ruby230.dll(rb_check_safe_obj+0x3b2) [0x000000006E61E522]
 [0x0000000000401A85]
C:\Windows\SYSTEM32\ntdll.dll(_C_specific_handler+0x9c) [0x00000000771E7958]
C:\Windows\SYSTEM32\ntdll.dll(RtlDecodePointer+0xad) [0x00000000771F812D]
C:\Windows\SYSTEM32\ntdll.dll(RtlUnwindEx+0xbbf) [0x00000000771E855F]
C:\Windows\SYSTEM32\ntdll.dll(KiUserExceptionDispatcher+0x2e) [0x000000007721BCB8]
 [0x0000000067FC23FB]
C:\Dev\ruby\Ruby23-x64\lib\ruby\gems\2.3.0\gems\ruby2d-0.3.0\lib\ruby2d\ruby2d.so(Init_ruby2d+0x2139) [0x0000000067FC53F9]
 [0x0000000067FC3124]
C:\Dev\ruby\Ruby23-x64\bin\x64-msvcrt-ruby230.dll(rb_error_arity+0x1fb) [0x000000006E697D1B]
C:\Dev\ruby\Ruby23-x64\bin\x64-msvcrt-ruby230.dll(rb_vm_invoke_proc+0x760) [0x000000006E6A4280]
C:\Dev\ruby\Ruby23-x64\bin\x64-msvcrt-ruby230.dll(rb_vm_localjump_error+0xe11) [0x000000006E69E9B1]
C:\Dev\ruby\Ruby23-x64\bin\x64-msvcrt-ruby230.dll(rb_vm_localjump_error+0x5788) [0x000000006E6A3328]
C:\Dev\ruby\Ruby23-x64\bin\x64-msvcrt-ruby230.dll(rb_check_copyable+0x2dc1) [0x000000006E5509B1]
C:\Dev\ruby\Ruby23-x64\bin\x64-msvcrt-ruby230.dll(ruby_run_node+0x51) [0x000000006E553951]
 [0x0000000000402D14]
 [0x00000000004013D7]
 [0x00000000004014F8]
C:\Windows\system32\kernel32.dll(BaseThreadInitThunk+0xd) [0x00000000770C59CD]

-- Other runtime information -----------------------------------------------

* Loaded script: ruby2d-hello.rb

* Loaded features:

    0 enumerator.so
    1 thread.rb
    2 rational.so
    3 complex.so
    4 C:/Dev/ruby/Ruby23-x64/lib/ruby/2.3.0/x64-mingw32/enc/encdb.so
    5 C:/Dev/ruby/Ruby23-x64/lib/ruby/2.3.0/x64-mingw32/enc/trans/transdb.so
    6 C:/Dev/ruby/Ruby23-x64/lib/ruby/2.3.0/x64-mingw32/enc/windows_1252.so
    7 C:/Dev/ruby/Ruby23-x64/lib/ruby/2.3.0/unicode_normalize.rb
    8 C:/Dev/ruby/Ruby23-x64/lib/ruby/2.3.0/x64-mingw32/rbconfig.rb
    9 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/compatibility.rb
   10 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/defaults.rb
   11 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/deprecate.rb
   12 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/errors.rb
   13 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/version.rb
   14 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/requirement.rb
   15 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/platform.rb
   16 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/basic_specification.rb
   17 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/stub_specification.rb
   18 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/util/list.rb
   19 C:/Dev/ruby/Ruby23-x64/lib/ruby/2.3.0/x64-mingw32/stringio.so
   20 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb
   21 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/exceptions.rb
   22 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/defaults/operating_system.rb
   23 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/dependency.rb
   24 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_gem.rb
   25 C:/Dev/ruby/Ruby23-x64/lib/ruby/2.3.0/monitor.rb
   26 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb
   27 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems.rb
   28 C:/Dev/ruby/Ruby23-x64/lib/ruby/site_ruby/2.3.0/rubygems/path_support.rb
   29 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/version.rb
   30 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/core_ext/name_error.rb
   31 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/levenshtein.rb
   32 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/jaro_winkler.rb
   33 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkable.rb
   34 C:/Dev/ruby/Ruby23-x64/lib/ruby/2.3.0/delegate.rb
   35 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
   36 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb
   37 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkers/name_error_checkers.rb
   38 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkers/method_name_checker.rb
   39 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/spell_checkers/null_checker.rb
   40 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean/formatter.rb
   41 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/did_you_mean-1.0.0/lib/did_you_mean.rb
   42 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/exceptions.rb
   43 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/color.rb
   44 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/window.rb
   45 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/application.rb
   46 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/dsl.rb
   47 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/quad.rb
   48 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/rectangle.rb
   49 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/square.rb
   50 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/triangle.rb
   51 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/image.rb
   52 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/sprite.rb
   53 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/text.rb
   54 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/sound.rb
   55 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/music.rb
   56 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d/ruby2d.so
   57 C:/Dev/ruby/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ruby2d-0.3.0/lib/ruby2d.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.

Move `type_id` variables out of ruby code

All renderable classess have @type_id variables defined, which are then used for rendering purposes inside native extensions. Those variables belong inside native extensions and should be stored there. Ideally, native extensions should have the possibility to get objects class and behave based on that.

unable to install ruby2d

I'm trying to install ruby2d and running into some issues. Here is the message I'm getting!

C:\devkit>gem install ruby2d
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions.  This could take a while...
ERROR:  Error installing ruby2d:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/ruby2d-0.4.1/ext/ruby2d
C:/Ruby24-x64/bin/ruby.exe -r ./siteconf20170919-5880-17h3jbs.rb extconf.rb
which: no simple2d in (/c/Ruby24-x64/bin:/mingw64/bin:/usr/bin:/c/ProgramData/Oracle/Java/javapath:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c/Program Files/Microsoft SQL Server/120/Tools/Binn:/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/c/Program Files/Git/cmd:/c/Program Files/nodejs:/c/Program Files/Java/jdk1.8.0_121/bin:/c/Program Files/MySQL/MySQL Utilities 1.6:/c/Program Files/MATLAB/R2017a/runtime/win64:/c/Program Files/MATLAB/R2017a/bin:/c/devkit:/c/devkit/bin:/c/devkit/mingw:/c/devkit/mingw/bin:/c/Ruby24-x64/bin:/c/Users/Clinton Jaroboe/AppData/Local/Programs/Python/Python36-32/Scripts:/c/Users/Clinton Jaroboe/AppData/Local/Programs/Python/Python36-32:/c/Ruby22-x64/bin:/c/Users/Clinton Jaroboe/AppData/Local/Microsoft/WindowsApps:/c/Users/Clinton Jaroboe/AppData/Roaming/npm)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby24-x64/bin/$(RUBY_BASE_NAME)

== Ruby 2D Installation Errors =====================================

  Ruby 2D uses a native library called Simple 2D.

  To install Simple 2D, follow the instructions in the README:
    https://github.com/simple2d/simple2d

====================================================================

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/ruby2d-0.4.1 for inspection.
Results logged to C:/Ruby24-x64/lib/ruby/gems/2.4.0/extensions/x64-mingw32/2.4.0/ruby2d-0.4.1/gem_make.out

I've had the devkit installed for ages and installed loads of other C gems. I went ahead and installed simple2d from the link provided with no issues, but I'm consistently getting this error.

I'd love to work with simple2d, I've been working with ruby since my first assignment as an intern years ago when I started my career, and I've recently transitioned into a GUI position at my company, so I'd love to combine the two. ruby2d seems like a great option from the documentation provided, but if I can't get past all these install issues I'm worried I'll never get to try it out!

Add music

User Story

As a user, I want a Music class, so that I can load and play longer audio samples, like for background music.

Tasks

Design Sprite class and interface

An initial implementation has been created for Sprite, but the interface hasn't really been "designed," and certainly not yet finalized. In this issue, we can discuss what an ideal sprite DSL might look like and how to implement it. Ideas welcome!

CLI Discussion

CLI 2.0 discussion

Some time ago I suggested to reorganise the CLI code and organise it around an external, battle-tested tool for CLI management. As an example I suggested Thor.

I would like to start that discussion by stating that the work done to make the compilation pipeline is a wonderful piece of plumbing, and I don't want to interfere with this code, at least not without a good reason. What I'm suggesting is, merely, to move that code around and organise it in such way, that it is more easily understandable and extendable.

Now to the code itself: What is there now?

Current CLI management tool is all packed in one file, /bin/ruby2d. It includes core extensions, code used for actual building and code responsible for CLI interaction. In this state:

  1. "--debug" option doesn't work, when compiling. Parsing and understanding params passed to CLI command is actually a nontrivial task. This is where using a dedicated tool would be helpful.

  2. It is hard to reuse the compilation pipeline for other files. By hard, here, I mean: I'm not sure how to do it.

I have many ideas about how to expand and improve the compilation process and it's output, but for it to be possible, it would be very helpful to divide the code responsible from the compilation itself, and the CLI code.

Also, I would like to do some research on issues like: running the test code for all platforms, or running a compatibility tests, or performance comparisons for all platforms. For this reason, we must be able to easily specify new rake tasks like:

  • rake test, extended version, that would compile the code in all available platforms, and combine the result in one visual representation.
  • rake compatibility that would do the same as above, but for another set of tests.
  • rake performance, same as above.

And all of that would use the same compilation pipeline, just with different input file, and output directory.

Feature suggestion: Renderable#contains?

In multiple places in my game I am interested in knowing if mouse is being positioned over a specific rendered object. This is useful, for example, for features like pressing buttons.

This feature seems to me like something that would useful for other people if upstreamed to ruby2d. Would you be willing to have this feature upstreamed? I can implement #contains? for all renderable objects. Logic would simply be like this:

object.contains?(x, y)

And it would return true if that x, y coordinate point is inside given renderable.

What do you think?

Add classical style

User Story

As a user, I want to use classes instead of the DSL, so that I can modularize my app and reduce potential conflicts.

Notes

This would be similar to Sinatra’s “modular” style.. The user would probably require ruby2d/base, and then have access to the base classes (see example of this in application.rb).

Tasks

  • Implement require ruby2d/base
  • Write tests and documentation

Implementation of File.exists?

Hey

First of all, spectacular work! This is exactly what I needed to revive my pet project: ).

Now to the business: I noticed none of the files that take a path to asset are checking for the existence of that path, and I also noticed that you want them to do so, but the problem is mruby missing File class.

I found this: https://github.com/iij/mruby-io to implement the File class, and it also seems that MRuby has it's own gems environment, which is setup in that build_config.rb file. Those gems seem to have a lot of things that would be useful. Could you please share if you have any plans on integrating with it? Currently those methods throw segfaults. I'm also glad to provide some PRs if you point me to a good direction and they don't involve hacking c code: )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.