Init commit

This commit is contained in:
derek holloway
2026-03-09 18:56:08 -07:00
commit 190204b3b6
4 changed files with 62 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
#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;
}