Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Playing with DragonRuby Game Toolkit (DRGTK)
Cristian Molina
Cristian Molina

Posted on

     

Playing with DragonRuby Game Toolkit (DRGTK)

Last week I was working on a very simple game to testDragonRuby Game Toolkit and learn its API.

This Ruby implementation is based onmruby andLLVM and it’s commercial software but cheap.

The game toolkit has a simple API to handle sprites with animations, sound/music, inputs, basic drawing primitives like lines or rectangles, allows for HTTP requests and other niceties. It also has a fixed resolution and 60 times a second game loop.

The engine has a game loop that calls to a#tick method where you draw, check inputs and update game logic.

The code is structured in a couple of classes, the main one is the MyGame, that contains other classes like the Player, the list of FloorFires and the Coin to collect.

When it detects a collision it plays a sound. The game is paused when the window loses focus.

For collision detection, it uses some builtin rectangle intersection primitives.

For Input handling, the keyboard, arrows/WASD are handled the same.

And that’s pretty much it. There are a lot to improve the game but I think I’ll start a new project with a better idea to start doing something funnier and more polished.

Besidesthe official docs, I learnt a lot fromthis post series, kudos to Justin!, and also theofficial discord is super friendly and helpful when you get stuck on something.

The start screen:

start screen

In-game:

in-game animation

The source is about 360 lines and availableon GitHub. The assets are free.

You can download or play it onlinehere at Itch.io (DRGTK includes a great tool to deploy to Itch.io)

Happy hacking!

Top comments(3)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
megatux profile image
Cristian Molina
Programmer
  • Location
    San Luis, Argentina
  • Education
    some
  • Work
    Developer
  • Joined

v0.7 has better coin placement

CollapseExpand
 
megatux profile image
Cristian Molina
Programmer
  • Location
    San Luis, Argentina
  • Education
    some
  • Work
    Developer
  • Joined

Added joystick support in v0.6!

CollapseExpand
 
megatux profile image
Cristian Molina
Programmer
  • Location
    San Luis, Argentina
  • Education
    some
  • Work
    Developer
  • Joined

v0.8 adds saving hiscore to a file and restore it so it persist between different game process runs

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Programmer
  • Location
    San Luis, Argentina
  • Education
    some
  • Work
    Developer
  • Joined

More fromCristian Molina

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp