The DSIM Project







Home

What is DSIM ?

Screenshots

Download

Developpement

Contact






















Hosted by:
SourceForge
Logo




The AI motor

5) The main loop:
After all these beautifull things, we enter in the main loop.
5.1) your actions:
At first, you can decide to do something (move, get statistics,...), here comes: tour_player(map)

We begin by checking if you are pregnant.
(this is only possible if you are using the active mode.)
In this case, your "gestation" value decreases.
If it's time for you to have your children,
- pnj_tab[0]->sexe=1 :you are no more pregnant.
- nombre_pnj++ :there's a new player.
- pnj_tab = (struct _perso **) realloc(pnj_tab,nombre_pnj*sizeof(struct _perso*)) :some place for him. - pnj_tab[nombre_pnj-1] = gener_pnj(map,pnj_tab[0]) :the new entity is define by the function gener_pnj.(see that later)

After all these adventures, you may want to move on the grid.
We'll study one example here: you want to go to the north. Here's the code:
- clear_pos(pnj_tab[0]->id) :you're moving, so you're not on the cell.
- pnj_tab[0]->position = pnj_tab[0]->position->fh :you follow the pointer and go to the north.
- add_pos(pnj_tab[0]->id) :you're on the new cell, the cell is informed.
Ase you can see, moving somebody on the grid is really easy, and fast, even if you are in the middle of 25000 cells...
- Previous - Next -





Copyright Dsim 2000/2001