Initial clone in from local subversion server

This commit is contained in:
2011-05-26 02:24:33 +00:00
commit ccca81e04e
87 changed files with 20290 additions and 0 deletions

204
Actor.cpp Executable file
View File

@@ -0,0 +1,204 @@
//#include "Game.h"
#include "Common.h"
#include "Actor.h"
#include "Animation.h"
#include <SDL.h>
#include <iostream>
Actor::Actor()
{
this->userType = 0;
this->state = STATE_NONE;
this->animMap = new AnimationStateMap();
this->position.x = 0;
this->position.y = 0;
this->position.z = 0;
this->velocity.x = 0;
this->velocity.y = 0;
this->velocity.z = 0;
this->parent = NULL;
this->frameCounter.curFrame = 0;
this->frameCounter.lastFrame = 0;
this->frameCounter.lastTime = SDL_GetTicks();
this->logicCounter.lastTime = SDL_GetTicks();
}
Actor::~Actor()
{
}
Actor::Actor(AnimationStateMap *animMap, Vector position, Vector velocity)
{
this->animMap = animMap;
if ( this->animMap == NULL ) {
this->animMap = new AnimationStateMap();
}
this->position.x = position.x;
this->position.y = position.y;
this->position.z = position.z;
this->velocity.x = velocity.x;
this->velocity.y = velocity.y;
this->velocity.z = velocity.z;
this->frameCounter.curFrame = 0;
this->frameCounter.lastFrame = 0;
this->frameCounter.lastTime = SDL_GetTicks();
this->logicCounter.lastTime = SDL_GetTicks();
this->state = 0;
}
int Actor::addAnimation(Animation *anim, unsigned int stateKey)
{
// I started letting this accept NULL sprite strips when STATE_DEFAULT was introduced
// so that you could force an actor to be culled from the display list by setting its
// STATE_DEAD to NULL manually.
if ( this->animMap == NULL) {
//////std::cerr << "Pussying out.";
return 1;
}
//////std::cerr << "Adding " << anim << " to animation map " << this->animMap << " for " << this << " at state " << stateKey << "\n";
if ( this->animMap->count(stateKey) > 0 ) {
this->animMap->erase(stateKey);
}
(*this->animMap)[stateKey] = anim;
return 0;
}
Animation *Actor::getAnimation(unsigned int stateKey)
{
//////std::cerr << "stateKey " << stateKey << " this->animMap " << this->animMap << " count " << this->animMap->count(stateKey) << "\n";
if ( this->animMap == NULL ) {
return NULL;
}
if ( this->animMap != NULL && this->animMap->count(stateKey) > 0 ) {
//////std::cerr << "Returning SOMETHING...\n";
return (*this->animMap)[stateKey];
} else if ( this->animMap->count(STATE_DEFAULT) > 0 ) {
return (*this->animMap)[STATE_DEFAULT];
}
return NULL;
}
SDL_Surface *Actor::nextFrame()
{
SDL_Surface *newFrame = NULL;
Animation *anim = this->getAnimation(this->state);
if ( anim != NULL ) {
newFrame = anim->nextFrame(0, 0, this);
return newFrame;
}
////std::cerr << "Got NULL animation!\n";
return NULL;
}
void Actor::setState(int state)
{
this->state = state;
}
void Actor::addState(int state)
{
this->state = this->state | state;
//////std::cerr << "State is now " << this->state << " for actor " << this << "\n";
}
void Actor::removeState(int state)
{
if ( this->hasState(state) ) {
this->state = this->state ^ state;
}
//////std::cerr << "State is now " << this->state << " for actor " << this << "\n";
}
Vector Actor::getPosition(char gfxanchor)
{
Animation *anim = NULL;
Vector pos;
Vector parentPos;
pos.x = this->position.x;
pos.y = this->position.y;
pos.z = this->position.z;
if ( gfxanchor == 1 ) {
anim = this->getAnimation(this->state);
if ( anim )
pos = anim->anchorAt(pos);
}
if ( this->parent != NULL && this->hasState(STATE_RENDERPARENT)) {
parentPos = this->parent->getPosition();
pos.x += parentPos.x;
pos.y += parentPos.y;
pos.z += parentPos.z;
}
return pos;
}
void Actor::update()
{
Animation *curAnim;
Vector parentPos;
//if ( (SDL_GetTicks() - this->logicCounter.lastTime) > (1000/GAMEFPS) ) {
this->logicCounter.lastTime = SDL_GetTicks();
if ( this->hasState(STATE_MOVEXAXIS)) {
this->position.x += this->velocity.x;
} else {
if ( this->hasState(STATE_MOVERIGHT) )
this->position.x += this->velocity.x;
if ( this->hasState(STATE_MOVELEFT) )
this->position.x -= this->velocity.x;
}
if ( this->hasState(STATE_MOVEYAXIS) ) {
this->position.y += this->velocity.y;
} else {
if ( this->hasState(STATE_MOVEDOWN) )
this->position.y += this->velocity.y;
if ( this->hasState(STATE_MOVEUP) )
this->position.y -= this->velocity.y;
}
if ( this->hasState(STATE_MOVEIN) )
this->position.z -= this->velocity.z;
if ( this->hasState(STATE_MOVEOUT) )
this->position.z += this->velocity.z;
//std::cerr << "x = " << this->position.x << " y = " << this->position.y << "\n";
//std::cerr << " state = " << this->state << "\n";
curAnim = this->getAnimation(this->state);
//std::cerr << curAnim->numFrames();
//if ( curAnim != NULL )
//std::cerr << "Dying object " << this << "has animation " << curAnim << " current frame " << this->frameCounter.curFrame << " of " << curAnim->numFrames() << " state " << this->state << "\n";
//std::cerr.flush();
if ( ((curAnim != NULL) && (this->frameCounter.curFrame+1 >= (unsigned int)curAnim->numFrames()) && (this->hasState(STATE_DYING))) ||
(curAnim == NULL && this->hasState(STATE_DYING)) ) {
// we're dead
//std::cerr << "Actor " << this << " is dead.\n";
this->state = STATE_DEAD;
}
//}
}
int Actor::hasState(int state)
{
if ( (this->state & state) == state )
return 1;
else return 0;
}
int Actor::getState()
{
return this->state;
}
unsigned int Actor::getUserType()
{
return this->userType;
}
void Actor::setUserType(unsigned int type)
{
this->userType = type;
}

62
Actor.h Executable file
View File

@@ -0,0 +1,62 @@
#ifndef __ACTOR_H__
#define __ACTOR_H__
#include <vector>
#include <SDL.h>
#include "Renderable.h"
#include "Animation.h"
#define STATE_NONE 0
#define STATE_DYING 2
#define STATE_DEAD 4
#define STATE_MOVEXAXIS (8 | 16)
#define STATE_MOVELEFT 8
#define STATE_MOVERIGHT 16
#define STATE_MOVEYAXIS (32 | 64)
#define STATE_MOVEUP 32
#define STATE_MOVEDOWN 64
#define STATE_VISIBLE 128
#define STATE_INVINCIBLE 256
#define STATE_SPAWNWAIT 512
#define STATE_FADEIN 1024
#define STATE_FADEOUT 2048
#define STATE_ATTACKING 4096
#define STATE_MOVEIN 8192
#define STATE_MOVEOUT 16384
#define STATE_RENDERPARENT 32768 // this status flag specifies that, when an Actor has a Parent,
// the position returned by this actor should be relative to their parent
#define STATE_DEFAULT 0xFFFFFFFF
class Actor : public AnimatedRenderable
{
protected:
int state;
FrameCounter logicCounter;
unsigned int userType;
public:
AnimationStateMap *animMap;
Actor(AnimationStateMap *animMap, Vector position, Vector velocity);
Actor();
virtual ~Actor();
virtual SDL_Surface *nextFrame();
virtual Vector getPosition(char gfxanchor = 0);
virtual int addAnimation(Animation *anim, unsigned int key);
virtual Animation *getAnimation(unsigned int stateKey);
virtual void setState(int state);
virtual int getState();
virtual void addState(int state);
virtual void removeState(int state);
virtual int hasState(int state);
virtual void update();
virtual void collide(Actor *ptr) {};
virtual unsigned int getUserType();
virtual void setUserType(unsigned int type);
Actor *parent;
};
typedef std::vector<Actor *> ActorList;
typedef std::vector<Actor *>::iterator ActorListIterator;
#endif // __ACTOR_H__

107
Animation.cpp Executable file
View File

@@ -0,0 +1,107 @@
#include <SDL.h>
#include "SpriteStrip.h"
#include "Animation.h"
#include "Actor.h"
#include <iostream>
// TODO: Animation has mysterious segfault problems when it is used static; e.g.
//
// Animation anim; <-- using this object will eventually cause a segfault thru the framecounters/indexers
// ..
// Animation *anim = new Animation() <-- ... using this one will not
Animation::Animation()
{
this->strip = NULL;
this->timeStep = 0;
this->fps = 0;
this->anchor.x = 0;
this->anchor.y = 0;
}
Animation::~Animation()
{
}
int Animation::setStrip(SpriteStrip *strip, int fps, int loop, Vector anchor)
{
if ( strip == NULL ) {
std::cerr << "Got NULL sprite strip\n";
return 1;
}
this->loop = loop;
this->strip = strip;
//std::cerr << "this->strip is now " << strip << "\n";
this->fps = fps;
if ( this-> fps > 0 )
this->timeStep = 1000 / fps;
if ( anchor.x <= this->strip->width() )
this->anchor.x = anchor.x;
if ( anchor.y <= this->strip->height() )
this->anchor.y = anchor.y;
return 0;
}
// FIXME : The way this interaction works is INCREDIBLY hackish. I should look
// at collapsing the nextFrame() functionality into Actor, and basically redoing the
// Animation class as a structure that does nothing. For now, though, this works.
SDL_Surface *Animation::nextFrame(int curFrame, int lastTime, AnimatedRenderable *actorSource)
{
FrameCounter fc;
if ( actorSource ) {
fc = actorSource->getFrameCounter();
curFrame = fc.curFrame;
lastTime = fc.lastTime;
}
SDL_Surface *toRet = NULL;
//std::cerr << "Checking for step; timeStep " << this->timeStep << " lastTime " << lastTime << "\n";
if ( this->fps > 0 && ((SDL_GetTicks() - lastTime) >= this->timeStep) ) {
if ( curFrame +1 >= this->strip->numFrames() && this->loop == 0 ) {
toRet = this->strip->getFrame(0);
//std::cerr << "Time for a step; Returning frame 0\n";
} else if ( curFrame + 1 >= this->strip->numFrames() && this->loop == 1) {
return NULL;
}
//std::cerr << "Time for a step; returning frame " << curFrame + 1 << "\n";
toRet = this->strip->getFrame(curFrame+1);
curFrame += 1;
if ( actorSource ) {
fc.curFrame += 1;
if ( fc.curFrame >= this->strip->numFrames() && this->loop == 0 ) {
//std::cerr << "Resetting to zero\n";
fc.curFrame = 0;
curFrame = 0;
}
fc.lastTime = SDL_GetTicks();
fc.lastFrame = toRet;
actorSource->setFrameCounter(fc);
}
} else if ( this->fps == 0 ) {
//std::cerr << "0 FPS ; Returning frame 0\n";
toRet = this->strip->getFrame(0);
} else {
//std::cerr << "Not time for a step; Returning frame " << curFrame << "\n";
toRet = this->strip->getFrame(curFrame);
}
if ( toRet == NULL )
return this->strip->getFrame(0);
else
return toRet;
}
int Animation::numFrames()
{
if ( this->strip != NULL ) {
return this->strip->numFrames();
}
return 0;
}
Vector Animation::anchorAt(Vector position)
{
Vector newVector;
newVector.x = position.x - this->anchor.x;
newVector.y = position.y - this->anchor.y;
return newVector;
}

34
Animation.h Executable file
View File

@@ -0,0 +1,34 @@
#ifndef __ANIMATION_H__
#define __ANIMATION_H__
#include <SDL.h>
#include "SpriteStrip.h"
#include "Renderable.h"
#include <map>
class Animation
{
private:
unsigned int lastTime;
SpriteStrip *strip;
unsigned int timeStep;
int fps;
int loop;
Vector anchor;
public:
Animation();
virtual ~Animation();
int getLoop() { return this->loop; };
int setStrip(SpriteStrip *strip, int fps, int loop = 0, Vector anchor = (Vector){0,0,0});
SDL_Surface *nextFrame(int curFrame, int lastTime, AnimatedRenderable *actorSource = NULL);
int numFrames();
Vector anchorAt(Vector position);
};
//typedef std::map<std::string, Animation *> AnimationMap;
//typedef std::map<std::string, Animation *>::iterator AnimationMapIterator;
typedef std::map<unsigned int, Animation *> AnimationStateMap;
typedef std::map<unsigned int, Animation *>::iterator AnimationStateMapIterator;
#endif // __ANIMATION_H__

75
Common.cpp Executable file
View File

@@ -0,0 +1,75 @@
#include "Common.h"
#include <iostream>
SharedCanvas2D::SharedCanvas2D()
{
this->canvas = NULL;
}
SharedCanvas2D::~SharedCanvas2D()
{
this->releaseCanvas();
}
/**
* @brief Return a pointer to the SDL_Surface pointer held by this shared canvas
* @return SDL_Surface *
*/
SDL_Surface *SharedCanvas2D::getCanvas()
{
return this->canvas;
}
/**
* @brief Set the canvas pointer to the given object, and increment its refcount
* @param obj A SharedCanvas2D object whose surface you want to share
* @return 0 on success, 1 on failure
*/
int SharedCanvas2D::shareCanvas(SharedCanvas2D *obj)
{
if ( obj == NULL || this->canvas != NULL || obj->getCanvas() == NULL ) {
std::cerr << "Unable to share canvas from object " << obj << "\n";
return 1;
}
this->canvas = obj->getCanvas();
this->canvas->refcount += 1;
return 0;
}
/**
* @brief Set the canvas pointer to the given object, and increment its refcount
* @param obj A SDL_Surface pointer who you want to share
* @return 0 on success, 1 on failure
*/
int SharedCanvas2D::shareCanvas(SDL_Surface *obj)
{
if ( obj == NULL ) {
return 1;
}
this->canvas = obj;
obj->refcount += 1;
return 0;
}
/**
* @fn SharedCanvas2D::releaseCanvas
* @brief Decrement the refcount of the canvas we're currently sharing, and release it
* @return 0 on success, 1 on failure
*/
int SharedCanvas2D::releaseCanvas()
{
if ( this->canvas == NULL ) {
return 0;
}
if ( this->canvas->refcount >= 2 ) {
this->canvas->refcount -= 1;
this->canvas = NULL;
return 1;
} else if ( this->canvas->refcount == 1 ) {
SDL_FreeSurface(this->canvas);
return 1;
}
// do nothing if canvas refcount == 0 (thou shalt not double free)
return 0;
}

45
Common.h Executable file
View File

@@ -0,0 +1,45 @@
#ifndef __COMMON_H__
#define __COMMON_H__
#include <SDL.h>
#define GAMEFPS 60
struct Vector
{
float x;
float y;
float z;
};
typedef Vector Point;
struct FrameCounter
{
unsigned int curFrame;
unsigned int lastTime;
SDL_Surface *lastFrame;
};
/**
* @class SharedCanvas2D
* @brief A class that allows multiple objects to re-use a single SDL_Surface with reference counting for safe memory usage
*
* The only thing that might be confusing about this class is that it is just
* a container for an SDL_Surface that implements refcounting.
*/
class SharedCanvas2D
{
protected:
SDL_Surface *canvas;
public:
SharedCanvas2D();
virtual ~SharedCanvas2D();
SDL_Surface *getCanvas();
virtual int shareCanvas(SharedCanvas2D *obj);
virtual int shareCanvas(SDL_Surface *obj);
virtual int releaseCanvas();
};
#endif // __COMMON_H__

BIN
Debug/libgame-dbg Executable file

Binary file not shown.

119
Display.cpp Executable file
View File

@@ -0,0 +1,119 @@
#include "Display.h"
#include "Actor.h"
#include <iostream>
Display::Display()
{
this->active = 0;
return;
}
Display::~Display()
{
if ( this->canvas != NULL && this->canvas->refcount > 0 ) {
SDL_FreeSurface(this->canvas);
}
}
int Display::isActive()
{
return this->active;
}
void Display::setActive(int active)
{
this->active = active;
}
int Display::initVideo(Vector pos, int w, int h, int depth, int flags)
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
int rmask = 0xff000000;
int gmask = 0x00ff0000;
int bmask = 0x0000ff00;
//int amask = 0x000000ff;
#else
int rmask = 0x000000ff;
int gmask = 0x0000ff00;
int bmask = 0x00ff0000;
//int amask = 0xff000000;
#endif
this->setPosition(pos);
this->canvas = SDL_CreateRGBSurface(flags, w, h, depth, rmask, gmask, bmask, 0);
if ( this->canvas == NULL ) {
//std::cerr << "Failed to create new SDL surface. Error was: " << SDL_GetError() << "\n";
return 1;
}
////std::cerr << "Created new SDL surface at " << this->canvas << "\n";
return 0;
}
int Display::addActor(Actor *actor)
{
if ( actor == NULL ) {
//std::cerr << "NULL actor!";
return 1;
}
//std::cerr << "Adding actor " << actor << " to Display " << this << "\n";
ActorListIterator iter = this->actors.begin();
while ( iter != this->actors.end() ) {
if ( *iter == actor ) {
return 1;
}
iter++;
}
this->actors.push_back(actor);
return 0;
}
Actor *Display::getActor(unsigned int index)
{
if ( index < this->actors.size() ) {
return this->actors.at(index);
}
return NULL;
}
int Display::removeActor(Actor *actor)
{
ActorListIterator iter = this->actors.begin();
//std::cerr << "Trying to delete actor " << actor << " from master list\n";
while ( iter != this->actors.end() ) {
if ( (*iter) == actor ) {
//std::cerr << "Found it!\n";
this->actors.erase(iter);
return 0;
}
iter++;
}
return 1;
}
SDL_Surface *Display::nextFrame()
{
//std::cerr << "[" << this << "]::nextFrame active = " << this->active << "\n";
if ( this->active == 1 ) {
return this->canvas;
} else {
return NULL;
}
}
SDL_PixelFormat *Display::pixelFormat()
{
return this->canvas->format;
}
int Display::objectsOfType(unsigned int userType)
{
int ocount = 0;
ActorListIterator iter = this->actors.begin();
while ( iter != this->actors.end() ) {
if ( (*iter)->getUserType() == userType ) {
ocount += 1;
}
iter++;
}
return ocount;
}

29
Display.h Executable file
View File

@@ -0,0 +1,29 @@
#ifndef __DISPLAY_H__
#define __DISPLAY_H__
#include "Actor.h"
#include "Renderable.h"
#include "FontRenderer.h"
#include <SDL.h>
class Display : public Renderable, public SharedCanvas2D
{
protected:
ActorList actors;
int active;
public:
Display();
virtual ~Display();
virtual int isActive();
virtual void setActive(int active);
virtual int initVideo(Vector pos, int w, int h, int depth, int flags);
virtual SDL_Surface *nextFrame();
virtual int addActor(Actor *actor = NULL);
virtual Actor *getActor(unsigned int index);
virtual int removeActor(Actor *actor);
virtual void update(int logicOnly = 0) {};
SDL_PixelFormat *pixelFormat();
virtual int objectsOfType(unsigned int userType);
};
#endif // __DISPLAY_H__

81
Display2D.cpp Executable file
View File

@@ -0,0 +1,81 @@
#include "Display2D.h"
#include "Renderable.h"
#include <SDL.h>
#include <iostream>
Display2D::Display2D()
{
return;
}
int Display2D::addActor(Actor *actor, int layer)
{
Display::addActor(actor);
this->layers[layer].push_back(actor);
//std::cerr << "Added actor " << actor << " to layer " << layer << "\n";
return 0;
}
void Display2D::update(int logicOnly)
{
ActorListIterator actorIter;
ActorListIterator newActorIter;
SDL_Surface *curFrame = NULL;
Actor *actor = NULL;
if ( this->active == 0 ) {
return;
}
//std::cerr << "Updating Display2D " << this << "\n";
SDL_Rect screen = {0, 0, this->canvas->w, this->canvas->h};
Vector actorpos;
if ( this->canvas->refcount < 2 ) {
// don't blank out someone's shared canvas
SDL_FillRect(this->canvas, &screen, 0);
}
for ( int layer = 0; layer < MAX_LAYERS; layer++ ) {
//std::cerr << "Displaying " << this->layers[layer].size() << " sprites on layer " << layer << " on canvas " << this->canvas << "\n";
actorIter = this->layers[layer].begin();
while ( actorIter != this->layers[layer].end() ) {
actor = (*actorIter);
//std::cerr << "Updating actor " << actor << "\n";
if ( actor != NULL ) {
actor->update();
if ( logicOnly == 0 ) {
curFrame = actor->nextFrame();
actorpos = actor->getPosition(1);
//std::cerr << "Position of " << actor << " " << actorpos.x << "x" << actorpos.y << "\n";
if ( curFrame ) {
//std::cerr << "Blitting sprite " << curFrame << " to (" << actorpos.x << "," << actorpos.y << ")...\n";
SDL_Rect srcRect = {0, 0, curFrame->w, curFrame->h};
SDL_Rect destRect = {(Sint16) actorpos.x, (Sint16)actorpos.y, 0, 0};
SDL_BlitSurface(curFrame, &srcRect, this->canvas, &destRect);
}
}
// more logic
if ( actor->hasState(STATE_DEAD) ) {
actorIter = this->layers[layer].erase(actorIter);
newActorIter = this->actors.begin();
while ( newActorIter < this->actors.begin() ) {
if ( *newActorIter == actor ) {
newActorIter = this->actors.erase(newActorIter);
continue;
}
newActorIter++;
}
//delete actor;
continue;
}
}
actorIter++;
}
}
}
void Display2D::setTransparentBG()
{
SDL_SetColorKey(this->canvas, SDL_SRCCOLORKEY, SDL_MapRGB(this->canvas->format, 0, 0, 0));
}

29
Display2D.h Executable file
View File

@@ -0,0 +1,29 @@
#ifndef __DISPLAY2D_H__
#define __DISPLAY2D_H__
#include "Display.h"
#include "Common.h"
#define LAYER_BACKGROUND 0
#define LAYER_SPRITE1 1
#define LAYER_SPRITE2 2
#define LAYER_SPRITE3 3
#define LAYER_EFFECTS 4
#define LAYER_HUDOVERLAY 5
#define LAYER_MENUOVERLAY 6
#define MAX_LAYERS 6
class Display2D : public Display
{
protected:
int blitSprite(SDL_Surface *srcframe, int x, int y);
std::vector<Actor *> layers[MAX_LAYERS];
public:
Display2D();
int addActor(Actor *actor, int layer = LAYER_BACKGROUND);
void update(int logicOnly = 0);
void setTransparentBG();
};
#endif // __Display2D_H__

103
FontRenderer.cpp Executable file
View File

@@ -0,0 +1,103 @@
#include "FontRenderer.h"
#include "Common.h"
#include <SDL.h>
#include <SDL_gfxPrimitives.h>
FontRenderer::FontRenderer()
{
this->setColor((SDL_Color) {0,0,0,0}, (SDL_Color){255,255,255,0}, 1);
}
FontRenderer::~FontRenderer()
{
////std::cerr << "Freeing memory in FontRenderer is not yet implemented\n";
}
int FontRenderer::loadFont(std::string filename, std::string fontname, int pointsize)
{
TTF_Font *font = TTF_OpenFont(filename.c_str(), pointsize);
if ( font == NULL ) {
////std::cerr << "Unable to load font " << filename << "\n";
return 1;
}
this->loadedFonts[fontname][pointsize] = font;
return 0;
}
void FontRenderer::setColor(SDL_Color textColor, SDL_Color bgColor, int alpha)
{
//std::cerr << "FontRenderer::setColor (" << textColor.r << " : " << textColor.g << " : " << textColor.b << ") "
//<< " ( " << bgColor.r << " : " << bgColor.g << " : " << bgColor.b << " ) alpha " << alpha << "\n";
this->textColor = textColor;
this->bgColor = bgColor;
this->alpha = alpha;
}
SDL_Rect FontRenderer::renderString(std::string text,
SDL_Surface *dest,
std::string fontname,
Vector position,
int pointsize)
{
SDL_Rect destrect;
SDL_Surface *surface;
SDL_Color foregroundColor, backgroundColor;
TTF_Font *font;
SDL_Rect blankrect;
int plainTextWidth = 0;
if ( dest == NULL ) {
return blankrect;
}
if ( fontname == "" ) {
plainTextWidth = text.size() * 8;
if ( position.x == -1 )
position.x = (dest->w/2) - (plainTextWidth/2);
if ( position.y == -1 )
position.y = (dest->h/2) - 8;
//std::cerr << "Rendering (plain text) " << text << " at " << position.x << " x " << position.y << "\n";
stringRGBA(dest, (int)position.x, (int)position.y, text.c_str(),
this->textColor.r, this->textColor.g, this->textColor.b, this->alpha);
return blankrect;
}
////std::cerr << "Rendering (true type) " << text << " at " << position.x << " x " << position.y << "\n";
if ( this->loadedFonts.count(fontname) == 1 ) {
if ( this->loadedFonts[fontname].count(pointsize) == 1 ) {
////std::cerr << "Found font..";
font = this->loadedFonts[fontname][pointsize];
} else {
////std::cerr << "No font found for (point size) 20\n";
return blankrect;
}
} else {
////std::cerr << "No font found for (" << fontname << ")\n";
return blankrect;
}
surface = TTF_RenderUTF8_Shaded(font, text.c_str(), this->textColor, this->bgColor);
if (surface == NULL)
{
////std::cerr << "Couldn't create String " << text << ":" << SDL_GetError() << "\n";
return blankrect;
}
/* Blit the entire surface to the screen */
destrect.x = (position.x == -1 ? (dest->w - surface->w) / 2 : (Sint16) position.x);
destrect.y = (position.y == -1 ? (dest->h - surface->h) / 2 : (Sint16) position.y);
destrect.w = surface->w;
destrect.h = surface->h;
////std::cerr << "FontRenderer::renderString this->alpha " << this->alpha << "\n";
if ( this->alpha == 1 ) {
SDL_SetColorKey(surface, SDL_SRCCOLORKEY,
SDL_MapRGBA(surface->format, this->bgColor.r, this->bgColor.g, this->bgColor.b, 0) );
}
SDL_BlitSurface(surface, NULL, dest, &destrect);
/* Free the generated string image */
SDL_FreeSurface(surface);
return destrect;
}

36
FontRenderer.h Executable file
View File

@@ -0,0 +1,36 @@
#ifndef __FONTRENDERER_H__
#define __FONTRENDERER_H__
#include <SDL.h>
#include <SDL_ttf.h>
#include <iostream>
#include <vector>
#include <map>
#include "Common.h"
class FontRenderer
{
protected:
// organized by loadedFonts[FontName][PointSize] = TTF_Font *
FontRenderer();
~FontRenderer();
std::map<std::string, std::map<int, TTF_Font *> > loadedFonts;
SDL_Color textColor;
SDL_Color bgColor;
int alpha;
public:
static FontRenderer &NewSingleton()
{
static FontRenderer rend;
return rend;
}
void setColor(SDL_Color textColor, SDL_Color bgColor, int alpha);
int loadFont(std::string filename, std::string fontname, int pointsize);
SDL_Rect renderString(std::string text,
SDL_Surface *dest,
std::string fontname,
Vector position,
int pointsize);
};
#endif // __FONTRENDERER_H__

506
Game.cpp Executable file
View File

@@ -0,0 +1,506 @@
#include "Game.h"
#include "SpriteStrip.h"
#include "Actor.h"
#include "Display2D.h"
#include <SDL_mixer.h>
#include <SDL.h>
#include <iostream>
Game::Game()
{
this->musicVolume = 128;
this->soundVolume = 128;
this->lastNumKeys = 0;
this->lastKeyState = NULL;
this->fpslock = 0;
this->realfps = 0;
return;
}
Game::~Game()
{
if ( this->canvas != NULL ) {
SDL_FreeSurface(this->canvas);
}
}
int Game::initSDL(int audio_rate, Uint16 audio_format, int audio_channels, int audio_buffers)
{
if ( SDL_Init(SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0 ) {
//std::cerr << "Failed to initialize SDL. Error was: " << SDL_GetError() << "\n";
return 1;
}
if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0) {
//std::cerr << "Unable to initialize audio: " << Mix_GetError() << "\n";
exit(1);
}
return 0;
}
int Game::initVideo(int w, int h, int depth, int flags)
{
this->canvas = SDL_SetVideoMode(w, h, depth, flags);
if ( this->canvas == NULL ) {
//std::cerr << "Failed to create new SDL display. Error was: " << SDL_GetError() << "\n";
return 1;
}
////std::cerr << "Created new SDL display at " << this->canvas << "\n";
return 0;
}
void Game::update(int logicOnly)
{
DisplayList::iterator displayIter;
SDL_Surface *curFrame = NULL;
Display *display = NULL;
Uint8 *keyState = NULL;
int numKeys = 0;
int gfxframe = 1;
static unsigned int lastTime = 0;
static unsigned int lastfps = 0;
static unsigned int realFPStimer = 0;
SDL_Rect screen = {0, 0, this->canvas->w, this->canvas->h};
Vector displaypos;
SDL_PumpEvents();
if ( (this->fpslock != 0) && (SDL_GetTicks() - lastTime) >= (1000/this->fpslock) ) {
gfxframe = 1;
lastTime = SDL_GetTicks();
} else if (this->fpslock != 0) {
return;
}
if ( (SDL_GetTicks() - realFPStimer) > 1000 ) {
this->realfps = lastfps;
lastfps = 0;
realFPStimer = SDL_GetTicks();
} else {
lastfps++;
}
if ( logicOnly == 0 ) {
SDL_FillRect(this->canvas, &screen, 0);
}
for ( displayIter = this->windows.begin(); displayIter != this->windows.end() ; displayIter++ ) {
display = (*displayIter);
//std::cerr << "Updating display " << display << "\n";
display->update();
if ( logicOnly == 1 ) {
continue;
}
curFrame = display->nextFrame();
displaypos = display->getPosition();
//std::cerr << "Position of " << display << " " << displaypos.x << "x" << displaypos.y << "\n";
if ( curFrame && curFrame != this->canvas ) {
//std::cerr << "Blitting display " << display << " canvas " << curFrame << " to main canvas " << this->canvas << "(" << displaypos.x << "," << displaypos.y << ")...\n";
SDL_Rect destRect = {(Sint16) displaypos.x, (Sint16) displaypos.y, 0, 0};
SDL_BlitSurface(curFrame, NULL, this->canvas, &destRect);
//this->blitSprite(curFrame, 0, 0);
} else if ( curFrame == this->canvas ) {
//std::cerr << "Not blitting display window " << display << " to our canvas " << this->canvas << " because it is sharing our canvas at " << curFrame << "\n";
} else if ( curFrame == NULL ) {
//std::cerr << "display " << display << " has a NULL canvas\n";
}
}
if ( this->lastKeyState != NULL ) {
delete this->lastKeyState;
}
keyState = SDL_GetKeyState(&numKeys);
this->lastKeyState = new Uint8[numKeys];
if ( this->lastKeyState != NULL ) {
memcpy(this->lastKeyState, keyState, (sizeof(Uint8)*numKeys));
}
//this->handleEvents();
this->cleanSounds();
}
/*int Game::handleControlEvent(SDL_Event *event)
{
switch(event->type) {
case SDL_KEYUP:
if ( event->key.state == SDL_RELEASED ) {
if ( event->key.keysym.sym == SDLK_ESCAPE ) {
exit(0);
}
}
}
return 0;
}
int Game::handleEvents()
{
SDL_Event nextEvent;
while ( SDL_PollEvent(&nextEvent) ) {
switch(nextEvent.type) {
case SDL_KEYUP:
this->handleControlEvent(&nextEvent);
}
}
return 0;
}
*/
int Game::playMusic(std::string filename)
{
Mix_HaltMusic();
if ( this->bgmusic )
Mix_FreeMusic(this->bgmusic);
this->bgmusic = Mix_LoadMUS(filename.c_str());
if ( this->bgmusic == NULL ) {
//std::cerr << "Unable to load " << filename.c_str() << " to play music.\n";
return 1;
}
if ( Mix_PlayMusic(this->bgmusic, -1) == -1 ) {
//std::cerr << "Unable to play background music. " << Mix_GetError() << " \n";
return 1;
}
Mix_VolumeMusic(this->musicVolume);
return 0;
}
void Game::haltMusic()
{
Mix_HaltMusic();
if ( this->bgmusic )
Mix_FreeMusic(this->bgmusic);
this->bgmusic = NULL;
}
int Game::playSound(std::string filename, int loops)
{
PlayingSound *sndstruct = NULL;
Mix_Chunk *sound = NULL;
int channel = 0;
sound = Mix_LoadWAV(filename.c_str());
if ( sound == NULL ) {
return 1;
}
channel = Mix_PlayChannel(-1, sound, loops);
if ( channel > -1 ) {
//std::cerr << "Pushing sound chunk " << sound << " on channel " << channel << "\n";
sndstruct = new PlayingSound();
sndstruct->sound = sound;
sndstruct->channel = channel;
this->playingSounds.push_back(sndstruct);
} else {
Mix_FreeChunk(sound);
return 1;
}
Mix_Volume(sndstruct->channel, this->soundVolume);
return 0;
}
void Game::cleanSounds(int force)
{
PlayingSoundList::iterator iter;
PlayingSoundList::iterator newIter;
PlayingSound *curSound = NULL;
iter = this->playingSounds.begin() ;
while ( iter != this->playingSounds.end()) {
curSound = *iter;
if ( curSound == NULL ) {
iter++;
continue;
}
if ( Mix_Playing(curSound->channel) != 0 && force == 1) {
Mix_HaltChannel(curSound->channel);
} else if ( Mix_Playing(curSound->channel) != 0 ) {
iter++;
continue;
}
newIter = iter;
iter++;
Mix_FreeChunk(curSound->sound);
//std::cerr << "Cleared sound at channel" << curSound->channel << "\n";
iter = this->playingSounds.erase(newIter);
delete curSound;
//iter++;
}
}
void Game::setMusicVolume(int volume)
{
this->musicVolume = volume;
Mix_VolumeMusic(this->musicVolume);
}
void Game::setSoundVolume(int volume)
{
this->soundVolume = volume;
Mix_Volume(-1, this->soundVolume);
}
int Game::keyHeldDown(int keysym)
{
Uint8 *keyState = NULL;
int numKeys = 0;
keyState = SDL_GetKeyState(&numKeys);
if ( this->lastKeyState == NULL ) {
return 0;
}
if ( keysym < this->lastNumKeys && keysym < numKeys ) {
return 0;
}
if ( this->lastKeyState[keysym] + keyState[keysym] == 2 ) {
return 1;
}
return 0;
}
// ------------ class factory and memory management stuff
SpriteStrip *Game::newSpriteStrip(std::string key)
{
SpriteStrip *obj = new SpriteStrip();
if ( obj == NULL )
return NULL;
if ( key != "" ) {
if ( this->addSpriteStrip(obj, key) != 0 ) {
delete obj;
return NULL;
}
}
return obj;
}
int Game::freeSpriteStrip(std::string key, SpriteStrip *obj)
{
if ( obj == NULL && this->spriteMap.count(key) == 0 ) {
return 1;
} else if ( obj == NULL ) {
obj = this->spriteMap[key];
}
this->spriteMap.erase(key);
delete obj;
}
Animation *Game::newAnimation(std::string key)
{
Animation *obj = new Animation();
if ( obj == NULL )
return NULL;
if ( key != "" ) {
if ( this->addAnimation(obj, key) != 0 ) {
delete obj;
return NULL;
}
}
return obj;
}
int Game::freeAnimation(std::string key, Animation *obj)
{
if ( obj == NULL && this->animationMap.count(key) == 0 ) {
return 1;
} else if ( obj == NULL ) {
obj = this->animationMap[key];
}
this->animationMap.erase(key);
delete obj;
}
Actor *Game::newActor(std::string key)
{
Actor *obj = new Actor();
if ( obj == NULL )
return NULL;
if ( key != "" ) {
if ( this->addActor(obj, key) != 0 ) {
delete obj;
return NULL;
}
}
return obj;
}
int Game::freeActor(std::string key, Actor *obj)
{
if ( obj == NULL && this->actorMap.count(key) == 0 ) {
return 1;
} else if ( obj == NULL ) {
obj = this->actorMap[key];
}
this->actorMap.erase(key);
delete obj;
}
Display2D *Game::newDisplay2D(std::string key)
{
Display2D *obj = new Display2D();
if ( obj == NULL )
return NULL;
if ( key != "" ) {
if ( this->addDisplay(obj, key) != 0 ) {
delete obj;
return NULL;
}
}
return obj;
}
int Game::freeDisplay2D(std::string key, Display2D *obj)
{
if ( obj == NULL && this->displayMap.count(key) == 0 ) {
return 1;
} else if ( obj == NULL ) {
obj = (Display2D *)this->displayMap[key];
}
this->displayMap.erase(key);
delete obj;
}
MenuDisplay *Game::newMenuDisplay(std::string key)
{
MenuDisplay *obj = new MenuDisplay();
if ( obj == NULL )
return NULL;
if ( key != "" ) {
if ( this->addDisplay(obj, key) != 0 ) {
delete obj;
return NULL;
}
}
return obj;
}
int Game::freeMenuDisplay(std::string key, MenuDisplay *obj)
{
if ( obj == NULL && this->displayMap.count(key) == 0 ) {
return 1;
} else if ( obj == NULL ) {
obj = (MenuDisplay *)this->displayMap[key];
}
this->displayMap.erase(key);
delete obj;
}
int Game::addSpriteStrip(SpriteStrip *strip, std::string key)
{
if ( strip == NULL || this->spriteMap.count(key) > 0 )
return 1;
this->spriteMap[key] = strip;
return 0;
}
SpriteStrip *Game::getSpriteStrip(std::string key)
{
if ( this->spriteMap.count(key) > 0 ) {
return this->spriteMap[key];
}
return NULL;
}
int Game::removeSpriteStrip(std::string stripName)
{
if ( this->spriteMap.count(stripName) > 0 ) {
this->spriteMap.erase(stripName);
return 0;
}
return 1;
}
int Game::addAnimation(Animation *ptr, std::string key)
{
if ( ptr != NULL || this->animationMap.count(key) == 0 ) {
this->animationMap[key] = ptr;
return 0;
}
return 1;
}
Animation *Game::getAnimation(std::string key)
{
if ( this->animationMap.count(key) > 0 ) {
return this->animationMap[key];
}
return NULL;
}
int Game::removeAnimation(std::string key)
{
if ( this->animationMap.count(key) > 0 ) {
this->animationMap.erase(key);
return 0;
}
return 1;
}
int Game::addActor(Actor *ptr, std::string key)
{
if ( ptr != NULL || this->actorMap.count(key) == 0 ) {
this->actorMap[key] = ptr;
return 0;
}
return 1;
}
Actor *Game::getActor(std::string key)
{
if ( this->actorMap.count(key) > 0 ) {
return this->actorMap[key];
}
return NULL;
}
int Game::removeActor(std::string key)
{
if ( this->actorMap.count(key) > 0 ) {
this->actorMap.erase(key);
return 0;
}
return 1;
}
int Game::addDisplay(Display *ptr, std::string key)
{
if ( ptr != NULL || this->displayMap.count(key) == 0 ) {
this->displayMap[key] = ptr;
return 0;
}
return 1;
}
Display *Game::getDisplay(std::string key)
{
if ( this->displayMap.count(key) > 0 ) {
return this->displayMap[key];
}
return NULL;
}
int Game::removeDisplay(std::string key)
{
if ( this->displayMap.count(key) > 0 ) {
this->displayMap.erase(key);
return 0;
}
return 1;
}
void Game::lockFPS(int fps)
{
this->fpslock = fps;
}
void Game::finishFrame()
{
SDL_Flip(this->canvas);
}
SDL_Surface *Game::getCanvas()
{
return this->canvas;
}

113
Game.h Executable file
View File

@@ -0,0 +1,113 @@
#ifndef __GAME_H__
#define __GAME_H__
#include <SDL.h>
#include "SpriteStrip.h"
#include "Animation.h"
#include "Actor.h"
#include "Display.h"
#include "MenuDisplay.h"
#include <SDL_mixer.h>
struct Collision
{
Actor *actor1;
Actor *actor2;
};
struct PlayingSound
{
int channel;
Mix_Chunk *sound;
};
typedef std::vector<PlayingSound *> PlayingSoundList;
// TODO : Take parts of the Game class and break them out into a Window class.
// the way that the Game class lets you specify a render window tells me that
// it should really be its own class, w/ a separate class for game logic
typedef std::vector<Display *> DisplayList;
class Game : public SharedCanvas2D
{
protected:
Mix_Music *bgmusic;
// format is [ idx = [{filename, sound}, {filename, sound}] ]
// .. where idx is a channel number, which gives you a vector of SoundPairs.
PlayingSoundList playingSounds;
int musicVolume;
int soundVolume;
int lastNumKeys;
int fpslock;
Uint8 *lastKeyState;
std::map<std::string, SpriteStrip *> spriteMap;
std::map<std::string, Actor *> actorMap;
std::map<std::string, Animation *> animationMap;
std::map<std::string, Display *> displayMap;
Game();
virtual ~Game();
public:
// easier this way
DisplayList windows;
int realfps;
static Game &NewSingleton()
{
static Game theGame;
return theGame;
}
SDL_Surface *getCanvas();
int initVideo(int w, int h, int depth, int flags);
int initSDL(int audio_rate = 44100, Uint16 audio_format = AUDIO_S16SYS, int audio_channels = 2, int audio_buffers = 4096);
// this stuff is removed for now because the control event mapping isn't implemented
// at all and it was causing problems
/*
int handleEvents();
int handleControlEvent(SDL_Event *event);
*/
void setMusicVolume(int volume = 128);
void setSoundVolume(int volume = 128);
int playMusic(std::string filename);
void haltMusic();
int playSound(std::string filename, int loops = 0);
void cleanSounds(int force = 0);
// --------------- class factory stuff -----------------
SpriteStrip *newSpriteStrip(std::string key = "");
Animation *newAnimation(std::string key = "");
Actor *newActor(std::string key = "");
Display2D *newDisplay2D(std::string key = "");
MenuDisplay *newMenuDisplay(std::string key = "");
int freeSpriteStrip(std::string key = "", SpriteStrip *obj = NULL);
int freeAnimation(std::string key = "", Animation *obj = NULL);
int freeActor(std::string key = "", Actor *obj = NULL);
int freeDisplay2D(std::string key = "", Display2D *obj = NULL);
int freeMenuDisplay(std::string key = "", MenuDisplay *obj = NULL);
// --------------- object tracking ------------------
int addSpriteStrip(SpriteStrip *strip, std::string key);
SpriteStrip *getSpriteStrip(std::string stripName);
int removeSpriteStrip(std::string stripName);
int addActor(Actor *ptr, std::string key);
Actor *getActor(std::string key);
int removeActor(std::string key);
int addAnimation(Animation *ptr, std::string key);
Animation *getAnimation(std::string key);
int removeAnimation(std::string key);
int addDisplay(Display *ptr, std::string key);
Display *getDisplay(std::string key);
int removeDisplay(std::string key);
// ----------------- updating crap
void update(int logicOnly = 0);
void finishFrame();
void lockFPS(int fps);
// ----------------- input helpers
int keyHeldDown(int keysym);
};
#endif // __GAME_H__

98
Makefile Executable file
View File

@@ -0,0 +1,98 @@
# This makefile is a bit hackish. I wrote it early in the AM.
# Fohgiveuhness, please!!
ifndef $(CFG)
CFG=Debug
endif
# you can also pass : mingw32 and macosx
ifndef $(OS)
OS=linux
endif
LIBNAME=game
PROJECTHOME=$(shell pwd)
SDL_CFLAGS=$(shell sdl-config --cflags)
SDL_LDFLAGS=$(shell sdl-config --static-libs)
LIBDIR=/usr/lib
HEADERDIR=/usr/include
ADDL_CFLAGS=
ifeq "$(OS)" "mingw32"
ADDL_CFLAGS=-mwindows
endif
ifeq "$(CFG)" "Debug"
OUTDIR=Debug
LIBTARGET=lib$(LIBNAME)-dbg
LINKLIB=game-dbg
CXXFLAGS=-pg -I./source -g -ggdb -gstabs -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
ifeq "$(CFG)" "Release"
OUTDIR=Release
LIBTARGET=lib$(LIBNAME)
LINKLIB=game
CXXFLAGS=-I./source -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
LINKLIBS=-L../../$(CFG) -L$(OUTDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer
LIBOBJ=$(OUTDIR)/Common.o \
$(OUTDIR)/FontRenderer.o \
$(OUTDIR)/Renderable.o \
$(OUTDIR)/SpriteStrip.o \
$(OUTDIR)/Animation.o \
$(OUTDIR)/Actor.o \
$(OUTDIR)/Display.o \
$(OUTDIR)/Display2D.o \
$(OUTDIR)/MenuDisplay.o \
$(OUTDIR)/Game.o
CC = gcc
CXX = g++
LD = $(CXX)
INSTALL = $(shell which install)
$(OUTDIR)/%.o : %.cpp
$(CXX) $(CXXFLAGS) -o $@ $<
ifeq "$(OS)" "macosx"
all: sharedlib
else
all: staticlib
endif
# this was a pain in my ass cross-platform, so I killed it
sharedlib: $(LIBOBJ)
$(CXX) -dynamiclib -Wl,-headerpad_max_install_names,-undefined,dynamic_lookup,-compatibility_version,1.0,-current_version,1.0,-install_name,/usr/lib/$(LIBTARGET).dylib -o $(CFG)/$(LIBTARGET).dylib $(LIBOBJ)
staticlib: $(LIBOBJ)
$(AR) rcs $(OUTDIR)/$(LIBTARGET) $(LIBOBJ)
.PHONY: docs
docs:
doxygen doxygen.conf
.PHONY: clean
clean:
rm -f $(OUTDIR)/*.o
rm -f $(OUTDIR)/$(LIBTARGET).*
.PHONY: demos
demos:
cd demo && ./build-demos.sh $(CFG)
.PHONY: rebuild
rebuild:
make clean
make CFG=$(CFG) OS=$(OS)
.PHONY: install
install:
$(INSTALL) $(OUTDIR)/$(LIBTARGET)* $(LIBDIR)/
mkdir -p $(HEADERDIR)/libgame
$(INSTALL) *h $(HEADERDIR)/libgame/
.PHONY: deps
deps:
cd deps && make

430
MenuDisplay.cpp Executable file
View File

@@ -0,0 +1,430 @@
#include "libgame.h"
#include <iostream>
#include <SDL_ttf.h>
#include <SDL_gfxPrimitives.h>
#include <cstdlib>
// TODO : Need to get the up/down left/right arrows displaying
// ------------------ Menu Relation --------------
MenuRelation::MenuRelation()
{
this->opt1 = 0;
this->opt2 = 0;
this->relation = 0;
}
// ------------------ Menu Option -------------------
MenuOption::MenuOption(std::string name, int rangeLow, int rangeHigh, int rangeStart, int spinFree, SDL_Surface *img)
{
this->name = name;
this->rangeLow = rangeLow;
this->rangeHigh = rangeHigh;
this->rangeStart = rangeStart;
this->optionImage = img;
this->spinFree = spinFree;
if ( rangeHigh + rangeLow != 0 ) {
this->selected = rangeStart;
} else
this->selected = -1;
}
MenuOption::~MenuOption()
{
}
void MenuOption::clampValue(MenuRelation *relation, int defClampVal)
{
// check our relation for clamping issues
if ( relation != NULL && relation->opt1 != NULL && relation->opt2 != NULL && relation->opt1 == this ) {
std::cerr << "[" << this << "]->selected (" << this->selected << "=" << this->getStringValue() << ") = [" << relation->opt2 << "]->selected (" << relation->opt2->selected << "=" << relation->opt2->getStringValue() << ")\n";
if ( (relation->relation == MENURELATION_NODUPLICATE) &&
(this->getStringValue() == relation->opt2->getStringValue()) ) {
if ( ((this->selected+1) >= (int) this->optlist.size()) ||
((this->rangeHigh != 0) && (this->selected+1 > this->rangeHigh)) ){
//std::cerr << "Clamping DOWN\n";
this->selected -= 1;
} else if ( ((this->selected - 1) < 0) ||
((this->rangeLow != 0) && (this->selected - 1 < this->rangeLow)) ) {
//std::cerr << "Clamping UP\n";
this->selected += 1;
} else {
// we're safe to move either direction on the option here, so just ++ it and then clamp it
this->selected += defClampVal;
}
this->clampValue(NULL);
//std::cerr << "[" << this << "]->selected (" << this->selected << "=" << this->getStringValue() << ") = [" << relation->opt2 << "]->selected (" << relation->opt2->selected << "=" << relation->opt2->getStringValue() << ")\n";
}
}
else {
if ( this->optlist.size() > 0 ) {
if ( this->selected >= (int) this->optlist.size() ) {
this->selected = this->optlist.size()-1;
} else if ( this->selected < 0 ) {
this->selected = 0;
}
} else {
if ( this->selected < this->rangeLow ) {
this->selected = this->rangeLow;
} else if ( this->selected > this->rangeHigh ) {
this->selected = this->rangeHigh;
} else if ( this->rangeLow > this->rangeHigh || this->rangeLow + this->rangeHigh == 0 ) {
this->selected = 0;
}
}
}
//std::cerr << "MenuOption::clampValue " << this->name
//<< " (" << this->optlist.size() << " sub-options ) "
//<< " range (" << this->rangeLow << " - " << this->rangeHigh << ") "
//<< " selected " << this->selected << "\n";
}
std::string MenuOption::getStringValue()
{
char intStringBuff[64];
memset((char *)&intStringBuff, 0x00, 63);
if ( this->rangeLow + this->rangeHigh != 0 ) {
sprintf((char *)&intStringBuff, "%d\0", this->selected);
return std::string((char *)&intStringBuff);
}
if ( this->optlist.size() > this->selected )
return this->optlist.at(this->selected);
else
return this->name;
}
int MenuOption::getIntValue()
{
return this->selected;
}
int MenuOption::select(int value)
{
if ( ( this->optlist.size() > 0 ) && ( value < this->optlist.size()) && ( value > -1 ) ) {
this->selected = value;
return 0;
} else if ( (value >= this->rangeLow) && ( value <= this->rangeHigh ) ) {
this->selected = value;
return 0;
}
return 1;
}
int MenuOption::whenhighlighted()
{
return 0;
}
int MenuOption::whenselected()
{
return 0;
}
int MenuOption::valueup()
{
this->select(this->selected + 1);
}
int MenuOption::valuedown()
{
this->select(this->selected - 1);
}
// ----------------- MenuDisplay --------------------
MenuDisplay::MenuDisplay()
{
this->pointerActor = NULL;
this->curOpt = 0;
this->origin.x = 0;
this->origin.y = 0;
this->origin.z = 0;
this->fontname = "";
this->pointsize = 0;
this->spacing = 0;
this->closeOpt = "";
}
MenuDisplay::~MenuDisplay()
{
if ( this->pointerActor != NULL ) {
delete this->pointerActor;
}
}
void MenuDisplay::setMenuImages(Animation *arrowLeft, Animation *arrowRight, Animation *arrowUp, Animation *arrowDown)
{
this->arrowLeft = arrowLeft;
this->arrowRight = arrowRight;
this->arrowUp = arrowUp;
this->arrowDown = arrowDown;
}
// this is just for backwards compatibility with old code.
void MenuDisplay::addOption(std::string name, int rangeLow = 0, int rangeHigh = 0, int rangeStart = 0, int spinFree = 0, SDL_Surface *img = NULL)
{
this->addOption(new MenuOption(name, rangeLow, rangeHigh, rangeStart, spinFree, img) );
}
void MenuDisplay::addOption(MenuOption *mopt)
{
if ( mopt != NULL )
this->menuOptions.push_back(mopt);
}
int MenuDisplay::addSubOption(std::string name, std::string subopt)
{
std::vector<MenuOption *>::iterator iter;
iter = this->menuOptions.begin();
while ( iter != this->menuOptions.end() ) {
if ( *iter != NULL && (*iter)->optionImage != NULL ) {
// there's zero point in adding a sub option string when this has an image
return 1;
}
if ( *iter != NULL && (*iter)->name == name ) {
(*iter)->optlist.push_back(subopt);
(*iter)->select(0);
return 0;
}
iter++;
}
return 1;
}
int MenuDisplay::setPointer(Animation *ptr)
{
if ( ptr == NULL ) {
//std::cerr << "MenuDisplay::setPointer was passed a NULL Animation.\n";
return 1;
}
if ( this->pointerActor != NULL ) {
delete this->pointerActor;
} else {
this->pointerActor = new Actor();
if ( this->pointerActor == NULL ) {
//std::cerr << "Couldn't allocate memory for new pointer actor\n";
return 1;
}
}
//std::cerr << "Set animation " << ptr << " as animation for actor " << this->pointerActor << " for menu pointer\n";
this->pointerActor->addAnimation(ptr, STATE_NONE);
this->pointerActor->addState(STATE_NONE);
return 0;
}
MenuOption *MenuDisplay::getOption(std::string name)
{
std::vector<MenuOption *>::iterator menuIter;
MenuOption *opt = NULL;
menuIter = this->menuOptions.begin();
if ( name != "" ) {
while ( menuIter != this->menuOptions.end() ) {
opt = *menuIter;
//std::cerr << "Checking " << opt->name << " against " << name << "\n";
if ( opt->name == name ) {
return opt;
}
menuIter++;
}
} else {
//std::cerr << "Returning option at " << this->curOpt << "\n";
return this->menuOptions.at(this->curOpt);
}
return NULL;
}
void MenuDisplay::setMenuOrigin(Vector origin)
{
this->origin.x = origin.x;
this->origin.y = origin.y;
this->origin.z = origin.z;
//std::cerr << "MenuDisplay::setMenuOrigin x = " << this->origin.x << " y = " << this->origin.y << " z = " << this->origin.z << "\n";
}
void MenuDisplay::update(int logicOnly)
{
SDL_Surface *frame = NULL;
SDL_Rect destrect;
SDL_Rect lastdirty;
MenuOption *opt = NULL;
FontRenderer &textEngine = FontRenderer::NewSingleton();
int lastwidth = 0;
std::vector<int> yvalues;
if ( this->active == 0 ) {
return;
}
Display2D::update(logicOnly);
//std::cerr << "curOpt now " << this->curOpt << "\n";
if ( this->curOpt >= (int) this->menuOptions.size() ) {
this->curOpt = this->menuOptions.size() - 1;
} else if ( this->curOpt < 0 ) {
this->curOpt = 0;
}
if ( logicOnly == 1 ) {
return;
}
//std::cerr << "fixed curOpt now " << this->curOpt << "\n";
lastdirty.x = (Sint16) this->origin.x;
lastdirty.y = (Sint16) this->origin.y;
lastdirty.w = 0;
lastdirty.h = 0;
frame = this->pointerActor->nextFrame();
if ( frame != NULL ) {
lastdirty.x += (frame->w + 10);
}
for ( unsigned int i = 0; i < this->menuOptions.size(); i++ ) {
opt = this->menuOptions.at(i);
if ( opt == NULL ) {
continue;
}
//std::cerr << " in MenuDisplay::update i = " << i << " curOpt = " << curOpt << "\n";
//std::cerr << "String value of currently rendering option: " << opt->getStringValue() << "\n";
lastdirty = textEngine.renderString(opt->name, this->canvas, this->fontname, (Vector){lastdirty.x, lastdirty.y + lastdirty.h, 0}, this->pointsize);
if ( i == (unsigned int) curOpt ) {
//std::cerr << this->optHeight * this->curOpt << " = " << this->origin.y + (this->optHeight * this->curOpt) << " = " << ptrdest.y << "\n";
//std::cerr << "MenuDisplay origin is x = " << this->origin.x << " y = " << this->origin.y << " z = " << this->origin.z << " optHeight is " << this->optHeight << " curOpt is " << this->curOpt << "\n";
if ( frame != NULL ) {
// the pointer actually appears slightly to the left of the current option
destrect.x = (Sint16) this->origin.x;
destrect.y = lastdirty.y + ((lastdirty.h/2) - frame->h/2);
destrect.w = 0;
destrect.h = 0;
//std::cerr << "Blitting frame " << frame << " to canvas " << this->canvas << " at (" << destrect.x << " x " << destrect.y << ") as pointer.\n";
SDL_BlitSurface(frame, NULL, this->canvas, &destrect);
}
}
lastdirty.y += this->spacing;
if ( lastdirty.w > lastwidth ) {
lastwidth = lastdirty.w;
}
yvalues.push_back(lastdirty.y - this->spacing);
}
for ( unsigned int i = 0; i < this->menuOptions.size(); i++ ) {
opt = this->menuOptions.at(i);
if ( opt->getStringValue() != opt->name ) {
textEngine.renderString(opt->getStringValue(), this->canvas, this->fontname, (Vector){lastdirty.x + lastwidth + 10, yvalues.at(i), 0}, this->pointsize);
}
}
return;
}
void MenuDisplay::setFont(std::string fontname, int pointsize, SDL_Color color, SDL_Color bgcolor)
{
FontRenderer &textEngine = FontRenderer::NewSingleton();
textEngine.setColor(color, bgcolor, 1);
this->fontname = fontname;
this->pointsize = pointsize;
}
int MenuDisplay::handleEvent(SDL_Event *event)
{
MenuOption *opt = NULL;
opt = this->getOption();
int retval = 1;
if ( this->active == 0 || opt == NULL ) {
return retval;
}
//std::cerr << "MenuDisplay::handleEvent\n";
//switch (event->type) {
//default:
if ( event->key.state == SDL_RELEASED && event->key.keysym.sym == SDLK_DOWN ) {
this->curOpt += 1;
if ( this->curOpt < 0 ) {
this->curOpt = 0;
}
retval = 0;
} else if ( event->key.state == SDL_RELEASED && event->key.keysym.sym == SDLK_UP ) {
this->curOpt -= 1;
if ( this->curOpt >= (int) this->menuOptions.size() ) {
this->curOpt = this->menuOptions.size()-1;
}
retval = 0;
} else if ( ( event->key.state == SDL_RELEASED || opt->spinFree == 1 && event->key.state == SDL_PRESSED )
&& event->key.keysym.sym == SDLK_LEFT ) {
opt->valuedown();
this->clampValue(opt, -1);
retval = 0;
} else if ( ( event->key.state == SDL_RELEASED || opt->spinFree == 1 && event->key.state == SDL_PRESSED )
&& event->key.keysym.sym == SDLK_RIGHT ) {
opt->valueup();
this->clampValue(opt, 1);
retval = 0;
} else if ( event->key.state == SDL_RELEASED && event->key.keysym.sym == SDLK_RETURN ) {
if ( (this->closeOpt != "") && (opt->name != this->closeOpt)) {
retval = 0;
} else if ( ((this->closeOpt != "" ) && (opt->name == this->closeOpt)) || this->closeOpt == "") {
this->active = 0;
retval = 0;
}
}
//}
//opt->clampValue();
return retval;
}
void MenuDisplay::setCloseOption(std::string option)
{
this->closeOpt = option;
}
void MenuDisplay::setSpacing(int spacing)
{
this->spacing = spacing;
}
int MenuDisplay::setRelation(std::string opt1, std::string opt2, int relationType)
{
std::vector<MenuRelation *>::iterator iter;
MenuRelation *tmp;
iter = this->menuRelations.begin();
while ( iter != this->menuRelations.end() ) {
tmp = *iter;
if ( tmp == NULL || tmp->opt1 == NULL || tmp->opt2 == NULL ) {
iter++;
continue;
}
if ( tmp->opt1->name == opt1 && tmp->opt2->name == opt2 && tmp->relation == relationType ) {
return 1;
}
iter++;
}
tmp = new MenuRelation();
tmp->opt1 = this->getOption(opt1);
tmp->opt2 = this->getOption(opt2);
tmp->relation = relationType;
this->menuRelations.push_back(tmp);
this->clampValue(tmp->opt1, 1);
return 0;
}
void MenuDisplay::clampValue(MenuOption *opt, int defclamp)
{
std::vector<MenuRelation *>::iterator iter;
MenuRelation *tmp;
opt->clampValue();
//std::cerr << "(PRE-RELATION CLAMP) Option " << opt->name << " now set to option " << opt->getIntValue() << "=" << opt->getStringValue() << "\n";
iter = this->menuRelations.begin();
while ( iter != this->menuRelations.end() ) {
tmp = *iter;
if ( tmp == NULL || tmp->opt1 == NULL || tmp->opt2 == NULL ) {
iter++;
continue;
}
if ( tmp->opt1->name == opt->name ) {
//std::cerr << "Found relation for " << opt->name << " (" << tmp->opt1 << " = " << tmp->opt2 << ")\n";
opt->clampValue(tmp, defclamp);
}
iter++;
}
//std::cerr << "(POST-RELATION CLAMP) Option " << opt->name << " now set to option " << opt->getIntValue << "=" <<opt->getStringValue() << "\n";
}

97
MenuDisplay.h Executable file
View File

@@ -0,0 +1,97 @@
#ifndef __MENUDISPLAY_H__
#define __MENUDISPLAY_H__
#include "Actor.h"
#include "Common.h"
#include "Display2D.h"
#include <vector>
// TODO: Add the ability to set a MenuOption to display as either text or as a slider for numeric values.
typedef struct MenuRelation;
#define MENU_OPTYPE_CHOICE 0
#define MENU_OPTYPE_RANGE 1
#define MENU_OPTYPE_SUBMENU 2
class MenuOption
{
public:
std::string name;
SDL_Surface *optionImage;
std::vector<std::string> optlist;
int rangeLow;
int rangeHigh;
int rangeStart;
int selected; // doesn't hold info on whether this is selected or not, holds the index of optlist or the range number that is currently selected
int spinFree; // if this is set to 1, then the value is modified on the presence of a key DOWN event, not a key RELEASE.
MenuOption(std::string name, int rangeLow, int rangeHigh, int rangeStart, int spinFree, SDL_Surface *img);
~MenuOption();
void clampValue(MenuRelation *relation = NULL, int defClampVal = 1);
int getIntValue();
std::string getStringValue();
virtual int select(int value); // called by MenuDisplay to force selection to a given item
virtual int whenhighlighted(); // called whenever the menu item is highlighted
virtual int whenselected(); // called whenever the menu item is selected ("enter" is pressed on the item)
virtual int valueup(); // called whenever the value of the item is increased (the range is moved up, or the next sub option is selected)
virtual int valuedown(); // as with valueup(), but works with lower values and previous items
};
#define MENURELATION_NODUPLICATE 0
struct MenuRelation
{
MenuOption *opt1;
MenuOption *opt2;
int relation;
MenuRelation();
};
// class for the menus in the game
// This class dynamically creates actors for the menu options and such
// the only actor you have to feed it is your pointer Animation
class MenuDisplay : public Display2D
{
protected:
std::vector<MenuOption *> menuOptions;
std::vector<MenuRelation *> menuRelations;
std::vector<MenuDisplay *> subMenus;
Actor *pointerActor;
int curOpt;
Vector origin;
SDL_Color textColor;
SDL_Color bgColor;
std::string fontname;
int pointsize;
int spacing;
std::string closeOpt;
Animation *arrowUp;
Animation *arrowDown;
Animation *arrowLeft;
Animation *arrowRight;
public:
MenuDisplay();
~MenuDisplay();
void setCloseOption(std::string option);
void setSpacing(int spacing);
int setPointer(Animation *ptr);
void setMenuOrigin(Vector origin);
void setMenuImages(Animation *arrowLeft, Animation *arrowRight, Animation *arrowUp, Animation *arrowDown);
void setFont(std::string fontname, int pointsize, SDL_Color color, SDL_Color bgcolor);
void update(int logicOnly = 0);
int handleEvent(SDL_Event *event);
void clampValue(MenuOption *opt, int defClamp);
int setRelation(std::string opt1, std::string opt2, int relationType = MENURELATION_NODUPLICATE);
void setOption(std::string optName, std::string );
void setOption(std::string optName, int);
void addOption(MenuOption *mopt);
void addOption(std::string name, int rangeLow, int rangeHigh, int rangeStart, int spinFree, SDL_Surface *img);
int addSubOption(std::string name, std::string subopt);
MenuOption *getOption(std::string name = "");
};
#endif // __MENUDISPLAY_H__

64
Physics.h Executable file
View File

@@ -0,0 +1,64 @@
#ifndef __PHYSICS_H__
#define __PHYSICS_H__
// x = pounds to convert to newtons
#define CALC_CONV_LB2NEWTON(x) ((x)*4.44822162)
// x = ounces to convert to newtons
#define CALC_CONV_OZ2NEWTON(x) (((x)*4.44822162)/16)
// x = kilograms to convert to newtons
#define CALC_CONV_KG2NEWTON(x) ((x)*9.81)
// x = milligrams to convert to newtons
#define CALC_CONV_MG2NEWTON(x) (((x)*9.81)/1000
// W = weight in newtons, g = constant acceleration of gravity
#define CALC_MASSFROMWEIGHT(W, g) ((W)/(g))
// F = Force applied to object, a = acceleration of object
#define CALC_MASSFROMFORCE(F, a) ((F)/(a))
// v = linear velocity of object, r = radius of circular path
#define CALC_ACCEL_CENTRIPETAL(v, r) (((v)*(v))/(r))
// v1 = starting velocity, v2 = ending velocity, t = time elapsed between v1 and v2
#define CALC_ACCEL_VELOCITYDELTA(v1, v2, t) (((v2)-(v1)) / (t))
// F = force applied to object, m = mass of object
#define CALC_ACCEL_FORCE(F, m) ((F)/(m))
// d = distance object has traveled, t = time object has spent in motion
#define CALC_VELOCITY_AVG(d, t) ((d)/(t))
// W = Weight of object, H = Height of object above the ground plane
#define CALC_ENERGY_POTENTIAL(W, H) ((W)*(H))
// m = mass of object, v = velocity of object
#define CALC_ENERGY_KINETIC(m, v) (((m)*(v))/2)
#define PHYSICS_NOPHYSICS 0000000000000000b
#define PHYSICS_FRICTIONLESS 0000000000000001b
#define PHYSICS_NOGRAVITY 0000000000000010b
#define PHYSICS_MATERIAL_LIQUID 0000000000000100b
#define PHYSICS_MATERIAL_GAS 0000000000001000b
#define PHYSICS_MATERIAL_SOLID 0000000000010000b
struct WorldPhysics
{
float gravity;
float airfriction;
}
struct StaticPhysics
{
float friction;
float bouyancy;
int flags;
}
struct ObjectPhysics : public StaticPhysics
{
float mass;
float weight;
float p1; // position 1, used for calculating velocity
float p2; // position 2, "" " " "
float v1; // velocity 1, used for calculation acceleration
float v2; // velocity 2, " " " "
float pe; // potential energy of an object at rest
float ke; // kinetic energy of a moving object
}
#endif

69
Renderable.cpp Executable file
View File

@@ -0,0 +1,69 @@
#include "Renderable.h"
#include <SDL.h>
#include <iostream>
Renderable::Renderable()
{
this->position = (Vector){0,0,0};
this->velocity = (Vector){0,0,0};
}
Vector Renderable::getPosition()
{
return this->position;
}
Vector Renderable::getVelocity()
{
return this->velocity;
}
void Renderable::setPosition(Vector pos)
{
this->position.x = pos.x;
this->position.y = pos.y;
this->position.z = pos.z;
}
void Renderable::setVelocity(Vector vel)
{
this->velocity.x = vel.x;
this->velocity.y = vel.y;
this->velocity.z = vel.z;
}
/**
* @fn Renderable::nextFrame
* @brief Return the next surface that this class is ready to render
* @return SDL_Surface *
*/
SDL_Surface *Renderable::nextFrame()
{
return NULL;
}
AnimatedRenderable::AnimatedRenderable()
{
this->frameCounter.curFrame = 0;
this->frameCounter.lastFrame = NULL;
this->frameCounter.lastTime = 0;
}
FrameCounter AnimatedRenderable::getFrameCounter()
{
return this->frameCounter;
}
/**
* @fn AnimatedRenderable::setFrameCounter
* @brief Force the frame counter to a given FrameCounter value
* @return 0
*/
int AnimatedRenderable::setFrameCounter(FrameCounter fc)
{
////std::cerr << "Updating frame counter\n";
this->frameCounter = fc;
return 0;
}

46
Renderable.h Executable file
View File

@@ -0,0 +1,46 @@
#ifndef __RENDERABLE_H__
#define __RENDERABLE_H__
#include <SDL.h>
#include "Common.h"
/**
* @class Renderable
* @brief A base class for objects that are capable of returning renderable data
*
* This base class provides default mechanisms for an object to return renderable
* data, track position and velocity.
*/
class Renderable
{
protected:
Vector position; /**< The position of the renderable object */
Vector velocity; /**< The velocity (if any) of the renderable object */
public:
Renderable();
Vector getPosition();
Vector getVelocity();
void setPosition(Vector);
void setVelocity(Vector);
virtual SDL_Surface *nextFrame();
};
/**
* @class AnimatedRenderable
* @brief A subclass of Renderable for objects that are renderable and animated
*
* This subclass defines the interface for libgame objects that are both
* Renderable, but that also perform some kind of internal logic to return
* different surfaces each call.
*/
class AnimatedRenderable : public Renderable
{
protected:
FrameCounter frameCounter; /**< Current frame within the current animation */
public:
AnimatedRenderable();
FrameCounter getFrameCounter();
int setFrameCounter(FrameCounter fc);
};
#endif // __RENDERABLE_H__

142
SpriteStrip.cpp Executable file
View File

@@ -0,0 +1,142 @@
#include "Renderable.h"
#include "SpriteStrip.h"
#include <SDL.h>
#include <SDL_image.h>
#include <iostream>
SpriteStrip::SpriteStrip()
{
return;
}
SpriteStrip::~SpriteStrip()
{
this->clearFrames();
}
int SpriteStrip::loadFromFile(std::string filename, int f_w, int f_h, Vector colorkey)
{
SDL_Surface *imgsurf = NULL;
imgsurf = IMG_Load(filename.c_str());
if ( imgsurf != NULL ) {
//std::cerr << "Splitting frames from " << filename.c_str() << " (" << imgsurf->w << "x" << imgsurf->h << "...\n";
return this->loadFromSurface(imgsurf, f_w, f_h, colorkey);
} else {
//std::cerr << "Couldn't load image from file!\n";
return 1;
}
}
// pass 0 in f_w and f_h to return a single frame into the strip that's the size of the image
// pass 0 in just one of them to indicate that each sprite is the entire width or height of
// image
int SpriteStrip::loadFromSurface(SDL_Surface *image, int f_w, int f_h, Vector colorkey)
{
int stripping = 1;
SDL_Surface *newSurf = NULL;
SDL_Rect copyRect = {0, 0, f_w, f_h };
if ( image == NULL )
return 1;
if ( f_w == 0 ) {
f_w = image->w;
copyRect.w = f_w;
}
if ( f_h == 0 ) {
f_h = image->h;
copyRect.h = f_h;
}
while ( stripping == 1) {
newSurf = SDL_CreateRGBSurface(image->flags, f_w, f_h, image->format->BitsPerPixel, 0, 0, 0, 0);
if ( newSurf != NULL ) {
if ( colorkey.x > -1 && colorkey.y > -1 && colorkey.z > -1 ) {
////std::cerr << "Setting color key\n";
SDL_SetColorKey(newSurf, SDL_SRCCOLORKEY,
SDL_MapRGB(newSurf->format,
(Uint8) colorkey.x,
(Uint8) colorkey.y,
(Uint8) colorkey.z));
}
//std::cout << "Blitting new surface (" << copyRect.w << "x" << copyRect.h << " (src : " << copyRect.x << "," << copyRect.y << ")\n";
if ( SDL_BlitSurface(image, &copyRect, newSurf, NULL) == 0 ) {
this->frames.push_back(newSurf);
newSurf = NULL;
} else {
//std::cerr << "Unable to blit from sprite sheet to sprite element.\n";
exit(1);
}
if ( copyRect.x + (f_w*2) > image->w ) {
copyRect.x = 0;
copyRect.y += f_h;
// overflowing image?
if ( copyRect.y >= image->h ){
stripping = 0;
continue;
}
} else {
copyRect.x += f_w;
}
} else {
//std::cerr << "Unable to allocate memory for sprite strip element.\n";
exit(1);
}
}
//std::cout << "Split " << this->frames.size() << " frames into new sprite strip\n";
return 0;
}
SDL_Surface *SpriteStrip::getFrame(unsigned int frame)
{
if ( frame < this->frames.size() ) {
return this->frames.at(frame);
} else {
////std::cerr << "Attempt to access beyond end of sprite strip (" << frame << " of " << this->frames.size() << ") on strip " << this << "\n";
return NULL;
}
}
int SpriteStrip::width()
{
if ( this->frames.size() > 0 ) {
return this->frames.at(0)->w;
}
return 0;
}
int SpriteStrip::height()
{
if ( this->frames.size() > 0 ) {
return this->frames.at(0)->h;
}
return 0;
}
void SpriteStrip::clearFrames()
{
std::vector<SDL_Surface *>::iterator iter;
while ( this->frames.size() > 0 ) {
iter = this->frames.end();
if ( *iter != NULL ) {
SDL_FreeSurface(*iter);
this->frames.erase(iter);
}
}
}
int SpriteStrip::numFrames()
{
if ( this == NULL ) {
//std::cerr << "SpriteStrip::numFrames got passed a NULL this-> pointer. How the FUCK did that happen?!\n";
return 0;
}
return this->frames.size();
}
SpriteStripIter SpriteStrip::iterator()
{
return (SpriteStripIter)this->frames.begin();
}

32
SpriteStrip.h Executable file
View File

@@ -0,0 +1,32 @@
#ifndef __SPRITESTRIP_H__
#define __SPRITESTRIP_H__
#include <SDL.h>
#include <vector>
#include <string>
#include <map>
#include "Renderable.h"
typedef std::vector<SDL_Surface *>::iterator SpriteStripIter;
class SpriteStrip
{
private:
std::vector<SDL_Surface *> frames;
public:
SpriteStrip();
~SpriteStrip();
int width();
int height();
int loadFromFile(std::string filename, int f_w = 0, int f_h = 0, Vector colorkey = (Vector){-1,-1,-1});
int loadFromSurface(SDL_Surface *image, int f_w = 0, int f_h = 0, Vector colorkey = (Vector){-1,-1,-1});
void clearFrames();
SDL_Surface *getFrame(unsigned int frame);
int numFrames();
SpriteStripIter iterator();
};
typedef std::map<std::string, SpriteStrip *> SpriteStripMap;
#endif // #ifndef __SPRITESTRIP_H__

32
TileSet.cpp Executable file
View File

@@ -0,0 +1,32 @@
#include "Display2D.h"
#include "TileSet.h"
#include <libxml/xmlreader.h>
#include <cstdlib>
int TileDisplay::loadFromTMX(std::string filename)
{
xmlTextReaderPtr reader;
const xmlChar *name;
const xmlChar *value;
int ret;
reader = xmlReaderForFile(filename.c_str(), NULL, 0);
if ( reader != NULL ) {
ret = xmlTextReaderRead(reader);
while ( ret == 1) {
name = xmlTextReaderConstName(reader);
if ( name != NULL ) {
if ( !strcmp(name, "map") ) {
}
value = xmlTextReaderConstValue(reader);
}
// process current node
}
xmlFreeTextReader(reader);
if ( ret == 0 ) {
return 1;
}
}
return 0;
}

37
TileSet.h Executable file
View File

@@ -0,0 +1,37 @@
#ifndef __TILESET_H__
#define __TILESET_H__
#include <SDL.h>
#include "Display2D.h"
#define TILEMAP_ORTHOGONAL 1
#define TILEMAP_ISOMETRIC 2
typedef std::map<int, SDL_Surface *> TileSet;
struct TileSetDef {
int start_id;
std::string name;
TileSet *tiles;
}
typedef std::vector<TileSetDef *> TileGroup;
typedef std::vector<int> TileLayer;
class TileDisplay : public Display2D {
protected:
TileGroup tilegroup;
std::vector<int>[MAX_LAYERS] layers;
int w;
int h;
int tw;
int th;
public:
int loadFromTMX(std::string filename);
void clearTiles();
void scroll(int x, int y);
void autoScroll(int x, int y);
void update();
}
#endif // __TILESET_H__

78
demo/bouncingball/Makefile Executable file
View File

@@ -0,0 +1,78 @@
# This makefile is a bit hackish. I wrote it early in the AM.
# Fohgiveuhness, please!!
ifndef $(CFG)
CFG=Debug
endif
# you can also pass : mingw32 and macosx
ifndef $(OS)
OS=linux
endif
TARGET=demo
BINTARGET=$(TARGET)
PROJECTHOME=$(shell pwd)
SDL_CFLAGS=$(shell sdl-config --cflags)
SDL_LDFLAGS=$(shell sdl-config --libs)
LIBDIR=/usr/lib
HEADERDIR=/usr/include
ADDL_CFLAGS=
ifeq "$(OS)" "mingw32"
ADDL_CFLAGS=-mwindows -DBUILD_MINGW32
endif
ifeq "$(OS)" "linux"
ADDL_CFLAGS=-DBUILD_LINUX
endif
# default for release configs
ifeq "$(CFG)" "Release"
OUTDIR=Release
ifeq "$(OS)" "mingw32"
BINTARGET=$(TARGET).exe
else
BINTARGET=$(TARGET)
endif
LINKLIB=game
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
ifeq "$(CFG)" "Debug"
OUTDIR=Debug
ifeq "$(OS)" "mingw32"
BINTARGET=$(TARGET)-dbg.exe
else
BINTARGET=$(TARGET)-dbg
endif
LINKLIB=game-dbg
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
LINKLIBS=-L../../$(CFG) -L$(LIBDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer -lSDL_gfx -lSDL_ttf
BINOBJ=$(OUTDIR)/demo.o
CC = gcc
CXX = g++
LD = $(CXX)
INSTALL = $(which install)
$(OUTDIR)/%.o : cpp/%.cpp
$(CXX) $(CXXFLAGS) -o $@ $<
all: bin
bin: $(BINOBJ)
$(LD) -pg -o $(OUTDIR)/$(BINTARGET) \
-pg $(BINOBJ) $(LINKLIBS)
.PHONY: clean
clean:
rm -f $(OUTDIR)/*.o
rm -f $(OUTDIR)/$(BINTARGET)
.PHONY: rebuild
rebuild:
make clean
make CFG=$(CFG)

BIN
demo/bouncingball/Release/demo Executable file

Binary file not shown.

Binary file not shown.

BIN
demo/bouncingball/ball.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

65
demo/bouncingball/cpp/demo.cpp Executable file
View File

@@ -0,0 +1,65 @@
/*
* This demo just expands on the 'gravity' demo to show how one could create a primitive bouncing effect
*/
#include <libgame/libgame.h>
int main(int argc, char *argv[])
{
Display2D display = Display2D();
Game &myGame = Game::NewSingleton();
Animation *anim = NULL;
Actor ball;
SpriteStrip *strip = NULL;
float gravity = 0.1;
unsigned int lastTimer = 0;
Vector actorPos;
Vector actorVel;
myGame.initSDL();
myGame.initVideo(640, 480, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
display.initVideo((Vector){0,0,0}, 640, 480, 32, SDL_HWSURFACE);
display.setActive(1);
myGame.windows.push_back(&display);
strip = myGame.newSpriteStrip("ball");
strip->loadFromFile("ball.png", 32, 32, (Vector){0,0,0});
anim = myGame.newAnimation("ball");
anim->setStrip(strip, 0, 0, (Vector){0,0,0});
ball.addAnimation(anim, STATE_DEFAULT);
ball.setState(STATE_MOVERIGHT | STATE_MOVEUP);
ball.setPosition((Vector){0,400,0});
ball.setVelocity((Vector){.25, 1.5, 0});
display.addActor(&ball, LAYER_SPRITE1);
lastTimer = SDL_GetTicks();
while ( 1 ) {
actorPos = ball.getPosition();
actorVel = ball.getVelocity();
/* this is what does the bounce */
if ( actorPos.y > (480 - ball.nextFrame()->h) ) {
actorVel.y = -(actorVel.y);
actorPos.y = (480 - ball.nextFrame()->h);
ball.setPosition(actorPos);
}
// -- end of bouncing
if ( actorPos.x >= 640 ) {
break;
}
if ( (SDL_GetTicks() - lastTimer) >= (1000/30) ) {
myGame.update();
actorVel.y -= gravity;
ball.setVelocity(actorVel);
lastTimer = SDL_GetTicks();
} else {
myGame.update(1);
}
if ( myGame.keyHeldDown(SDLK_ESCAPE) ) {
break;
}
myGame.finishFrame();
}
}

BIN
demo/bouncingball/gmon.out Executable file

Binary file not shown.

277
demo/bouncingball/log.txt Executable file
View File

@@ -0,0 +1,277 @@
ALSA lib pcm_dmix.c:874:(snd_pcm_dmix_open) unable to open slave
Current time 35 last timer 30
Moving ball down by 0.001 (0) units
Now at 0 0
Current time 40 last timer 30
Moving ball down by 0.002 (0) units
Now at 0 0
Current time 51 last timer 30
Moving ball down by 0.0042 (0) units
Now at 0 0
Current time 58 last timer 30
Moving ball down by 0.0056 (0) units
Now at 0 0
Current time 61 last timer 30
Moving ball down by 0.0062 (0) units
Now at 0 0
Current time 64 last timer 30
Moving ball down by 0.0068 (0) units
Now at 0 0
Current time 74 last timer 30
Moving ball down by 0.0088 (0) units
Now at 0 0
Current time 82 last timer 30
Moving ball down by 0.0104 (0) units
Now at 0 0
Current time 91 last timer 30
Moving ball down by 0.0122 (0) units
Now at 0 0
Current time 100 last timer 30
Moving ball down by 0.014 (0) units
Now at 0 0
Current time 112 last timer 30
Moving ball down by 0.0164 (0) units
Now at 0 0
Current time 121 last timer 30
Moving ball down by 0.0182 (0) units
Now at 0 0
Current time 131 last timer 30
Moving ball down by 0.0202 (0) units
Now at 0 0
Current time 141 last timer 30
Moving ball down by 0.0222 (0) units
Now at 0 0
Current time 150 last timer 30
Moving ball down by 0.024 (0) units
Now at 0 0
Current time 159 last timer 30
Moving ball down by 0.0258 (0) units
Now at 0 0
Current time 169 last timer 30
Moving ball down by 0.0278 (0) units
Now at 0 0
Current time 177 last timer 30
Moving ball down by 0.0294 (0) units
Now at 0 0
Current time 188 last timer 30
Moving ball down by 0.0316 (0) units
Now at 0 0
Current time 197 last timer 30
Moving ball down by 0.0334 (0) units
Now at 0 0
Current time 207 last timer 30
Moving ball down by 0.0354 (0) units
Now at 0 0
Current time 215 last timer 30
Moving ball down by 0.037 (0) units
Now at 0 0
Current time 224 last timer 30
Moving ball down by 0.0388 (0) units
Now at 0 0
Current time 234 last timer 30
Moving ball down by 0.0408 (0) units
Now at 0 0
Current time 243 last timer 30
Moving ball down by 0.0426 (0) units
Now at 0 0
Current time 251 last timer 30
Moving ball down by 0.0442 (0) units
Now at 0 0
Current time 260 last timer 30
Moving ball down by 0.046 (0) units
Now at 0 0
Current time 268 last timer 30
Moving ball down by 0.0476 (0) units
Now at 0 0
Current time 277 last timer 30
Moving ball down by 0.0494 (0) units
Now at 0 0
Current time 286 last timer 30
Moving ball down by 0.0512 (0) units
Now at 0 0
Current time 295 last timer 30
Moving ball down by 0.053 (0) units
Now at 0 0
Current time 307 last timer 30
Moving ball down by 0.0554 (0) units
Now at 0 0
Current time 316 last timer 30
Moving ball down by 0.0572 (0) units
Now at 0 0
Current time 325 last timer 30
Moving ball down by 0.059 (0) units
Now at 0 0
Current time 333 last timer 30
Moving ball down by 0.0606 (0) units
Now at 0 0
Current time 343 last timer 30
Moving ball down by 0.0626 (0) units
Now at 0 0
Current time 351 last timer 30
Moving ball down by 0.0642 (0) units
Now at 0 0
Current time 360 last timer 30
Moving ball down by 0.066 (0) units
Now at 0 0
Current time 369 last timer 30
Moving ball down by 0.0678 (0) units
Now at 0 0
Current time 377 last timer 30
Moving ball down by 0.0694 (0) units
Now at 0 0
Current time 386 last timer 30
Moving ball down by 0.0712 (0) units
Now at 0 0
Current time 399 last timer 30
Moving ball down by 0.0738 (0) units
Now at 0 0
Current time 408 last timer 30
Moving ball down by 0.0758 (0) units
Now at 0 0
Current time 422 last timer 30
Moving ball down by 0.0784 (0) units
Now at 0 0
Current time 431 last timer 30
Moving ball down by 0.0802 (0) units
Now at 0 0
Current time 440 last timer 30
Moving ball down by 0.082 (0) units
Now at 0 0
Current time 449 last timer 30
Moving ball down by 0.0838 (0) units
Now at 0 0
Current time 457 last timer 30
Moving ball down by 0.0854 (0) units
Now at 0 0
Current time 468 last timer 30
Moving ball down by 0.0876 (0) units
Now at 0 0
Current time 478 last timer 30
Moving ball down by 0.0896 (0) units
Now at 0 0
Current time 487 last timer 30
Moving ball down by 0.0914 (0) units
Now at 0 0
Current time 496 last timer 30
Moving ball down by 0.0932 (0) units
Now at 0 0
Current time 506 last timer 30
Moving ball down by 0.0954 (0) units
Now at 0 0
Current time 516 last timer 30
Moving ball down by 0.0972 (0) units
Now at 0 0
Current time 525 last timer 30
Moving ball down by 0.099 (0) units
Now at 0 0
Current time 533 last timer 30
Moving ball down by 0.1006 (0) units
Now at 0 0
Current time 545 last timer 30
Moving ball down by 0.103 (0) units
Now at 0 0
Current time 555 last timer 30
Moving ball down by 0.105 (0) units
Now at 0 0
Current time 565 last timer 30
Moving ball down by 0.107 (0) units
Now at 0 0
Current time 575 last timer 30
Moving ball down by 0.109 (0) units
Now at 0 0
Current time 586 last timer 30
Moving ball down by 0.1112 (0) units
Now at 0 0
Current time 595 last timer 30
Moving ball down by 0.113 (0) units
Now at 0 0
Current time 607 last timer 30
Moving ball down by 0.1154 (0) units
Now at 0 0
Current time 616 last timer 30
Moving ball down by 0.1172 (0) units
Now at 0 0
Current time 625 last timer 30
Moving ball down by 0.119 (0) units
Now at 0 0
Current time 633 last timer 30
Moving ball down by 0.1206 (0) units
Now at 0 0
Current time 643 last timer 30
Moving ball down by 0.1226 (0) units
Now at 0 0
Current time 651 last timer 30
Moving ball down by 0.1244 (0) units
Now at 0 0
Current time 660 last timer 30
Moving ball down by 0.126 (0) units
Now at 0 0
Current time 669 last timer 30
Moving ball down by 0.128 (0) units
Now at 0 0
Current time 678 last timer 30
Moving ball down by 0.1296 (0) units
Now at 0 0
Current time 687 last timer 30
Moving ball down by 0.1314 (0) units
Now at 0 0
Current time 698 last timer 30
Moving ball down by 0.1336 (0) units
Now at 0 0
Current time 707 last timer 30
Moving ball down by 0.1354 (0) units
Now at 0 0
Current time 718 last timer 30
Moving ball down by 0.1376 (0) units
Now at 0 0
Current time 727 last timer 30
Moving ball down by 0.1394 (0) units
Now at 0 0
Current time 737 last timer 30
Moving ball down by 0.1414 (0) units
Now at 0 0
Current time 748 last timer 30
Moving ball down by 0.1436 (0) units
Now at 0 0
Current time 757 last timer 30
Moving ball down by 0.1454 (0) units
Now at 0 0
Current time 765 last timer 30
Moving ball down by 0.147 (0) units
Now at 0 0
Current time 774 last timer 30
Moving ball down by 0.1488 (0) units
Now at 0 0
Current time 785 last timer 30
Moving ball down by 0.151 (0) units
Now at 0 0
Current time 796 last timer 30
Moving ball down by 0.1532 (0) units
Now at 0 0
Current time 806 last timer 30
Moving ball down by 0.1552 (0) units
Now at 0 0
Current time 816 last timer 30
Moving ball down by 0.1572 (0) units
Now at 0 0
Current time 825 last timer 30
Moving ball down by 0.159 (0) units
Now at 0 0
Current time 833 last timer 30
Moving ball down by 0.161 (0) units
Now at 0 0
Current time 847 last timer 30
Moving ball down by 0.1634 (0) units
Now at 0 0
Current time 855 last timer 30
Moving ball down by 0.165 (0) units
Now at 0 0
Current time 865 last timer 30
Moving ball down by 0.167 (0) units
Now at 0 0
Current time 874 last timer 30
Moving ball down by 0.1688 (0) units
Now at 0 0
Current time 883 last timer 30
Moving ball down by 0.1708 (0) units
Now at 0 0

25
demo/build-demos.sh Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
BUILTOK=""
BUILTFAIL=""
for dir in $(find . -maxdepth 1 -type d | grep -v "\.$" );
do
echo "Making in $dir "
cd $dir
make CFG=$1 $2
if [ $? -eq 0 ]; then
BUILTOK="$(echo $BUILTOK $dir)"
else
BUILTFAIL="$(echo $BUILTFAIL $dir)"
fi
cd ..
done
echo
echo
echo "OK : $BUILTOK"
echo
echo "FAIL : $BUILTFAIL"

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

78
demo/exploder/Makefile Executable file
View File

@@ -0,0 +1,78 @@
# This makefile is a bit hackish. I wrote it early in the AM.
# Fohgiveuhness, please!!
ifndef $(CFG)
CFG=Debug
endif
# you can also pass : mingw32 and macosx
ifndef $(OS)
OS=linux
endif
TARGET=demo
BINTARGET=$(TARGET)
PROJECTHOME=$(shell pwd)
SDL_CFLAGS=$(shell sdl-config --cflags)
SDL_LDFLAGS=$(shell sdl-config --libs)
LIBDIR=/usr/lib
HEADERDIR=/usr/include
ADDL_CFLAGS=
ifeq "$(OS)" "mingw32"
ADDL_CFLAGS=-mwindows -DBUILD_MINGW32
endif
ifeq "$(OS)" "linux"
ADDL_CFLAGS=-DBUILD_LINUX
endif
# default for release configs
ifeq "$(CFG)" "Release"
OUTDIR=Release
ifeq "$(OS)" "mingw32"
BINTARGET=$(TARGET).exe
else
BINTARGET=$(TARGET)
endif
LINKLIB=game
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
ifeq "$(CFG)" "Debug"
OUTDIR=Debug
ifeq "$(OS)" "mingw32"
BINTARGET=$(TARGET)-dbg.exe
else
BINTARGET=$(TARGET)-dbg
endif
LINKLIB=game-dbg
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
LINKLIBS=-L../../$(CFG) -L$(LIBDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer -lSDL_gfx -lSDL_ttf
BINOBJ=$(OUTDIR)/demo.o
CC = gcc
CXX = g++
LD = $(CXX)
INSTALL = $(which install)
$(OUTDIR)/%.o : cpp/%.cpp
$(CXX) $(CXXFLAGS) -o $@ $<
all: bin
bin: $(BINOBJ)
$(LD) -pg -o $(OUTDIR)/$(BINTARGET) \
-pg $(BINOBJ) $(LINKLIBS)
.PHONY: clean
clean:
rm -f $(OUTDIR)/*.o
rm -f $(OUTDIR)/$(BINTARGET)
.PHONY: rebuild
rebuild:
make clean
make CFG=$(CFG)

BIN
demo/exploder/Release/demo Executable file

Binary file not shown.

BIN
demo/exploder/Release/demo.exe Executable file

Binary file not shown.

33
demo/exploder/cpp/demo.cpp Executable file
View File

@@ -0,0 +1,33 @@
#include <libgame/libgame.h>
int main(int argc, char *argv[])
{
Display2D display = Display2D();
Game &myGame = Game::NewSingleton();
Animation *anim = NULL;
Actor exploder;
SpriteStrip *strip = NULL;
myGame.initSDL();
myGame.initVideo(640, 480, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
display.initVideo((Vector){0,0,0}, 640, 480, 32, SDL_HWSURFACE);
display.setActive(1);
myGame.windows.push_back(&display);
strip = myGame.newSpriteStrip("explosion");
strip->loadFromFile("explosion.png", 110, 110, (Vector){0,0,0});
anim = myGame.newAnimation("explosion");
anim->setStrip(strip, 12, 0, (Vector){0,0,0});
exploder.addAnimation(anim, STATE_DEFAULT);
exploder.setState(STATE_NONE);
display.addActor(&exploder, LAYER_SPRITE1);
while ( 1 ) {
myGame.update();
if ( myGame.keyHeldDown(SDLK_ESCAPE) ) {
break;
}
myGame.finishFrame();
}
}

BIN
demo/exploder/explosion.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
demo/exploder/gmon.out Executable file

Binary file not shown.

12157
demo/explodingball/Debug/stderr.txt Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
Split 1 frames into new sprite strip
Split 10 frames into new sprite strip

78
demo/explodingball/Makefile Executable file
View File

@@ -0,0 +1,78 @@
# This makefile is a bit hackish. I wrote it early in the AM.
# Fohgiveuhness, please!!
ifndef $(CFG)
CFG=Debug
endif
# you can also pass : mingw32 and macosx
ifndef $(OS)
OS=linux
endif
TARGET=demo
BINTARGET=$(TARGET)
PROJECTHOME=$(shell pwd)
SDL_CFLAGS=$(shell sdl-config --cflags)
SDL_LDFLAGS=$(shell sdl-config --libs)
LIBDIR=/usr/lib
HEADERDIR=/usr/include
ADDL_CFLAGS=
ifeq "$(OS)" "mingw32"
ADDL_CFLAGS=-mwindows -DBUILD_MINGW32
endif
ifeq "$(OS)" "linux"
ADDL_CFLAGS=-DBUILD_LINUX
endif
# default for release configs
ifeq "$(CFG)" "Release"
OUTDIR=Release
ifeq "$(OS)" "mingw32"
BINTARGET=$(TARGET).exe
else
BINTARGET=$(TARGET)
endif
LINKLIB=game
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
ifeq "$(CFG)" "Debug"
OUTDIR=Debug
ifeq "$(OS)" "mingw32"
BINTARGET=$(TARGET)-dbg.exe
else
BINTARGET=$(TARGET)-dbg
endif
LINKLIB=game-dbg
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
LINKLIBS=-L../../$(CFG) -L$(LIBDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer -lSDL_gfx -lSDL_ttf
BINOBJ=$(OUTDIR)/demo.o
CC = gcc
CXX = g++
LD = $(CXX)
INSTALL = $(which install)
$(OUTDIR)/%.o : cpp/%.cpp
$(CXX) $(CXXFLAGS) -o $@ $<
all: bin
bin: $(BINOBJ)
$(LD) -pg -o $(OUTDIR)/$(BINTARGET) \
-pg $(BINOBJ) $(LINKLIBS)
.PHONY: clean
clean:
rm -f $(OUTDIR)/*.o
rm -f $(OUTDIR)/$(BINTARGET)
.PHONY: rebuild
rebuild:
make clean
make CFG=$(CFG)

BIN
demo/explodingball/Release/demo Executable file

Binary file not shown.

Binary file not shown.

BIN
demo/explodingball/ball.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

100
demo/explodingball/cpp/demo.cpp Executable file
View File

@@ -0,0 +1,100 @@
/*
* This demo expands on the frictionball demo. It shows how to create objects dynamically, by
* creating an explosion every time the ball touches the ground
*/
#include <libgame/libgame.h>
#include <string>
int main(int argc, char *argv[])
{
Display2D display = Display2D();
Game &myGame = Game::NewSingleton();
Actor ball;
Actor *exploder = NULL;
float gravity = 0.1;
//int exploderCount = 0;
unsigned int lastTimer = 0;
Vector actorPos;
Vector actorVel;
myGame.initSDL();
myGame.initVideo(640, 480, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
display.initVideo((Vector){0,0,0}, 640, 480, 32, SDL_HWSURFACE);
display.setActive(1);
myGame.windows.push_back(&display);
// this stuff is a bit more terse now just to save space
myGame.newSpriteStrip("ball")->loadFromFile("ball.png", 32, 32, (Vector){0,0,0});
myGame.newAnimation("ball")->setStrip(myGame.getSpriteStrip("ball"), 0, 0, (Vector){0,0,0});
// create the new animation for the explosion
myGame.newSpriteStrip("explosion")->loadFromFile("explosion.png", 110, 110, (Vector){0,0,0});
myGame.newAnimation("explosion")->setStrip(myGame.getSpriteStrip("explosion"), 12, 0, (Vector){0,0,0});
ball.addAnimation(myGame.getAnimation("ball"), STATE_DEFAULT);
ball.setState(STATE_MOVERIGHT | STATE_MOVEUP);
ball.setPosition((Vector){0,400,0});
ball.setVelocity((Vector){.25, 1.5, 0});
display.addActor(&ball, LAYER_SPRITE1);
lastTimer = SDL_GetTicks();
while ( 1 ) {
actorPos = ball.getPosition();
actorVel = ball.getVelocity();
/* this is what does the bounce */
if ( actorPos.y > (480 - ball.nextFrame()->h) && (actorVel.y != 0 ) ) {
// if the velocity is low enough, then we just stop the ball so that it will roll
// smoothly along the floor of the window
if ( actorVel.y < .25 && actorVel.y > -.25 ) {
//std::cerr << "STOPPING BALL\n";
actorVel.y = 0;
ball.setState(STATE_NONE);
} else {
// if the velocity is still significant, then we reverse it to create the bounce
// but since real balls don't bounce quite as high as they did initially, when dropped
// so we do a primitive modification of the velocity to inroduce something similar to
// friction physics (see the "physics" demos for ACTUAL physics)
// The friction numbers here are arbitrary, and were used because they made sense in the
// demo, you can change the friction for some pretty different effects.
actorVel.y = -(actorVel.y) - .25;
// this is friction applied to the X axis to stop the ball's movement eventually
if ( actorVel.x < .01 && actorVel.x > -.01 ) {
actorVel.x = 0;
} else {
actorVel.x -= .025;
}
}
exploder = myGame.newActor();
exploder->addAnimation(myGame.getAnimation("explosion"), STATE_DYING);
exploder->setState(STATE_DYING);
exploder->setPosition(actorPos);
display.addActor(exploder, LAYER_SPRITE2);
actorPos.y = (480 - ball.nextFrame()->h);
ball.setPosition(actorPos);
}
// -- end of bouncing
if ( actorPos.x >= 640 ) {
break;
}
if ( (SDL_GetTicks() - lastTimer) >= (1000/30) ) {
myGame.update();
if ( ball.hasState(STATE_MOVEUP) ) {
actorVel.y -= gravity;
}
//std::cerr << "Velocity Y " << actorVel.y << "\n";
ball.setVelocity(actorVel);
lastTimer = SDL_GetTicks();
} else {
myGame.update(1);
}
if ( myGame.keyHeldDown(SDLK_ESCAPE) ) {
break;
}
myGame.finishFrame();
}
return 0;
}

BIN
demo/explodingball/explosion.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
demo/explodingball/gmon.out Executable file

Binary file not shown.

277
demo/explodingball/log.txt Executable file
View File

@@ -0,0 +1,277 @@
ALSA lib pcm_dmix.c:874:(snd_pcm_dmix_open) unable to open slave
Current time 35 last timer 30
Moving ball down by 0.001 (0) units
Now at 0 0
Current time 40 last timer 30
Moving ball down by 0.002 (0) units
Now at 0 0
Current time 51 last timer 30
Moving ball down by 0.0042 (0) units
Now at 0 0
Current time 58 last timer 30
Moving ball down by 0.0056 (0) units
Now at 0 0
Current time 61 last timer 30
Moving ball down by 0.0062 (0) units
Now at 0 0
Current time 64 last timer 30
Moving ball down by 0.0068 (0) units
Now at 0 0
Current time 74 last timer 30
Moving ball down by 0.0088 (0) units
Now at 0 0
Current time 82 last timer 30
Moving ball down by 0.0104 (0) units
Now at 0 0
Current time 91 last timer 30
Moving ball down by 0.0122 (0) units
Now at 0 0
Current time 100 last timer 30
Moving ball down by 0.014 (0) units
Now at 0 0
Current time 112 last timer 30
Moving ball down by 0.0164 (0) units
Now at 0 0
Current time 121 last timer 30
Moving ball down by 0.0182 (0) units
Now at 0 0
Current time 131 last timer 30
Moving ball down by 0.0202 (0) units
Now at 0 0
Current time 141 last timer 30
Moving ball down by 0.0222 (0) units
Now at 0 0
Current time 150 last timer 30
Moving ball down by 0.024 (0) units
Now at 0 0
Current time 159 last timer 30
Moving ball down by 0.0258 (0) units
Now at 0 0
Current time 169 last timer 30
Moving ball down by 0.0278 (0) units
Now at 0 0
Current time 177 last timer 30
Moving ball down by 0.0294 (0) units
Now at 0 0
Current time 188 last timer 30
Moving ball down by 0.0316 (0) units
Now at 0 0
Current time 197 last timer 30
Moving ball down by 0.0334 (0) units
Now at 0 0
Current time 207 last timer 30
Moving ball down by 0.0354 (0) units
Now at 0 0
Current time 215 last timer 30
Moving ball down by 0.037 (0) units
Now at 0 0
Current time 224 last timer 30
Moving ball down by 0.0388 (0) units
Now at 0 0
Current time 234 last timer 30
Moving ball down by 0.0408 (0) units
Now at 0 0
Current time 243 last timer 30
Moving ball down by 0.0426 (0) units
Now at 0 0
Current time 251 last timer 30
Moving ball down by 0.0442 (0) units
Now at 0 0
Current time 260 last timer 30
Moving ball down by 0.046 (0) units
Now at 0 0
Current time 268 last timer 30
Moving ball down by 0.0476 (0) units
Now at 0 0
Current time 277 last timer 30
Moving ball down by 0.0494 (0) units
Now at 0 0
Current time 286 last timer 30
Moving ball down by 0.0512 (0) units
Now at 0 0
Current time 295 last timer 30
Moving ball down by 0.053 (0) units
Now at 0 0
Current time 307 last timer 30
Moving ball down by 0.0554 (0) units
Now at 0 0
Current time 316 last timer 30
Moving ball down by 0.0572 (0) units
Now at 0 0
Current time 325 last timer 30
Moving ball down by 0.059 (0) units
Now at 0 0
Current time 333 last timer 30
Moving ball down by 0.0606 (0) units
Now at 0 0
Current time 343 last timer 30
Moving ball down by 0.0626 (0) units
Now at 0 0
Current time 351 last timer 30
Moving ball down by 0.0642 (0) units
Now at 0 0
Current time 360 last timer 30
Moving ball down by 0.066 (0) units
Now at 0 0
Current time 369 last timer 30
Moving ball down by 0.0678 (0) units
Now at 0 0
Current time 377 last timer 30
Moving ball down by 0.0694 (0) units
Now at 0 0
Current time 386 last timer 30
Moving ball down by 0.0712 (0) units
Now at 0 0
Current time 399 last timer 30
Moving ball down by 0.0738 (0) units
Now at 0 0
Current time 408 last timer 30
Moving ball down by 0.0758 (0) units
Now at 0 0
Current time 422 last timer 30
Moving ball down by 0.0784 (0) units
Now at 0 0
Current time 431 last timer 30
Moving ball down by 0.0802 (0) units
Now at 0 0
Current time 440 last timer 30
Moving ball down by 0.082 (0) units
Now at 0 0
Current time 449 last timer 30
Moving ball down by 0.0838 (0) units
Now at 0 0
Current time 457 last timer 30
Moving ball down by 0.0854 (0) units
Now at 0 0
Current time 468 last timer 30
Moving ball down by 0.0876 (0) units
Now at 0 0
Current time 478 last timer 30
Moving ball down by 0.0896 (0) units
Now at 0 0
Current time 487 last timer 30
Moving ball down by 0.0914 (0) units
Now at 0 0
Current time 496 last timer 30
Moving ball down by 0.0932 (0) units
Now at 0 0
Current time 506 last timer 30
Moving ball down by 0.0954 (0) units
Now at 0 0
Current time 516 last timer 30
Moving ball down by 0.0972 (0) units
Now at 0 0
Current time 525 last timer 30
Moving ball down by 0.099 (0) units
Now at 0 0
Current time 533 last timer 30
Moving ball down by 0.1006 (0) units
Now at 0 0
Current time 545 last timer 30
Moving ball down by 0.103 (0) units
Now at 0 0
Current time 555 last timer 30
Moving ball down by 0.105 (0) units
Now at 0 0
Current time 565 last timer 30
Moving ball down by 0.107 (0) units
Now at 0 0
Current time 575 last timer 30
Moving ball down by 0.109 (0) units
Now at 0 0
Current time 586 last timer 30
Moving ball down by 0.1112 (0) units
Now at 0 0
Current time 595 last timer 30
Moving ball down by 0.113 (0) units
Now at 0 0
Current time 607 last timer 30
Moving ball down by 0.1154 (0) units
Now at 0 0
Current time 616 last timer 30
Moving ball down by 0.1172 (0) units
Now at 0 0
Current time 625 last timer 30
Moving ball down by 0.119 (0) units
Now at 0 0
Current time 633 last timer 30
Moving ball down by 0.1206 (0) units
Now at 0 0
Current time 643 last timer 30
Moving ball down by 0.1226 (0) units
Now at 0 0
Current time 651 last timer 30
Moving ball down by 0.1244 (0) units
Now at 0 0
Current time 660 last timer 30
Moving ball down by 0.126 (0) units
Now at 0 0
Current time 669 last timer 30
Moving ball down by 0.128 (0) units
Now at 0 0
Current time 678 last timer 30
Moving ball down by 0.1296 (0) units
Now at 0 0
Current time 687 last timer 30
Moving ball down by 0.1314 (0) units
Now at 0 0
Current time 698 last timer 30
Moving ball down by 0.1336 (0) units
Now at 0 0
Current time 707 last timer 30
Moving ball down by 0.1354 (0) units
Now at 0 0
Current time 718 last timer 30
Moving ball down by 0.1376 (0) units
Now at 0 0
Current time 727 last timer 30
Moving ball down by 0.1394 (0) units
Now at 0 0
Current time 737 last timer 30
Moving ball down by 0.1414 (0) units
Now at 0 0
Current time 748 last timer 30
Moving ball down by 0.1436 (0) units
Now at 0 0
Current time 757 last timer 30
Moving ball down by 0.1454 (0) units
Now at 0 0
Current time 765 last timer 30
Moving ball down by 0.147 (0) units
Now at 0 0
Current time 774 last timer 30
Moving ball down by 0.1488 (0) units
Now at 0 0
Current time 785 last timer 30
Moving ball down by 0.151 (0) units
Now at 0 0
Current time 796 last timer 30
Moving ball down by 0.1532 (0) units
Now at 0 0
Current time 806 last timer 30
Moving ball down by 0.1552 (0) units
Now at 0 0
Current time 816 last timer 30
Moving ball down by 0.1572 (0) units
Now at 0 0
Current time 825 last timer 30
Moving ball down by 0.159 (0) units
Now at 0 0
Current time 833 last timer 30
Moving ball down by 0.161 (0) units
Now at 0 0
Current time 847 last timer 30
Moving ball down by 0.1634 (0) units
Now at 0 0
Current time 855 last timer 30
Moving ball down by 0.165 (0) units
Now at 0 0
Current time 865 last timer 30
Moving ball down by 0.167 (0) units
Now at 0 0
Current time 874 last timer 30
Moving ball down by 0.1688 (0) units
Now at 0 0
Current time 883 last timer 30
Moving ball down by 0.1708 (0) units
Now at 0 0

View File

@@ -0,0 +1,787 @@
Splitting frames from ball.png (32x32...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0x3d4218 to main canvas 0x3d42c8(0,0)...

View File

@@ -0,0 +1 @@
Split 1 frames into new sprite strip

78
demo/frictionball/Makefile Executable file
View File

@@ -0,0 +1,78 @@
# This makefile is a bit hackish. I wrote it early in the AM.
# Fohgiveuhness, please!!
ifndef $(CFG)
CFG=Debug
endif
# you can also pass : mingw32 and macosx
ifndef $(OS)
OS=linux
endif
TARGET=demo
BINTARGET=$(TARGET)
PROJECTHOME=$(shell pwd)
SDL_CFLAGS=$(shell sdl-config --cflags)
SDL_LDFLAGS=$(shell sdl-config --libs)
LIBDIR=/usr/lib
HEADERDIR=/usr/include
ADDL_CFLAGS=
ifeq "$(OS)" "mingw32"
ADDL_CFLAGS=-mwindows -DBUILD_MINGW32
endif
ifeq "$(OS)" "linux"
ADDL_CFLAGS=-DBUILD_LINUX
endif
# default for release configs
ifeq "$(CFG)" "Release"
OUTDIR=Release
ifeq "$(OS)" "mingw32"
BINTARGET=$(TARGET).exe
else
BINTARGET=$(TARGET)
endif
LINKLIB=game
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
ifeq "$(CFG)" "Debug"
OUTDIR=Debug
ifeq "$(OS)" "mingw32"
BINTARGET=$(TARGET)-dbg.exe
else
BINTARGET=$(TARGET)-dbg
endif
LINKLIB=game-dbg
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
LINKLIBS=-L../../$(CFG) -L$(LIBDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer -lSDL_gfx -lSDL_ttf
BINOBJ=$(OUTDIR)/demo.o
CC = gcc
CXX = g++
LD = $(CXX)
INSTALL = $(which install)
$(OUTDIR)/%.o : cpp/%.cpp
$(CXX) $(CXXFLAGS) -o $@ $<
all: bin
bin: $(BINOBJ)
$(LD) -pg -o $(OUTDIR)/$(BINTARGET) \
-pg $(BINOBJ) $(LINKLIBS)
.PHONY: clean
clean:
rm -f $(OUTDIR)/*.o
rm -f $(OUTDIR)/$(BINTARGET)
.PHONY: rebuild
rebuild:
make clean
make CFG=$(CFG)

BIN
demo/frictionball/Release/demo Executable file

Binary file not shown.

Binary file not shown.

BIN
demo/frictionball/ball.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

92
demo/frictionball/cpp/demo.cpp Executable file
View File

@@ -0,0 +1,92 @@
/*
* This demo expands on the bouncingball demo to show how you can integrate simple physics to create a
* more realistic bouncing effect, and bring the ball to a halt
*/
#include <libgame/libgame.h>
int main(int argc, char *argv[])
{
Display2D display = Display2D();
Game &myGame = Game::NewSingleton();
Animation *anim = NULL;
Actor ball;
SpriteStrip *strip = NULL;
float gravity = 0.1;
unsigned int lastTimer = 0;
Vector actorPos;
Vector actorVel;
myGame.initSDL();
myGame.initVideo(640, 480, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
display.initVideo((Vector){0,0,0}, 640, 480, 32, SDL_HWSURFACE);
display.setActive(1);
myGame.windows.push_back(&display);
strip = myGame.newSpriteStrip("ball");
strip->loadFromFile("ball.png", 32, 32, (Vector){0,0,0});
anim = myGame.newAnimation("ball");
anim->setStrip(strip, 0, 0, (Vector){0,0,0});
ball.addAnimation(anim, STATE_DEFAULT);
ball.setState(STATE_MOVERIGHT | STATE_MOVEUP);
ball.setPosition((Vector){320,240,0});
ball.setVelocity((Vector){-1, 0, 0});
display.addActor(&ball, LAYER_SPRITE1);
lastTimer = SDL_GetTicks();
myGame.lockFPS(60);
while ( 1 ) {
actorPos = ball.getPosition();
actorVel = ball.getVelocity();
/* this is what does the bounce */
if ( actorPos.y > (480 - ball.nextFrame()->h) ) {
// if the velocity is low enough, then we just stop the ball so that it will roll
// smoothly along the floor of the window
if ( actorVel.y < .01 && actorVel.y > -.01 ) {
actorVel.y = 0;
} else {
// if the velocity is still significant, then we reverse it to create the bounce
// but since real balls don't bounce quite as high as they did initially, when dropped
// so we do a primitive modification of the velocity to inroduce something similar to
// friction physics (see the "physics" demos for ACTUAL physics)
// The friction numbers here are arbitrary, and were used because they made sense in the
// demo, you can change the friction for some pretty different effects.
actorVel.y = -(actorVel.y) - 1;
// this is friction applied to the X axis to stop the ball's movement eventually
if ( actorVel.x < .01 && actorVel.x > -.01 ) {
actorVel.x = 0;
} else {
if ( actorVel.x > 0 ) {
actorVel.x -= .1;
} else {
actorVel.x += .1;
}
}
}
actorPos.y = (480 - ball.nextFrame()->h);
ball.setPosition(actorPos);
}
if ( ((actorPos.x + ball.nextFrame()->w) >= 640) || actorPos.x < 0 ) {
actorVel.x = -(actorVel.x);
}
// -- end of bouncing
if ( actorPos.x >= 640 ) {
break;
}
if ( (SDL_GetTicks() - lastTimer) >= (1000/30) ) {
actorVel.y -= gravity;
ball.setVelocity(actorVel);
lastTimer = SDL_GetTicks();
}
myGame.update();
if ( myGame.keyHeldDown(SDLK_ESCAPE) ) {
break;
}
myGame.finishFrame();
}
return 0;
}

BIN
demo/frictionball/gmon.out Executable file

Binary file not shown.

277
demo/frictionball/log.txt Executable file
View File

@@ -0,0 +1,277 @@
ALSA lib pcm_dmix.c:874:(snd_pcm_dmix_open) unable to open slave
Current time 35 last timer 30
Moving ball down by 0.001 (0) units
Now at 0 0
Current time 40 last timer 30
Moving ball down by 0.002 (0) units
Now at 0 0
Current time 51 last timer 30
Moving ball down by 0.0042 (0) units
Now at 0 0
Current time 58 last timer 30
Moving ball down by 0.0056 (0) units
Now at 0 0
Current time 61 last timer 30
Moving ball down by 0.0062 (0) units
Now at 0 0
Current time 64 last timer 30
Moving ball down by 0.0068 (0) units
Now at 0 0
Current time 74 last timer 30
Moving ball down by 0.0088 (0) units
Now at 0 0
Current time 82 last timer 30
Moving ball down by 0.0104 (0) units
Now at 0 0
Current time 91 last timer 30
Moving ball down by 0.0122 (0) units
Now at 0 0
Current time 100 last timer 30
Moving ball down by 0.014 (0) units
Now at 0 0
Current time 112 last timer 30
Moving ball down by 0.0164 (0) units
Now at 0 0
Current time 121 last timer 30
Moving ball down by 0.0182 (0) units
Now at 0 0
Current time 131 last timer 30
Moving ball down by 0.0202 (0) units
Now at 0 0
Current time 141 last timer 30
Moving ball down by 0.0222 (0) units
Now at 0 0
Current time 150 last timer 30
Moving ball down by 0.024 (0) units
Now at 0 0
Current time 159 last timer 30
Moving ball down by 0.0258 (0) units
Now at 0 0
Current time 169 last timer 30
Moving ball down by 0.0278 (0) units
Now at 0 0
Current time 177 last timer 30
Moving ball down by 0.0294 (0) units
Now at 0 0
Current time 188 last timer 30
Moving ball down by 0.0316 (0) units
Now at 0 0
Current time 197 last timer 30
Moving ball down by 0.0334 (0) units
Now at 0 0
Current time 207 last timer 30
Moving ball down by 0.0354 (0) units
Now at 0 0
Current time 215 last timer 30
Moving ball down by 0.037 (0) units
Now at 0 0
Current time 224 last timer 30
Moving ball down by 0.0388 (0) units
Now at 0 0
Current time 234 last timer 30
Moving ball down by 0.0408 (0) units
Now at 0 0
Current time 243 last timer 30
Moving ball down by 0.0426 (0) units
Now at 0 0
Current time 251 last timer 30
Moving ball down by 0.0442 (0) units
Now at 0 0
Current time 260 last timer 30
Moving ball down by 0.046 (0) units
Now at 0 0
Current time 268 last timer 30
Moving ball down by 0.0476 (0) units
Now at 0 0
Current time 277 last timer 30
Moving ball down by 0.0494 (0) units
Now at 0 0
Current time 286 last timer 30
Moving ball down by 0.0512 (0) units
Now at 0 0
Current time 295 last timer 30
Moving ball down by 0.053 (0) units
Now at 0 0
Current time 307 last timer 30
Moving ball down by 0.0554 (0) units
Now at 0 0
Current time 316 last timer 30
Moving ball down by 0.0572 (0) units
Now at 0 0
Current time 325 last timer 30
Moving ball down by 0.059 (0) units
Now at 0 0
Current time 333 last timer 30
Moving ball down by 0.0606 (0) units
Now at 0 0
Current time 343 last timer 30
Moving ball down by 0.0626 (0) units
Now at 0 0
Current time 351 last timer 30
Moving ball down by 0.0642 (0) units
Now at 0 0
Current time 360 last timer 30
Moving ball down by 0.066 (0) units
Now at 0 0
Current time 369 last timer 30
Moving ball down by 0.0678 (0) units
Now at 0 0
Current time 377 last timer 30
Moving ball down by 0.0694 (0) units
Now at 0 0
Current time 386 last timer 30
Moving ball down by 0.0712 (0) units
Now at 0 0
Current time 399 last timer 30
Moving ball down by 0.0738 (0) units
Now at 0 0
Current time 408 last timer 30
Moving ball down by 0.0758 (0) units
Now at 0 0
Current time 422 last timer 30
Moving ball down by 0.0784 (0) units
Now at 0 0
Current time 431 last timer 30
Moving ball down by 0.0802 (0) units
Now at 0 0
Current time 440 last timer 30
Moving ball down by 0.082 (0) units
Now at 0 0
Current time 449 last timer 30
Moving ball down by 0.0838 (0) units
Now at 0 0
Current time 457 last timer 30
Moving ball down by 0.0854 (0) units
Now at 0 0
Current time 468 last timer 30
Moving ball down by 0.0876 (0) units
Now at 0 0
Current time 478 last timer 30
Moving ball down by 0.0896 (0) units
Now at 0 0
Current time 487 last timer 30
Moving ball down by 0.0914 (0) units
Now at 0 0
Current time 496 last timer 30
Moving ball down by 0.0932 (0) units
Now at 0 0
Current time 506 last timer 30
Moving ball down by 0.0954 (0) units
Now at 0 0
Current time 516 last timer 30
Moving ball down by 0.0972 (0) units
Now at 0 0
Current time 525 last timer 30
Moving ball down by 0.099 (0) units
Now at 0 0
Current time 533 last timer 30
Moving ball down by 0.1006 (0) units
Now at 0 0
Current time 545 last timer 30
Moving ball down by 0.103 (0) units
Now at 0 0
Current time 555 last timer 30
Moving ball down by 0.105 (0) units
Now at 0 0
Current time 565 last timer 30
Moving ball down by 0.107 (0) units
Now at 0 0
Current time 575 last timer 30
Moving ball down by 0.109 (0) units
Now at 0 0
Current time 586 last timer 30
Moving ball down by 0.1112 (0) units
Now at 0 0
Current time 595 last timer 30
Moving ball down by 0.113 (0) units
Now at 0 0
Current time 607 last timer 30
Moving ball down by 0.1154 (0) units
Now at 0 0
Current time 616 last timer 30
Moving ball down by 0.1172 (0) units
Now at 0 0
Current time 625 last timer 30
Moving ball down by 0.119 (0) units
Now at 0 0
Current time 633 last timer 30
Moving ball down by 0.1206 (0) units
Now at 0 0
Current time 643 last timer 30
Moving ball down by 0.1226 (0) units
Now at 0 0
Current time 651 last timer 30
Moving ball down by 0.1244 (0) units
Now at 0 0
Current time 660 last timer 30
Moving ball down by 0.126 (0) units
Now at 0 0
Current time 669 last timer 30
Moving ball down by 0.128 (0) units
Now at 0 0
Current time 678 last timer 30
Moving ball down by 0.1296 (0) units
Now at 0 0
Current time 687 last timer 30
Moving ball down by 0.1314 (0) units
Now at 0 0
Current time 698 last timer 30
Moving ball down by 0.1336 (0) units
Now at 0 0
Current time 707 last timer 30
Moving ball down by 0.1354 (0) units
Now at 0 0
Current time 718 last timer 30
Moving ball down by 0.1376 (0) units
Now at 0 0
Current time 727 last timer 30
Moving ball down by 0.1394 (0) units
Now at 0 0
Current time 737 last timer 30
Moving ball down by 0.1414 (0) units
Now at 0 0
Current time 748 last timer 30
Moving ball down by 0.1436 (0) units
Now at 0 0
Current time 757 last timer 30
Moving ball down by 0.1454 (0) units
Now at 0 0
Current time 765 last timer 30
Moving ball down by 0.147 (0) units
Now at 0 0
Current time 774 last timer 30
Moving ball down by 0.1488 (0) units
Now at 0 0
Current time 785 last timer 30
Moving ball down by 0.151 (0) units
Now at 0 0
Current time 796 last timer 30
Moving ball down by 0.1532 (0) units
Now at 0 0
Current time 806 last timer 30
Moving ball down by 0.1552 (0) units
Now at 0 0
Current time 816 last timer 30
Moving ball down by 0.1572 (0) units
Now at 0 0
Current time 825 last timer 30
Moving ball down by 0.159 (0) units
Now at 0 0
Current time 833 last timer 30
Moving ball down by 0.161 (0) units
Now at 0 0
Current time 847 last timer 30
Moving ball down by 0.1634 (0) units
Now at 0 0
Current time 855 last timer 30
Moving ball down by 0.165 (0) units
Now at 0 0
Current time 865 last timer 30
Moving ball down by 0.167 (0) units
Now at 0 0
Current time 874 last timer 30
Moving ball down by 0.1688 (0) units
Now at 0 0
Current time 883 last timer 30
Moving ball down by 0.1708 (0) units
Now at 0 0

713
demo/gravity/Debug/stderr.txt Executable file
View File

@@ -0,0 +1,713 @@
Splitting frames from ball.png (32x32...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Updating actor 0x22fc90
Blitting display 0x22fcf0 canvas 0xb6dcb0 to main canvas 0x3d4100(0,0)...
Updating actor 0x22fc90
Updating actor 0x22fc90

1
demo/gravity/Debug/stdout.txt Executable file
View File

@@ -0,0 +1 @@
Split 1 frames into new sprite strip

78
demo/gravity/Makefile Executable file
View File

@@ -0,0 +1,78 @@
# This makefile is a bit hackish. I wrote it early in the AM.
# Fohgiveuhness, please!!
ifndef $(CFG)
CFG=Debug
endif
# you can also pass : mingw32 and macosx
ifndef $(OS)
OS=linux
endif
TARGET=demo
BINTARGET=$(TARGET)
PROJECTHOME=$(shell pwd)
SDL_CFLAGS=$(shell sdl-config --cflags)
SDL_LDFLAGS=$(shell sdl-config --libs)
LIBDIR=/usr/lib
HEADERDIR=/usr/include
ADDL_CFLAGS=
ifeq "$(OS)" "mingw32"
ADDL_CFLAGS=-mwindows -DBUILD_MINGW32
endif
ifeq "$(OS)" "linux"
ADDL_CFLAGS=-DBUILD_LINUX
endif
# default for release configs
ifeq "$(CFG)" "Release"
OUTDIR=Release
ifeq "$(OS)" "mingw32"
BINTARGET=$(TARGET).exe
else
BINTARGET=$(TARGET)
endif
LINKLIB=game
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
ifeq "$(CFG)" "Debug"
OUTDIR=Debug
ifeq "$(OS)" "mingw32"
BINTARGET=$(TARGET)-dbg.exe
else
BINTARGET=$(TARGET)-dbg
endif
LINKLIB=game-dbg
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
LINKLIBS=-L../../$(CFG) -L$(LIBDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer -lSDL_gfx -lSDL_ttf
BINOBJ=$(OUTDIR)/demo.o
CC = gcc
CXX = g++
LD = $(CXX)
INSTALL = $(which install)
$(OUTDIR)/%.o : cpp/%.cpp
$(CXX) $(CXXFLAGS) -o $@ $<
all: bin
bin: $(BINOBJ)
$(LD) -pg -o $(OUTDIR)/$(BINTARGET) \
-pg $(BINOBJ) $(LINKLIBS)
.PHONY: clean
clean:
rm -f $(OUTDIR)/*.o
rm -f $(OUTDIR)/$(BINTARGET)
.PHONY: rebuild
rebuild:
make clean
make CFG=$(CFG)

BIN
demo/gravity/Release/demo Executable file

Binary file not shown.

BIN
demo/gravity/Release/demo.exe Executable file

Binary file not shown.

BIN
demo/gravity/ball.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

61
demo/gravity/cpp/demo.cpp Executable file
View File

@@ -0,0 +1,61 @@
/*
* This demo just creates a ball that moves up, and allows gravity to effect it.
* The effect is to cause the velocity of the ball to change, causing it to travel
* in a parabola on the Y axis rather than simply going straight up or straight down.
*/
#include <libgame/libgame.h>
int main(int argc, char *argv[])
{
Display2D display = Display2D();
Game &myGame = Game::NewSingleton();
Animation *anim = NULL;
Actor ball;
SpriteStrip *strip = NULL;
float gravity = 0.1;
unsigned int lastTimer = 0;
Vector actorPos;
Vector actorVel;
myGame.initSDL();
myGame.initVideo(640, 480, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
display.initVideo((Vector){0,0,0}, 640, 480, 32, SDL_HWSURFACE);
display.setActive(1);
myGame.windows.push_back(&display);
strip = myGame.newSpriteStrip("ball");
strip->loadFromFile("ball.png", 32, 32, (Vector){0,0,0});
anim = myGame.newAnimation("ball");
anim->setStrip(strip, 0, 0, (Vector){0,0,0});
ball.addAnimation(anim, STATE_DEFAULT);
ball.setState(STATE_MOVERIGHT | STATE_MOVEUP);
ball.setPosition((Vector){0,400,0});
ball.setVelocity((Vector){1, 1.5, 0});
display.addActor(&ball, LAYER_SPRITE1);
lastTimer = SDL_GetTicks();
while ( 1 ) {
actorPos = ball.getPosition();
if ( actorPos.y >= 480 ) {
break;
}
if ( (SDL_GetTicks() - lastTimer) >= (1000/30) ) {
myGame.update();
actorVel = ball.getVelocity();
actorVel.y -= gravity;
ball.setVelocity(actorVel);
lastTimer = SDL_GetTicks();
} else {
myGame.update(1);
}
if ( myGame.keyHeldDown(SDLK_ESCAPE) ) {
break;
}
myGame.finishFrame();
}
return 0;
}

BIN
demo/gravity/gmon.out Executable file

Binary file not shown.

277
demo/gravity/log.txt Executable file
View File

@@ -0,0 +1,277 @@
ALSA lib pcm_dmix.c:874:(snd_pcm_dmix_open) unable to open slave
Current time 35 last timer 30
Moving ball down by 0.001 (0) units
Now at 0 0
Current time 40 last timer 30
Moving ball down by 0.002 (0) units
Now at 0 0
Current time 51 last timer 30
Moving ball down by 0.0042 (0) units
Now at 0 0
Current time 58 last timer 30
Moving ball down by 0.0056 (0) units
Now at 0 0
Current time 61 last timer 30
Moving ball down by 0.0062 (0) units
Now at 0 0
Current time 64 last timer 30
Moving ball down by 0.0068 (0) units
Now at 0 0
Current time 74 last timer 30
Moving ball down by 0.0088 (0) units
Now at 0 0
Current time 82 last timer 30
Moving ball down by 0.0104 (0) units
Now at 0 0
Current time 91 last timer 30
Moving ball down by 0.0122 (0) units
Now at 0 0
Current time 100 last timer 30
Moving ball down by 0.014 (0) units
Now at 0 0
Current time 112 last timer 30
Moving ball down by 0.0164 (0) units
Now at 0 0
Current time 121 last timer 30
Moving ball down by 0.0182 (0) units
Now at 0 0
Current time 131 last timer 30
Moving ball down by 0.0202 (0) units
Now at 0 0
Current time 141 last timer 30
Moving ball down by 0.0222 (0) units
Now at 0 0
Current time 150 last timer 30
Moving ball down by 0.024 (0) units
Now at 0 0
Current time 159 last timer 30
Moving ball down by 0.0258 (0) units
Now at 0 0
Current time 169 last timer 30
Moving ball down by 0.0278 (0) units
Now at 0 0
Current time 177 last timer 30
Moving ball down by 0.0294 (0) units
Now at 0 0
Current time 188 last timer 30
Moving ball down by 0.0316 (0) units
Now at 0 0
Current time 197 last timer 30
Moving ball down by 0.0334 (0) units
Now at 0 0
Current time 207 last timer 30
Moving ball down by 0.0354 (0) units
Now at 0 0
Current time 215 last timer 30
Moving ball down by 0.037 (0) units
Now at 0 0
Current time 224 last timer 30
Moving ball down by 0.0388 (0) units
Now at 0 0
Current time 234 last timer 30
Moving ball down by 0.0408 (0) units
Now at 0 0
Current time 243 last timer 30
Moving ball down by 0.0426 (0) units
Now at 0 0
Current time 251 last timer 30
Moving ball down by 0.0442 (0) units
Now at 0 0
Current time 260 last timer 30
Moving ball down by 0.046 (0) units
Now at 0 0
Current time 268 last timer 30
Moving ball down by 0.0476 (0) units
Now at 0 0
Current time 277 last timer 30
Moving ball down by 0.0494 (0) units
Now at 0 0
Current time 286 last timer 30
Moving ball down by 0.0512 (0) units
Now at 0 0
Current time 295 last timer 30
Moving ball down by 0.053 (0) units
Now at 0 0
Current time 307 last timer 30
Moving ball down by 0.0554 (0) units
Now at 0 0
Current time 316 last timer 30
Moving ball down by 0.0572 (0) units
Now at 0 0
Current time 325 last timer 30
Moving ball down by 0.059 (0) units
Now at 0 0
Current time 333 last timer 30
Moving ball down by 0.0606 (0) units
Now at 0 0
Current time 343 last timer 30
Moving ball down by 0.0626 (0) units
Now at 0 0
Current time 351 last timer 30
Moving ball down by 0.0642 (0) units
Now at 0 0
Current time 360 last timer 30
Moving ball down by 0.066 (0) units
Now at 0 0
Current time 369 last timer 30
Moving ball down by 0.0678 (0) units
Now at 0 0
Current time 377 last timer 30
Moving ball down by 0.0694 (0) units
Now at 0 0
Current time 386 last timer 30
Moving ball down by 0.0712 (0) units
Now at 0 0
Current time 399 last timer 30
Moving ball down by 0.0738 (0) units
Now at 0 0
Current time 408 last timer 30
Moving ball down by 0.0758 (0) units
Now at 0 0
Current time 422 last timer 30
Moving ball down by 0.0784 (0) units
Now at 0 0
Current time 431 last timer 30
Moving ball down by 0.0802 (0) units
Now at 0 0
Current time 440 last timer 30
Moving ball down by 0.082 (0) units
Now at 0 0
Current time 449 last timer 30
Moving ball down by 0.0838 (0) units
Now at 0 0
Current time 457 last timer 30
Moving ball down by 0.0854 (0) units
Now at 0 0
Current time 468 last timer 30
Moving ball down by 0.0876 (0) units
Now at 0 0
Current time 478 last timer 30
Moving ball down by 0.0896 (0) units
Now at 0 0
Current time 487 last timer 30
Moving ball down by 0.0914 (0) units
Now at 0 0
Current time 496 last timer 30
Moving ball down by 0.0932 (0) units
Now at 0 0
Current time 506 last timer 30
Moving ball down by 0.0954 (0) units
Now at 0 0
Current time 516 last timer 30
Moving ball down by 0.0972 (0) units
Now at 0 0
Current time 525 last timer 30
Moving ball down by 0.099 (0) units
Now at 0 0
Current time 533 last timer 30
Moving ball down by 0.1006 (0) units
Now at 0 0
Current time 545 last timer 30
Moving ball down by 0.103 (0) units
Now at 0 0
Current time 555 last timer 30
Moving ball down by 0.105 (0) units
Now at 0 0
Current time 565 last timer 30
Moving ball down by 0.107 (0) units
Now at 0 0
Current time 575 last timer 30
Moving ball down by 0.109 (0) units
Now at 0 0
Current time 586 last timer 30
Moving ball down by 0.1112 (0) units
Now at 0 0
Current time 595 last timer 30
Moving ball down by 0.113 (0) units
Now at 0 0
Current time 607 last timer 30
Moving ball down by 0.1154 (0) units
Now at 0 0
Current time 616 last timer 30
Moving ball down by 0.1172 (0) units
Now at 0 0
Current time 625 last timer 30
Moving ball down by 0.119 (0) units
Now at 0 0
Current time 633 last timer 30
Moving ball down by 0.1206 (0) units
Now at 0 0
Current time 643 last timer 30
Moving ball down by 0.1226 (0) units
Now at 0 0
Current time 651 last timer 30
Moving ball down by 0.1244 (0) units
Now at 0 0
Current time 660 last timer 30
Moving ball down by 0.126 (0) units
Now at 0 0
Current time 669 last timer 30
Moving ball down by 0.128 (0) units
Now at 0 0
Current time 678 last timer 30
Moving ball down by 0.1296 (0) units
Now at 0 0
Current time 687 last timer 30
Moving ball down by 0.1314 (0) units
Now at 0 0
Current time 698 last timer 30
Moving ball down by 0.1336 (0) units
Now at 0 0
Current time 707 last timer 30
Moving ball down by 0.1354 (0) units
Now at 0 0
Current time 718 last timer 30
Moving ball down by 0.1376 (0) units
Now at 0 0
Current time 727 last timer 30
Moving ball down by 0.1394 (0) units
Now at 0 0
Current time 737 last timer 30
Moving ball down by 0.1414 (0) units
Now at 0 0
Current time 748 last timer 30
Moving ball down by 0.1436 (0) units
Now at 0 0
Current time 757 last timer 30
Moving ball down by 0.1454 (0) units
Now at 0 0
Current time 765 last timer 30
Moving ball down by 0.147 (0) units
Now at 0 0
Current time 774 last timer 30
Moving ball down by 0.1488 (0) units
Now at 0 0
Current time 785 last timer 30
Moving ball down by 0.151 (0) units
Now at 0 0
Current time 796 last timer 30
Moving ball down by 0.1532 (0) units
Now at 0 0
Current time 806 last timer 30
Moving ball down by 0.1552 (0) units
Now at 0 0
Current time 816 last timer 30
Moving ball down by 0.1572 (0) units
Now at 0 0
Current time 825 last timer 30
Moving ball down by 0.159 (0) units
Now at 0 0
Current time 833 last timer 30
Moving ball down by 0.161 (0) units
Now at 0 0
Current time 847 last timer 30
Moving ball down by 0.1634 (0) units
Now at 0 0
Current time 855 last timer 30
Moving ball down by 0.165 (0) units
Now at 0 0
Current time 865 last timer 30
Moving ball down by 0.167 (0) units
Now at 0 0
Current time 874 last timer 30
Moving ball down by 0.1688 (0) units
Now at 0 0
Current time 883 last timer 30
Moving ball down by 0.1708 (0) units
Now at 0 0

123
deps/Makefile vendored Executable file
View File

@@ -0,0 +1,123 @@
all: clean packages
CFLAGS=$(CFLAGS) -I/usr/local/include -I/usr/include
LDFLAGS=$(LDFLAGS) -L/usr/local/lib -L/usr/lib
.PHONY: files
files:
wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2
.PHONY: packages
packages: SDL_main zlib libpng libjpeg libtiff SDL_image libvorbis flac SDL_mixer freetype SDL_ttf SDL_gfx libxml2
.PHONY: SDL_main
SDL_main:
wget http://www.libsdl.org/release/SDL-1.2.14.tar.gz
tar -zxvf SDL-1.2.14.tar.gz
cd SDL-1.2.14 && ./configure && make && make install
.PHONY: libpng
libpng:
wget -O libpng-1.2.37-bin.zip http://downloads.sourceforge.net/gnuwin32/libpng-1.2.37-bin.zip
unzip -od /usr/local/ libpng-1.2.37-bin.zip
wget -O libpng-1.2.37-deps.zip http://downloads.sourceforge.net/gnuwin32/libpng-1.2.37-dep.zip
unzip -od /usr/local/ libpng-1.2.37-deps.zip
wget -O libpng-1.2.37-devs.zip http://downloads.sourceforge.net/gnuwin32/libpng-1.2.37-lib.zip
unzip -od /usr/local/ libpng-1.2.37-devs.zip
cp libpng-config /usr/local/bin/libpng-config
.PHONY: zlib
zlib:
wget -O zlib-bin.zip http://gnuwin32.sourceforge.net/downlinks/zlib-bin-zip.php
unzip -od /usr/local/ zlib-bin.zip
wget -O zlib-libs.zip http://gnuwin32.sourceforge.net/downlinks/zlib-lib-zip.php
unzip -od /usr/local/ zlib-libs.zip
.PHONY: libjpeg
libjpeg:
wget -O jpeg-bin.zip http://gnuwin32.sourceforge.net/downlinks/jpeg-bin-zip.php
unzip -od /usr/local/ jpeg-bin.zip
wget -O jpeg-deps.zip http://gnuwin32.sourceforge.net/downlinks/jpeg-dep-zip.php
unzip -od /usr/local/ jpeg-deps.zip
wget -O jpeg-devs.zip http://gnuwin32.sourceforge.net/downlinks/jpeg-lib-zip.php
unzip -od /usr/local/ jpeg-devs.zip
.PHONY: libtiff
libtiff:
wget -O tiff-bin.zip http://gnuwin32.sourceforge.net/downlinks/tiff-bin-zip.php
unzip -od /usr/local/ tiff-bin.zip
wget -O tiff-deps.zip http://gnuwin32.sourceforge.net/downlinks/tiff-dep-zip.php
unzip -od /usr/local/ tiff-deps.zip
wget -O tiff-devs.zip http://gnuwin32.sourceforge.net/downlinks/tiff-lib-zip.php
unzip -od /usr/local/ tiff-devs.zip
.PHONY: SDL_image
SDL_image:
wget http://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.10.tar.gz
tar -zxvf SDL_image-1.2.10.tar.gz
cd SDL_image-1.2.10 && CFLAGS="-I/usr/local/include -I/usr/include" LDFLAGS=-L/usr/local/lib ./configure && make && make install
.PHONY: libvorbis
libvorbis:
wget http://downloads.xiph.org/releases/ogg/libogg-1.2.2.tar.gz
tar -zxvf libogg-1.2.2.tar.gz
cd libogg-1.2.2 && ./configure && make && make install
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.2.tar.gz
tar -zxvf libvorbis-1.3.2.tar.gz
cd libvorbis-1.3.2 && CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ./configure && make && make install
.PHONY: flac
flac:
wget http://downloads.xiph.org/releases/flac/flac-1.2.1.tar.gz
tar -zxvf flac-1.2.1.tar.gz
patch -p0 < flac-alloc.h.patch
patch -p0 < flac-main.cpp.patch
cd flac-1.2.1 && ./configure && make && make install
.PHONY: SDL_mixer
SDL_mixer:
wget http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-1.2.11.tar.gz
tar -zxvf SDL_mixer-1.2.11.tar.gz
cd SDL_mixer-1.2.11 && CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ./configure && make && make install
.PHONY: SDL_ttf
SDL_ttf:
wget http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-2.0.10.tar.gz
tar -zxvf SDL_ttf-2.0.10.tar.gz
cd SDL_ttf-2.0.10 && CFLAGS="-I/usr/local/include -I/usr/local/include/freetype2" LDFLAGS=-L/usr/local/lib ./configure && make && make install
.PHONY: freetype
freetype:
wget -O freetype-bin.zip http://gnuwin32.sourceforge.net/downlinks/freetype-bin-zip.php
unzip -od /usr/local/ freetype-bin.zip
wget -O freetype-deps.zip http://gnuwin32.sourceforge.net/downlinks/freetype-dep-zip.php
unzip -od /usr/local/ freetype-deps.zip
wget -O freetype-devs.zip http://gnuwin32.sourceforge.net/downlinks/freetype-lib-zip.php
unzip -od /usr/local/ freetype-devs.zip
.PHONY: SDL_gfx
SDL_gfx:
wget http://www.ferzkopp.net/Software/SDL_gfx-2.0/SDL_gfx-2.0.22.tar.gz
tar -zxvf SDL_gfx-2.0.22.tar.gz
mkdir SDL_gfx-2.0.22/m4
cp /usr/local/share/aclocal/sdl.m4 SDL_gfx-2.0.22/m4
cd SDL_gfx-2.0.22 && libtoolize --force --copy && aclocal -I m4 && autoconf && automake
cd SDL_gfx-2.0.22 && CFLAGS="-I/usr/local/include -I/usr/include" LDFLAGS="-L/usr/local/lib -L/usr/lib" ./configure && make && make install
.PHONY: libxml2
libxml2:
wget http://sourceforge.net/projects/gnuwin32/files/libxml/2.4.12-1/libxml2-2.4.12-bin.zip/download
unzip -od /usr/local/ libxml2-2.4.12-bin.zip
wget http://sourceforge.net/projects/gnuwin32/files/libxml/2.4.12-1/libxml2-2.4.12-1-lib.zip/download
unzip -od /usr/local/ libxml2-2.4.12-1-lib.zip
.PHONY: doxygen
doxygen:
wget http://ftp.stack.nl/pub/users/dimitri/doxygen-1.7.4.windows.bin.zip
unzip -od /bin doxygen-1.7.4.windows.bin.zip
.PHONY: clean
clean:
rm -rf *gz *zip *bz2
find . -maxdepth 1 -type d -iname "[a-zA-Z0-9]*" -exec rm -rf \{\} \;

15
deps/flac-alloc.h.patch vendored Executable file
View File

@@ -0,0 +1,15 @@
--- flac-1.2.1/include/share/alloc.h 2007-09-12 01:32:21 -0400
+++ flac-1.2.1/include/share/alloc.new.h 2011-05-22 13:52:19 -0400
@@ -35,11 +35,7 @@
#ifndef SIZE_MAX
# ifndef SIZE_T_MAX
-# ifdef _MSC_VER
-# define SIZE_T_MAX UINT_MAX
-# else
-# error
-# endif
+# define SIZE_T_MAX UINT_MAX
# endif
# define SIZE_MAX SIZE_T_MAX
#endif

10
deps/flac-main.cpp.patch vendored Executable file
View File

@@ -0,0 +1,10 @@
--- flac-1.2.1/examples/cpp/encode/file/main.cpp 2011-05-22 14:13:46 -0400
+++ flac-1.2.1/examples/cpp/encode/file/main.new.cpp 2011-05-22 14:13:21 -0400
@@ -30,6 +30,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "FLAC++/metadata.h"
#include "FLAC++/encoder.h"

124
deps/libpng-config vendored Executable file
View File

@@ -0,0 +1,124 @@
#! /bin/sh
# libpng-config
# provides configuration info for libpng.
# Copyright (C) 2002, 2004, 2006, 2007 Glenn Randers-Pehrson
# For conditions of distribution and use, see copyright notice in png.h
# Modeled after libxml-config.
version="1.2.37"
prefix="/usr/include"
exec_prefix="${prefix}"
libdir="${exec_prefix}/lib"
includedir="${prefix}/include/libpng12"
libs="-lpng12"
all_libs="-lpng12 -lz"
I_opts="-I${includedir}"
L_opts="-L${libdir}"
R_opts=""
cppflags=""
ccopts=""
ldopts=""
usage()
{
cat <<EOF
Usage: $0 [OPTION] ...
Known values for OPTION are:
--prefix print libpng prefix
--libdir print path to directory containing library
--libs print library linking information
--ccopts print compiler options
--cppflags print pre-processor flags
--cflags print preprocessor flags, I_opts, and compiler options
--I_opts print "-I" include options
--L_opts print linker "-L" flags for dynamic linking
--R_opts print dynamic linker "-R" or "-rpath" flags
--ldopts print linker options
--ldflags print linker flags (ldopts, L_opts, R_opts, and libs)
--static revise subsequent outputs for static linking
--help print this help and exit
--version print version information
EOF
exit $1
}
if test $# -eq 0; then
usage 1
fi
while test $# -gt 0; do
case "$1" in
--prefix)
echo ${prefix}
;;
--version)
echo ${version}
exit 0
;;
--help)
usage 0
;;
--ccopts)
echo ${ccopts}
;;
--cppflags)
echo ${cppflags}
;;
--cflags)
echo ${I_opts} ${cppflags} ${ccopts}
;;
--libdir)
echo ${libdir}
;;
--libs)
echo ${libs}
;;
--I_opts)
echo ${I_opts}
;;
--L_opts)
echo ${L_opts}
;;
--R_opts)
echo ${R_opts}
;;
--ldopts)
echo ${ldopts}
;;
--ldflags)
echo ${ldopts} ${L_opts} ${R_opts} ${libs}
;;
--static)
R_opts=""
libs=${all_libs}
;;
*)
usage
exit 1
;;
esac
shift
done
exit 0

1716
doxygen.conf Executable file

File diff suppressed because it is too large Load Diff

15
libgame.h Executable file
View File

@@ -0,0 +1,15 @@
#ifndef __LIBGAME_H__
#define __LIBGAME_H__
#include "Common.h"
#include "FontRenderer.h"
#include "Renderable.h"
#include "SpriteStrip.h"
#include "Animation.h"
#include "Actor.h"
#include "Display.h"
#include "Display2D.h"
#include "MenuDisplay.h"
#include "Game.h"
#endif // __LIBGAME_H__

BIN
util/animate/Debug/animate-dbg Executable file

Binary file not shown.

BIN
util/animate/Debug/demo-dbg Executable file

Binary file not shown.

BIN
util/animate/MARINE_WALK_LEFT.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

77
util/animate/Makefile Executable file
View File

@@ -0,0 +1,77 @@
# This makefile is a bit hackish. I wrote it early in the AM.
# Fohgiveuhness, please!!
ifndef $(CFG)
CFG=Debug
endif
# you can also pass : mingw32 and macosx
ifndef $(OS)
OS=linux
endif
TARGET=animate
BINTARGET=$(TARGET)
PROJECTHOME=$(shell pwd)
SDL_CFLAGS=$(shell sdl-config --cflags)
SDL_LDFLAGS=$(shell sdl-config --libs)
LIBDIR=/usr/lib
HEADERDIR=/usr/include
ADDL_CFLAGS=
ifeq "$(OS)" "mingw32"
ADDL_CFLAGS=-mwindows -DBUILD_MINGW32
endif
ifeq "$(OS)" "linux"
ADDL_CFLAGS=-DBUILD_LINUX
endif
# default for release configs
ifeq "$(CFG)" "Release"
OUTDIR=Release
ifeq "$(OS)" "mingw32"
BINTARGET=$(TARGET).exe
else
BINTARGET=$(TARGET)
endif
LINKLIB=game
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
ifeq "$(CFG)" "Debug"
OUTDIR=Debug
ifeq "$(OS)" "mingw32"
BINTARGET=$(TARGET)-dbg.exe
else
BINTARGET=$(TARGET)-dbg
endif
LINKLIB=game-dbg
CXXFLAGS=-I../../../ -I$(HEADERDIR) -I./cpp -pg -g -ggdb -gstabs -Wall -c $(SDL_CFLAGS) $(ADDL_CFLAGS)
endif
LINKLIBS=-L../../$(CFG) -L$(LIBDIR) -l$(LINKLIB) $(SDL_LDFLAGS) -lSDL_image -lSDL_mixer -lSDL_gfx -lSDL_ttf
BINOBJ=$(OUTDIR)/demo.o
CC = gcc
CXX = g++
LD = $(CXX)
INSTALL = $(which install)
$(OUTDIR)/%.o : cpp/%.cpp
$(CXX) $(CXXFLAGS) -o $@ $<
all: bin
bin: $(BINOBJ)
$(LD) -pg -o $(OUTDIR)/$(BINTARGET) \
-pg $(BINOBJ) $(LINKLIBS)
.PHONY: clean
clean:
rm -f $(OUTDIR)/*.o
rm -f $(OUTDIR)/$(BINTARGET)
.PHONY: rebuild
rebuild:
make clean
make CFG=$(CFG)

BIN
util/animate/Release/animate Executable file

Binary file not shown.

85
util/animate/cpp/demo.cpp Executable file
View File

@@ -0,0 +1,85 @@
#include <libgame/libgame.h>
#include <string>
#include <SDL_gfxPrimitives.h>
#include <cstdlib>
#include <sstream>
int main(int argc, char *argv[])
{
FontRenderer &font = FontRenderer::NewSingleton();
char gimmeitoa[32];
Display2D display = Display2D();
Game &myGame = Game::NewSingleton();
Animation *anim = NULL;
Actor animator;
Vector velocity;
Vector position;
SpriteStrip *strip = NULL;
if ( argc < 9 ) {
std::cerr << "animate SCRX SCRY SCRDEPTH IMAGEFILE FRAMEWIDTH FRAMEHEIGHT FPS LOOP [XVEL] [YVEL]\n";
exit(1);
}
myGame.initSDL();
myGame.initVideo(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]), SDL_HWSURFACE|SDL_DOUBLEBUF);
//display.initVideo((Vector){0,0,0}, atoi(argv[1]), atoi(argv[2]), atoi(argv[3]), SDL_HWSURFACE);
display.shareCanvas(&myGame);
display.setActive(1);
myGame.windows.push_back(&display);
strip = myGame.newSpriteStrip("anim");
if ( strip->loadFromFile(argv[4], atoi(argv[5]), atoi(argv[6]), (Vector){0,0,0}) ) {
std::cerr << "Failed to load sprite from file " << argv[4] << " (framesize " << argv[5] << "x" << argv[6] << "\n";
exit(1);
}
anim = myGame.newAnimation("anim");
anim->setStrip(strip, atoi(argv[7]), atoi(argv[8]), (Vector){0,0,0});
animator.addAnimation(anim, STATE_DEFAULT);
animator.setState(STATE_NONE);
if ( argc >= 10) {
animator.addState(STATE_MOVEXAXIS);
velocity.x = atof(argv[9]);
}
if ( argc >= 11 ) {
animator.addState(STATE_MOVEYAXIS);
velocity.y = atof(argv[10]);
}
animator.setVelocity(velocity);
animator.setPosition((Vector){
(myGame.getCanvas()->w/2)-((animator.nextFrame()->w)/2),
(myGame.getCanvas()->h/2)-((animator.nextFrame()->h)/2),
0} );
display.addActor(&animator, LAYER_SPRITE1);
font.setColor((SDL_Color){255, 255, 255, 255}, (SDL_Color){0, 0, 0, 255}, 255);
myGame.lockFPS(30);
std::string msg;
while ( 1 ) {
msg = argv[4];
msg += " ";
sprintf((char *)&gimmeitoa, "(%dx%d) %s/%d FPS",
animator.nextFrame()->w,
animator.nextFrame()->h,
argv[7],
myGame.realfps);
msg += (char *)&gimmeitoa;
//std::cerr << msg << "\n";
myGame.update();
font.renderString(msg, myGame.getCanvas(), "", (Vector){-1, 20, 0}, 0);
if ( myGame.keyHeldDown(SDLK_ESCAPE) ) {
break;
}
position = animator.getPosition();
if ( position.x < 0 || position.x > 640 ) {
position.x = (myGame.getCanvas()->w/2)-((animator.nextFrame()->w)/2);
}
if ( position.y < 0 || position.y > 480 ) {
position.y = (myGame.getCanvas()->h/2)-((animator.nextFrame()->h)/2);
}
animator.setPosition(position);
myGame.finishFrame();
}
}

BIN
util/animate/explosion.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
util/packsprite Executable file

Binary file not shown.