commit 190204b3b6d8e17ca0905ecfadb96882538fe7b7 Author: derek holloway Date: Mon Mar 9 18:56:08 2026 -0700 Init commit diff --git a/class.c b/class.c new file mode 100644 index 0000000..6b1a69d --- /dev/null +++ b/class.c @@ -0,0 +1,34 @@ +#include +#include +#include +#include +#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; +} \ No newline at end of file diff --git a/class.h b/class.h new file mode 100644 index 0000000..ab393a7 --- /dev/null +++ b/class.h @@ -0,0 +1,16 @@ +#pragma once + +#define MaxNameLength 100 +#define StartingHelath 100 + +typedef struct Humanoid Humanoid_t; + +struct Humanoid { + char name[MaxNameLength]; + float health; + void (*move)(Humanoid_t* self, int x, int y); + void (*look)(Humanoid_t* self, int x, int y); + void (*remove)(Humanoid_t* self); +}; + +Humanoid_t* InitHuman(char* PlayerName); \ No newline at end of file diff --git a/main.c b/main.c new file mode 100644 index 0000000..032fff9 --- /dev/null +++ b/main.c @@ -0,0 +1,12 @@ +#include +#include "class.h" + +int main(int argc, char** argv){ + + Humanoid_t* Player1 = InitHuman("Derek Hollowy"); + Player1->move(Player1, 4, 9); + + Player1->remove(Player1); + + return 1; +} \ No newline at end of file diff --git a/main.out b/main.out new file mode 100755 index 0000000..e2d0e9f Binary files /dev/null and b/main.out differ