34 lines
776 B
C
34 lines
776 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <assert.h>
|
|
#include "class.h"
|
|
|
|
void moveHuman(Humanoid_t* self, int Horizontal, int Vertical){
|
|
printf("My name is : %s", self->name);
|
|
}
|
|
|
|
void lookHuman(Humanoid_t* self, int Horizontal, int Vertical){
|
|
|
|
}
|
|
|
|
void removeHuman(Humanoid_t* self){
|
|
if (self != NULL){
|
|
// Free malloced internals first
|
|
free(self);
|
|
}
|
|
}
|
|
|
|
Humanoid_t* InitHuman(char* PlayerName){
|
|
|
|
assert(strlen(PlayerName) < MaxNameLength && "Name is too long!");
|
|
|
|
Humanoid_t* human = malloc(sizeof(Humanoid_t));
|
|
human->health = StartingHelath;
|
|
strncpy(human->name, PlayerName, MaxNameLength - 1);
|
|
human->move = moveHuman;
|
|
human->look = lookHuman;
|
|
human->remove = removeHuman;
|
|
|
|
return human;
|
|
} |