Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / Map Drawing Issues
- - By kyonides Date 2010-08-08 00:42
Ever since I started trying to dev a game in Gosu (Ruby) I noticed that the Cptn Ruby map script would only work in scrolling games. The thing is it isn't suitable for RPG's (like the one I didn't touch for months now). So I wonder if someone could show me a better way to draw maps on screen and handle all of its map files.
Parent - - By erisdiscord Date 2010-08-08 05:03 Edited 2010-08-08 05:05
What exactly is the problem you're having with the map drawing code? Is it too slow with large maps? That problem can be solved by only drawing the tiles that would be visible onscreen.

I wrote a tile map class that loads and draws TMX maps (created by Tiled), which has the advantage that there is already a map editor that you and I don't have to write ourselves. The format is a little bloated though since it uses XML and is pretty generalised overall. It's nice, though, because you can have as many layers as you want and you can attach arbitrary properties to the map and the objects in it.

My library also supports Chingu directly if you use it, and lets you hook into the loader in a few places to integrate it with your own system if you don't. Collision detection is up to you because one size doesn't fit all, but for a console RPG it should be fairly trivial. You'll need Nokogiri to use it as is, but if you're feeling adventurous, Ruby comes with a significantly less awesome but fairly straightforward XML library of its own.

I'm afraid gosu-tmx is a little undocumented, although the example should give you the gist of how it's used—don't be afraid to ask if you can't figure it out.

You can find my TMX library on GitHub at erisdiscord/gosu-tmx and Tiled is available from its own web site.

Oh, and right now the drawing code is set up for pre-transform Gosu, but I intend to update it to use transformations for scrolling in the future. Anybody is welcome to submit a patch to help me along if they'd like. :D
Parent - - By kyonides Date 2010-08-08 18:09
Well, I downloaded Tiled and since I'm using a Kubuntu distro, the Qt framework is already part of it and didn't need to do anything but installing Tiled itself. The problem was it didn't let me choose an option from an submenu or a tile from the Tileset section... Take a look at the screenshot.
Parent - - By erisdiscord Date 2010-08-08 18:19
Oh dear, I hadn't counted on problems with Tiled itself. It looks like you might have a bad graphics card or bad drivers, but I'm afraid troubleshooting graphics problems on Linux isn't my specialty. I had a problem like this with my Mac for a while where new windows would sometimes come up with scrambled graphics when the GPU was too hot and then the system would deadlock, but it was fixed with a firmware update later on.

My first suggestion is to try rebooting and hope for the best. If you're using a notebook, you could try propping it up on something solid to get as much clearance around the vents as possible. Double check that you've got the latest drivers too.

Other than that, I'm not sure what to do. :(
Parent - By kyonides Date 2010-08-08 19:41
I thought about it for a minute but it doesn't make sense, any other Qt (I'm using 4.6.2) or KDE app window is displayed correctly on my screen. Tiled is the only one that doesn't...

I even tried to make my app with a Qt GUI and all and it never showed me such flaws...

AFAIK it should be something with the deb file distributed for *Ubuntu OS's.
Parent - - By kyonides Date 2010-08-11 02:56
Well, after reading the source code I found out that I needed to include some command argument namely -graphicssystem native to disable the OpenGL rendering and force Qt to do the job on her own. On Kubuntu that seems to be slower but not in sidux - kde. The good thing is I'm now able to use it in both boxes!
Parent - - By erisdiscord Date 2010-08-11 03:57
That's good news, but I do wonder why OpenGL rendering was giving you trouble. Do you have problems with any other OpenGL applications?
Parent - By kyonides Date 2010-08-11 05:16
Mmm sometimes, Gosu is one of them, I can't start playing with my mouse and the current position of the Gosu project window because it makes the PC freeze he he he.
Parent - - By kyonides Date 2010-08-13 23:13
I wonder if you could tell me a bit about how to use Nokogiri. I know there's a reader and a parser but IDK when I should either use the former or the latter...
Parent - - By erisdiscord Date 2010-08-15 04:35
Oh, you shouldn't have to interact with Nokogiri directly for this—it just needs to be installed because gosu-tmx uses it. That said, the Nokogiri web site has a pretty extensive API documentation and links to pretty much any other information you might need.
Parent - - By kyonides Date 2010-08-15 06:15
OK, thanks for the advice, but isn't there a way to install it just like we do with any other rubygem? I could only find a source code download, which isn't bad at all but I'd prefer not to manually install it all by myself...
Parent - - By jlnr (dev) Date 2010-08-15 08:37

Cappuccina:~ jlnr$ sudo gem install nokogiri
Building native extensions.  This could take a while...
Successfully installed nokogiri-
1 gem installed
Cappuccina:~ jlnr$

Parent - By Basic Date 2010-08-15 15:25
Parent - - By kyonides Date 2010-08-15 23:43 Edited 2010-08-15 23:48
I was talking about gosu-tmx not Nokogiri, which I already installed on my PC... Please read more carefully :)

:~$ sudo gem1.9.1 i gosu-tmx
[sudo] password for user:
ERROR:  could not find gem gosu-tmx locally or in a repository
Parent - - By erisdiscord Date 2010-08-16 18:01
Aha, I read it the same way Julian did, sorry!

Mostly it's just laziness on my part. I haven't bothered to learn how to distribute gems yet—I suppose I should get on that soon. :) The good news is that there's no C extension to compile so dropping the source code into your project should work.
Parent - By kyonides Date 2010-08-17 03:36
Alright, then I guess I'll give it a shot unless it lacks of proper documentation...
Up Topic Gosu / Gosu Exchange / Map Drawing Issues

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill