"Coconut Project"
"Using the Coconut library "
Index
Français / English


The Coconut Project 

Using the Coconut Library

The "Welcome in the Coconut Island" scenario

Download

About Glade
 

Contact

I/ the C++ Coconut library

The library is used to modelize and manipulate the world using few C++ classes.
It defines ::
  • characteres
  • mouse cursors
  • found objects inventory
  • scenes
  • objects
  • graphic, sound and texts resources
This libray is completed with:
=> 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.


Software Architecture of Coconut Project
 

II/ The Coconut.dat description file

This file lists the names and properties of the scenes, objects, and resources.

a/ The scenes

The first step is the scenes definition:
A scene is composed by :
  • objects, which will be drawn, animated, on which you can click and drag'n drop.
  • a walking zone where characters are authorized to walk.
eg:
[Scenes]
NbScenes=2

[Scene1]
Name=SceneId_Intro
ScalePerso=1.000

[Scene2]
Name=SceneId_Panneau
ScalePerso=1.250

b/ The objects

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:
[Objets]
NbObjets=205

[Objet1]                    # A charactere: the sorcerer
Name=O_sorcier
AffName=
ResAnimName=R_Sorcier
ptCoord.x=146
ptCoord.y=184
ptSize.x=0
ptSize.y=0
ptHotSpot.x=0
ptHotSpot.y=0
ptText.x=61
ptText.y=7
SceneName=SceneId_Village
SceneSuivanteName=
SceneSuivantePoint=
isClickable=1
isAfficher=1
isZoneDep=0
isDragAndDrop=0

[Objet2]                        # A box defining a part of the walking zone
Name=O_dep_village
AffName=
ResAnimName=
ptCoord.x=4
ptCoord.y=258
ptSize.x=630
ptSize.y=217
ptHotSpot.x=0
ptHotSpot.y=0
ptText.x=0
ptText.y=-20
SceneName=SceneId_Village
SceneSuivanteName=
SceneSuivantePoint=
isClickable=0
isAfficher=0
isZoneDep=1
isDragAndDrop=0

c/ The resources

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:
[Ressources]
NbRessources=3

[Ressource1]
Name=RS_D_texan_6_2
type=Wav
filePath=res\wav\dialogues\texan\S_6_2.wav

[Ressource2]
Name=RT_D_biond_parachute_18_2
type=Text
textBuf=Je veux plus.
textBufEng=I want more

[Ressource3]
Name=R_peone_marche
type=Anim
filePath0=res\img\scenes\hotel\peone_marche_1.bmp
tempo0=200
filePath1=res\img\scenes\hotel\peone_marche_2.bmp
tempo1=200
filePath2=res\img\scenes\hotel\peone_marche_3.bmp
tempo2=200
nbAnim=3
 

d/ The Editor

 

Writting a description file by hand is easy, but it's easier to use the dedicated graphical editor.
 
 

III/ Behavior rules

Some C functions explain how to manage the clicks and drag'n drop on the objects.
 
  • The util coconut_utils permit to generate a file "coco_res.h" with some C Id to manipulate the objects.
eg:
#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"
#define C_Res_RT_D_barman_3                  "RT_D_barman_3"
#define C_Res_RT_D_barman_4                  "RT_D_barman_4"
#define C_Res_RT_D_barman_1_1                "RT_D_barman_1_1"
 

  • One write a C file implementing the functions: C_init, C_onClick, C_onDragNDrop, C_onQuit.
ex:
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.
Take a look at S_dummy_scenario.c
 

IV/ The final step: Generation of the Coconut resource file

The 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 !!!