To add some sprites to the program one needs to: (most of the things here must be done in the sprite.cpp file if not stated otherwise)
- -first of all, your figures for the sprite should have some order. It does not matter if some action was not used, a blank space could be placed in the algorithm, but the actions should meet the following order of actions, with any amount of figures:
walk, stay stopped, die, eat, run
- -write the total number of actions wich this sprite should have in the number_action[] variable, define near the other static variables.
- -incremmenting the number of characters available by increasing the number defined in the CHARACTER variable at the top of the sprite.h file.
- -add some number to the variable framesperaction[j][i], putting the j equal to the defined CHARACTER number of this sprite and the i equal to the maximum number of actions. For each action should be stored the number where the animation of this action ends. For example, if your walk end in the frame 30, and begins on 0, you should store 30 in the respective action.
- -the images should be put on the /tmp/sprites file, within a directory with his respective number of CHARACTER and within another directory with a respective number of action. Example: /tmp/sprites/3/0/ for a CHARACTER = 3 and an number of actions = 0 (use this value).
- -inside the /tmp/sprites/CHARACTER/action/ should be 8 directories: n, ns, ne, w, n, s, se and sw. These directories means the directions in wich the sprite is doing his/her action. The figures should be encoded in bmp and the numbers should be initialized with 00, then the first should be named: 0001.bmp. Note: the frames should beginwith 0001.bmp and the end you have already stored in the framesperaction variable.
- -give a close look to the the function changethis(), some things must be decided there. This function is responsible for the major changes in the sprite during his live.
- -add a new case in the switch part inside the setplace() function. This should be the posmap variable, the one responsible for the place where the sprite stay and this lead to collision detection.
- -in the function changethis() should be inserted in the first switch() a case for the respective new character and inside of it should be included a switch() for each action it could execute. Tbese are the rules to be applied to the character when it is continually executing the same action.
- -also in the function changethis() in the second switch() should be inserted a case for the respective character and inside of it should be the rules to be executed when the actions change.
- -insert the speed of the character inside the initspeed().
- -insert what the animal eat inside the initeathabit(). The number assigned to the eathabit means: 0 if the animal is herbivore, 1 if the animal is carnivore, 2 if the animal is omnivore and -1 if it lives from another kind of food or simply not live.
- -insert the power of the character inside the initpower(). A dog has power 8, a rat 1, a man without tools 3. This measures how much your character could damage in relation to the others characters.
- -insert the regeneration of the character inside the initregeneration(). A normal regeneration speed is 3, but you could change to give it some salamander powers :) .
- -insert the kind of flesh of the character in the initflesh() function. 0 means no flesh at all, 1 means plant and 2 means animal flesh.
- -try some copy and paste, if it does not solve it will certainly give some help.