Need advice: Code reuse of Wesnoth's hex display engine.

Discuss the development of other free/open-source games, as well as other games in general.

Moderator: Forum Moderators

Post Reply
Pentalis
Posts: 10
Joined: June 24th, 2005, 4:10 am
Location: Chile
Contact:

Need advice: Code reuse of Wesnoth's hex display engine.

Post by Pentalis »

Summary:

I tried to search for the source code of the classes responsible for rendering the hex grid of Wesnoth to the screen, of assigning priorities to terrain and sprites during rendering, and animating the sprites. However, after a search in the SVN tree I couldn't really find anything resembling an "hex grid renderer".
So, to get on track, I'd really appreciate if I could get advice on:
1.- Is the source located in a specific place or spread out in different modules?.
2.- If you know how Wesnoth's GUI engine works, do you think it's worth reusing the code for another game, or rather start from scratch?, in your opinion.
3.- Is there any design document I missed that explains in detail where everything is located?.


Long post:

I've been hanging around in Wesnoth's Freenode channel looking for a developer to directly ask about this. But since I couldn't find anyone, I'm doing the forums.

Wesnoth has an engine for displaying hexagons on the screen and complete support for animations, terrain and sprites based on .PNG images. I'd like to reuse those features to serve as a basis for another turn based strategy game, however, I'm not sure if it's really worth the effort to try to reuse the code, or if it I better write my own implementation from scratch (I hate reinventing the wheel).

I tried to search for the source of the engine in the Wesnoth SVN tree but in a twenty minute search I couldn't really find anything resembling an "hex grid renderer".
So, to get on track, I'd really appreciate if I could get advice on:
1.- Is the source located in a specific place or spread out in different modules?.
2.- If you know how Wesnoth's GUI engine works, do you think it's worth reusing the code or rather starting from scratch, in your opinion?.
3.- Is there any design document I missed that explains in detail where everything is located?.

I want to use Qt to make the GUI. I know Wesnoth has his own classes for graphical widgets (those I did actually find) and that it uses SDL, but that shouldn't prevent the hex/tile rendering code from being useful, or would it?.


Extra information that's slightly irrelevant and meant only for the curious (how's that for a long title?):

I'm designing the game such that it is clearly divided in a Back End and a Front End. The Back End is the game itself. The Front End renders the goodies on the screen.
Since both parts are separate, I can make a crummy front end just to test the game with a GUI. But I'd rather instead have a pretty GUI that's mostly copied (both the art and the hex engine) and then develop something more unique. Hence the post in this forum.


Thank you very much for your time.
User avatar
Eleazar
Retired Terrain Art Director
Posts: 2481
Joined: July 16th, 2004, 1:47 am
Location: US Midwest
Contact:

Re: Need advice: Code reuse of Wesnoth's hex display engine.

Post by Eleazar »

Pentalis wrote:2.- If you know how Wesnoth's GUI engine works, do you think it's worth reusing the code for another game, or rather start from scratch?, in your opinion.
It all depends on how similar what Wesnoth's GUI does is to what your game needs to do. Nobody can recommend a means if they don't know what you want to accomplishl.
Depending on your goal it might even more efficient to create your game as a conversion or addon for Wesnoth, which in many ways is highly mod-able.
Feel free to PM me if you start a new terrain oriented thread. It's easy for me to miss them among all the other art threads.
-> What i might be working on
Attempting Lucidity
Pentalis
Posts: 10
Joined: June 24th, 2005, 4:10 am
Location: Chile
Contact:

Re: Need advice: Code reuse of Wesnoth's hex display engine.

Post by Pentalis »

Eleazar wrote:
Pentalis wrote:2.- If you know how Wesnoth's GUI engine works, do you think it's worth reusing the code for another game, or rather start from scratch?, in your opinion.
It all depends on how similar what Wesnoth's GUI does is to what your game needs to do. Nobody can recommend a means if they don't know what you want to accomplishl.
Depending on your goal it might even more efficient to create your game as a conversion or addon for Wesnoth, which in many ways is highly mod-able.
It's a turn based strategy game but definitely not in the lines of Wesnoth. More in the lines of Civilization or Age of Wonders, a game where you build an empire and each hex tile represents a large extension of terrain, there's military units and several types of resources.
Wesnoth's mechanics are completely different, which is why I was mostly interested on the hex engine (if it can be separated from the inherent game's mechanics). Also the rest of the Wesnoth GUI is unimportant for that goal too (specially since both types of game differ so substantially).
lmelior
Posts: 116
Joined: June 16th, 2009, 3:30 am

Re: Need advice: Code reuse of Wesnoth's hex display engine.

Post by lmelior »

Wesnoth code is scary.

I'm not one of the developers, but my opinion is that it'd be faster to roll your own. That might depend on your skill level though. If you try to use the code as-is, you'll end up pulling in a whole lot of dependencies (and thus functionality) that you probably don't need or want. But if you're far more skilled than me, you may be able to chop up the map* and terrain* source files and extract what you want without pulling in the Wesnoth-specific stuff like the config class, logging, exceptions, and various utilities, or other dependencies like Boost and gettext.
Post Reply