|
"Using the Coconut library " |
Index
Français / English The Coconut Project |
I/ the C++ Coconut libraryThe library is used to modelize and manipulate the world using few C++ classes.It defines ::
=> A file descripting each object, ressource...: the Coconut.dat file. => Some rules explaining how to handle the clicks and drag'n drop on objects, using few functions : C_init, C_onSceneIn, C_onClick, C_onDragNDrop, C_onQuit... the library may be use to develop multi-players, multi-platforms game using a network interface.
II/ The Coconut.dat description fileThis file lists the names and properties of the scenes, objects, and resources.The first step is the scenes definition: A scene is composed by :
[Scenes] NbScenes=2 [Scene1]
[Scene2]
An object is located in a scene. It can be drawn using a graphical resource. It can be clicked and so start an action. It can be asked to move to a designated point of the scene in a fixed time. It may be asked to speak and draw a text. It may be asked to change the active scene. eg:
[Objet1]
# A charactere: the sorcerer
[Objet2]
# A box defining a part of the walking zone
The resource type can be Animation, Sound, or Text. The resources are a link to some externals files such as pictures, wav, CD, and permit to dial with many langages. eg:
[Ressource1]
[Ressource2]
[Ressource3]
Writting a description file by hand is easy, but it's easier to use the dedicated graphical editor. III/ Behavior rulesSome C functions explain how to manage the clicks and drag'n drop on the objects.
#define C_Objet_O_pt_feu_droit "O_pt_feu_droit" #define C_Objet_O_pt_hotel_gauche "O_pt_hotel_gauche" #define C_Objet_O_pt_hotel_porte "O_pt_hotel_porte" #define C_Objet_O_pt_hotel_droit "O_pt_hotel_droit" #define C_Res_RT_D_barman_2
"RT_D_barman_2"
void C_onClick(TE_ObjectId i_Objet) { TC_Object *l_obj; l_obj = O_getObjetById(i_Objet)); // I want to gi into the house if (l_obj->isName(C_Objet_O_village_vers_PC)) { O_getObjetPtr(C_Objet_O_sorcier)->AffText(C_Res_RT_village_dont_enter, M_dialogue_tempo_aff, T_TRUE); } Here, you just have to compile an executable, using this C file, the
coco_res.h file, and the Coconut library files.
IV/ The final step: Generation of the Coconut resource fileThe tool coconut_utils allow you to generate a big Coconut resources file "coconut.cre" containing all your external resources files (*.bmp, *.wav...).You just have to give this Coconut resource file and the executable. Of course, you'll probably need to give the SDL.dll or .rpm too. That's all !!! |