Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

DragonRuby Game Toolkit

An intuitive 2D game engine. Fast, cross-platform, tiny, hot loaded. 路 By DragonRuby

Object Oriented Dragon Demo

A topic by kniknoo created Jul 14, 2019 Views: 936 Replies: 20
Viewing posts 1 to 11

Hello. I'm Nick.

Amir graciously gifted me a copy of DragonRuby a few weeks ago, and after the new version came out yesterday I decided it was time to dig in.

I don't really understand the programming style in the tutorials, so I decided to piece together what I could from some of the samples to make a more Ruby-like tutorial. I wanted to show off a few Ruby features, and I documented the code with the assumption that it's an introduction to some Ruby concepts.

https://github.com/kniknoo/oo_dragon_demo

This demo just shows off the dragon with U/D/L/R control, including vflip, as well as defining and extending an object class. The Castle came from a stock image provider.

Hope y'all find this helpful, and I can't wait to see other people's projects!

Thanks for the demo. I noticed it only works with this latest version. I tried it with the previous version and it error'd out.

Oh, yeah. I was reading the release notes today and incorporated a few things like shorter namespace. You'll need the most recent release.

Developer

GTK tries to provide a really small/simple, render and collision api; leaving it up to the dev to decide how to wrap the array primitives with OO (or whatever paradigm they choose). The source code in your GH repo looks straight forward 馃憤

Thank you, I'm going to look at 02_collision* and see how I can implement that today with the dragon (do they have a name?). I'll increasingly use the API and helper methods as I  understand them, but right now the examples come with very little context for "args". Could you produce a very basic map for it that I could explore the endpoints for a better understanding? My attempts to inspect my way through it yield nothing.

I have a few points of feedback after yesterday about making sure the console is a Ruby experience. I will list most in a later thread after I delve in deeper, but before anything else... can you PLEASE make "exit" an alias for "quit"? I literally just found out after 5 years that "quit" even works in IRB, but "exit" is the ruby command assumed to leave to the console/desktop. Most of my feedback is nitpicky language stuff like that that is critical to the intuitive and linguistic aspect of Ruby. The other thing is I NEED to be able to use the left key to go back and fix a mistake, even the Beginner Ruby Tutorial sample was frustrating without that. The actual DR experience itself is great now that I'm wrapping my head around it. I love the console idea and can't wait to see it grow!

Developer(+1)

There are ctag files that show the api for DragonRuby in the root directory. That should give you at least autocompletion in the editor of your choice.

Oh, and where do I need to put my own files to require? My script is gonna get real cluttered if I don't break it up.

Developer(+1)

`require` works, just use it like you would anywhere else. Take a look at the Basic Gorillas sample app for information on how to require.

Thank you, I never would have guessed it was a GTK method. :D

for others who missed it:
$gtk.require "<path from dragon_root and filename>.rb"

Could the extension name change to optional in the require? It looks very strange to have a filename extension.

Developer

Eventually those require features will be there. But we are doing some research on auto resolution (so you don鈥檛 have to put any require statements at all). 

(1 edit) (+1)

IMHO, standardizing a /lib (or similar) and having it auto-require "/lib/*/*.rb" would make for the simplest interface.

For reusable libraries,

"../lib/"

with a

set :require_all_libs true

or manually calling the library name. Assume we copy/paste or otherwise import ../libs into /libs via a command when it's time to package.

Are all primitives of the same class on the same z as implied by the console message? I'm trying to use a solid as a background for text boxes but it's rendering behind my sprites even though it's the last step in my main tick.

Developer (3 edits) (+1)

The render order is always solids, sprites, labels, lines, borders. If you want full control over the draw order use `primitives << ` which respects last in/last out and accepts all primitive types. The Flappy Dragon sample app leverages this.

Looks like my BGM .ogg is looping at 120 seconds, is that expected? Most of my game soundtrack material is 4-5 minutes.

Developer(+1)

This is a bug that will be fixed in the next release.

Am I missing a command to quit within a script?

Also, check out what I did with the inflection in my tick. I couldn't wrap my head around the word args because it's nouns all the way down, but when I think of it as "as" the whole thing flows in my head. https://github.com/kniknoo/oo_dragon_demo/blob/master/app/main.rb

Please let that always be a modifiable term...

I am using Int#frame_index with a starting values other than 0, but it is still counting from 0. I tested this in def tick proper to verify.

Developer

Sample app?

I just updated my OP so you can see what I'm looking at. Take a look at https://github.com/kniknoo/oo_dragon_demo/blob/master/lib/sprite.rb , line 34 will point you to the workaround above and the default behavior below.

I found "key_held" in the events by reading dueling ships, I like the way that "up, down, left, right" are assumed to be key_held when called without a prefix. Could this happen for the letter keys too as a shorthand?

Developer(+1)

It's on the list to add yes!