Updated code
This commit is contained in:
90
entities.c
Normal file
90
entities.c
Normal file
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// Created by tony on 11/28/2024.
|
||||
//
|
||||
|
||||
#include "entities.h"
|
||||
|
||||
/*Entity* entity_INIT(int id, char avatar, char type, COORD position) {
|
||||
Entity* e = (Entity *)malloc(sizeof(Entity));
|
||||
|
||||
e->id = id;
|
||||
e->avatar = avatar;
|
||||
e->type = type;
|
||||
e->position = position;
|
||||
|
||||
e->next = NULL;
|
||||
return e;
|
||||
}*/
|
||||
|
||||
void append(Entity *head, int id, char avatar, char type, COORD position)
|
||||
{
|
||||
/* Entity e =
|
||||
{
|
||||
id,
|
||||
avatar,
|
||||
type,
|
||||
position
|
||||
};
|
||||
if (head == NULL) {
|
||||
head = &e;
|
||||
} else {
|
||||
Entity *temp = *head;
|
||||
while (temp->next != NULL) {
|
||||
temp = temp->next;
|
||||
}
|
||||
temp->next = e;
|
||||
}*/
|
||||
}
|
||||
|
||||
/*
|
||||
void freeList(Entity *e)
|
||||
{
|
||||
Entity *current = *e;
|
||||
Entity *next;
|
||||
|
||||
while (current != NULL)
|
||||
{
|
||||
free(current);
|
||||
current = next;
|
||||
}
|
||||
|
||||
*e = NULL;
|
||||
}
|
||||
*/
|
||||
void updateEntityPostition(struct Entity *pEntity, int direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case (1):
|
||||
pEntity->position.Y--;
|
||||
break;
|
||||
case (2):
|
||||
pEntity->position.Y++;
|
||||
break;
|
||||
case (3):
|
||||
pEntity->position.X--;
|
||||
break;
|
||||
case (4):
|
||||
pEntity->position.X++;
|
||||
break;
|
||||
default:
|
||||
0;
|
||||
}
|
||||
};
|
||||
|
||||
/*struct Entity **createEntity(int id, char avatar, char type, COORD position)
|
||||
{
|
||||
struct Entity *e = (Entity *)malloc(sizeof(Entity));
|
||||
|
||||
e->id = id;
|
||||
e->avatar = avatar;
|
||||
e->type = type;
|
||||
e->position = position;
|
||||
|
||||
return (Entity **)e;
|
||||
}*/
|
||||
|
||||
void freeEntities(struct Entity *pEntity)
|
||||
{
|
||||
free(pEntity);
|
||||
}
|
||||
Reference in New Issue
Block a user