OO coding, graphics and wesnoth
Moderator: Forum Moderators
OO coding, graphics and wesnoth
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"
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"
Angband, the ultimate FPS game!
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.
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.
First read, then think. Read again, think again. And then post!
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...
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