OO coding, graphics and wesnoth

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Post Reply
gandalf
Posts: 157
Joined: August 24th, 2003, 4:15 pm
Location: Sweden

OO coding, graphics and wesnoth

Post by gandalf »

Hi.
I wish to understand the wesnoth code and how it is designed, but it's quite large (and the number of comments are not large) so Ithought that someone here might be able to tell me something about it.

Here are a few of my questions.

How are the graphics handled? I wonder how you keep a large map with all units etc, in the memory and still get the game to scroll so smothly? Do you keep a large image and just display a part of it, or do draw everything from scratch when scrolling, i.e. finding out what new parts are visible and then draw them?

How do you let the AI find out about the enemy? I assume all units are objects, will this not mean a lot of overhead when getting/setting health values etc.? How do you store all the units to be able to find them quickly? Some tasks could be to find the unit that is positioned on a specific position, and find all units that are positioned near a unit. How is this done?

Concerning the lack of comments and documentation about the code, is this because "the code is selfevident" or because writing comments is so very boring (yes it is!) ?

I'd love to find a book: "algorithms and design of games like wesnoth in C++ with SDL" :D
Angband, the ultimate FPS game!
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

I don´t know it for sure, but I think it´s one image for the landshape and the unit images are
placed on it.

And I think this because the WML has a [redraw] tag wich is sometimes necesssary.

Ask Dave if you want exact informations. :wink:
First read, then think. Read again, think again. And then post!
Boucman
Inactive Developer
Posts: 2119
Joined: March 31st, 2004, 1:04 pm

Post by Boucman »

scrolling is a bit particular because it needs a whole redraw... I think it's directly in SDL... look in display.cpp

for most common task, we have a hex granularity. that is, the code tels "next time you redraw, remember to redraw this particular hex" so we try to avoid redrawing the screen as much as possible

yes, each unit is an object, and these objects are stored in an array, we use the STL find function to get them usually...
Fight key loggers: write some perl using vim
Post Reply