Skip to content

Instantly share code, notes, and snippets.

@cfcosta
Created February 21, 2012 01:02
Show Gist options
  • Save cfcosta/1872685 to your computer and use it in GitHub Desktop.
Save cfcosta/1872685 to your computer and use it in GitHub Desktop.
#include "sprite_stack.h"
void stack_remove(sprite_node *node)
{
node->previous->next = node->next;
SDL_FreeSurface(node->sprite->image);
free(node);
}
void stack_unshift(sprite_node *node)
{
first->previous = node;
node->last = first;
first = node;
}
void stack_append(sprite_node *node)
{
last->next = node;
node->previous = last;
last = node;
}
#ifndef H_STACK_COLLECTION
#define H_STACK_COLLECTION
#include "graphics.h"
typedef struct {
sprite *sprite;
sprite_node *previous;
sprite_node *next;
} sprite_node;
sprite_node *first;
sprite_node *last;
void stack_remove(sprite_node *node);
void stack_unshift(sprite_node *node);
void stack_append(sprite_node *node);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment