Suggestion about grid engine

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

Moderator: Forum Moderators

Post Reply
User avatar
Herduk
Posts: 97
Joined: August 18th, 2005, 9:19 am
Location: Bergamo - Italy

Suggestion about grid engine

Post by Herduk »

Hi all.
I'm a developer, mainly on ERP field, but in next months i need to learn (my boss "asked" me :roll: to do ) C# and .NET technologies.
So, to avoid to bore myself, i would like to study this technology in my way.
I would like to develop a little project I got in mind but to do so, i need a grid engine (like Wesnoth's hex-grid ).
I'm not looking for an hex grid, I would like to start step-by-step, so even a square grid could work.

What i'm looking for is something that i can read/look at to learn how to use them. :eng:
Don't bother a dwarf.. you can argue with his hammer!
User avatar
Cloud
Art Contributor
Posts: 502
Joined: December 17th, 2008, 7:43 pm
Location: The land of pixels
Contact:

Re: Suggestion about grid engine

Post by Cloud »

I'd assume the concept is pretty similar in any language*, I've tried out a little C#, but I can't say I got particularly far with it, but all the basic syntax was pretty standard, so if you're used to any sort of programming then you can probably work something out. If you're looking at C#, the XNA libraries might be useful to you, they do have some pretty nice video tutorials for you to work with. I'm sure there are plenty of internet tutorials around for both languages too. Really though practice makes perfect.

Hope that helps.

*Object Orientation seems pretty standard in a lot of languages now, although with rather different syntax.
Softly/SoftlySplinter on IRC. Will be lurking around more these days
Mainline Animations|The Væringjar
Art for these mead-sodden, bearded mushroom-junkies by Girgistian!
Yoyobuae
Posts: 408
Joined: July 24th, 2009, 8:38 pm

Re: Suggestion about grid engine

Post by Yoyobuae »

How about starting with loading one PNG and displaying it inside a window. Then displaying several images at different locations. Probably create a function/object that allow to take any one image and draw it anywhere on the windows. With this you can use Wesnoth's own terrain/units/etc in your program.

Then you'll probably want a way to represent the hex grid. Wesnoth uses 2 coordinates to address each hex (as it can easily be seen with the in-game coordinates). Or any use other system you wanna use.

Create some way to map this coordinates to actual X/Y coordinates in the target window area. Then use that to draw various terrain PNGs tiled correctly. Might even go as far as displaying some units on top.

Well at least that's how I would go about it.
Alink
Inactive Developer
Posts: 181
Joined: March 5th, 2007, 6:45 am
Location: Belgium

Re: Suggestion about grid engine

Post by Alink »

- The google word is "tile based (games)".
- Don't start with hex grid, it's much more complicated than square grid
- Encapsulate well everything related to your map and tile. The game should only use function like on_map(x,y), tile_at(x,y) or entity_at(x,y), etc.. This will allow to improve your grid code, without changing the gameplay code. For example the terrain map and unit map of wesnoth are now some monster of complexity, but most of the game still call its functions like when it was a simply coded grid. And yeah, grid always evolve (examples of new needs for wesnoth: border, negative coordinates, more layers, optimization, etc..)
[edit:] in fact even (x,y) should be encapsulated into a "location" object
User avatar
Herduk
Posts: 97
Joined: August 18th, 2005, 9:19 am
Location: Bergamo - Italy

Re: Suggestion about grid engine

Post by Herduk »

Thank you all.
You give me some nice hints :)
Don't bother a dwarf.. you can argue with his hammer!
Post Reply