diff options
| author | Ben Beltran <ben@freshout.us> | 2013-08-14 09:00:22 -0500 |
|---|---|---|
| committer | Ben Beltran <ben@freshout.us> | 2013-08-14 09:00:22 -0500 |
| commit | 8534e46e400268c5ceffb3b14f02cef39eedae8f (patch) | |
| tree | ec864c10f35c91c87711b0a12710ee18ba81f9dc /src/actor_manager.c | |
| parent | ed603039c4a456b37aefe434a3b1a5352362d86b (diff) | |
Add some basic actorstuffs
Diffstat (limited to 'src/actor_manager.c')
| -rw-r--r-- | src/actor_manager.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/actor_manager.c b/src/actor_manager.c new file mode 100644 index 0000000..c9303d2 --- /dev/null +++ b/src/actor_manager.c @@ -0,0 +1,57 @@ +// +// actor_manager.c +// Super Polarity +// +// Created by Ruben Beltran del Rio on 8/14/13. +// Copyright (c) 2013 Abuguet. All rights reserved. +// + +#include <stdio.h> +#include "actor_manager.h" + +void actorManagerUpdate(ActorManager *this, Uint32 dt) { + ActorNode *head = this->actors; + + while (head != NULL) { + head->val->update(head->val, dt); + head = head->next; + } +} + +void actorManagerDraw(ActorManager *this) { + ActorNode *head = this->actors; + + while (head != NULL) { + head->val->draw(head->val); + head = head->next; + } +} + +void actorManagerAddActor(ActorManager *this, Actor *actor) { + ActorNode *actorNode = malloc(sizeof(ActorNode*)); + ActorNode **head = &this->actors; + ActorNode *temp; + actorNode->val = actor; + actorNode->next = NULL; + + if (*head == NULL) { + *head = actorNode; + } else { + temp = *head; + + while (temp->next != NULL) { + temp = temp->next; + } + temp->next = actorNode; + } +} + +ActorManager* createActorManager () { + ActorManager *actorManager = malloc(sizeof(ActorManager*)); + actorManager->actors = NULL; + actorManager->update = actorManagerUpdate; + actorManager->draw = actorManagerDraw; + actorManager->addActor = actorManagerAddActor; + + return actorManager; +}
\ No newline at end of file |