@@ -22,7 +22,7 @@ configure | |||||
libtool | libtool | ||||
stamp-* | stamp-* | ||||
*-stamp | *-stamp | ||||
deushax-*.tar.* | |||||
lolengine-*.tar.* | |||||
# Debugging cruft | # Debugging cruft | ||||
core | core | ||||
core.* | core.* | ||||
@@ -1,6 +1,6 @@ | |||||
# $Id$ | # $Id$ | ||||
AC_INIT(deushax, 0.0) | |||||
AC_INIT(lolengine, 0.0) | |||||
AC_PREREQ(2.50) | AC_PREREQ(2.50) | ||||
AC_CONFIG_AUX_DIR(.auto) | AC_CONFIG_AUX_DIR(.auto) | ||||
AC_CANONICAL_SYSTEM | AC_CANONICAL_SYSTEM | ||||
@@ -2,7 +2,7 @@ | |||||
noinst_LIBRARIES = liblol.a | noinst_LIBRARIES = liblol.a | ||||
liblol_a_SOURCES = \ | liblol_a_SOURCES = \ | ||||
core.h matrix.h game.cpp game.h tiler.cpp tiler.h dict.cpp dict.h \ | |||||
core.h matrix.h tiler.cpp tiler.h dict.cpp dict.h \ | |||||
scene.cpp scene.h font.cpp font.h layer.cpp layer.h map.cpp map.h \ | scene.cpp scene.h font.cpp font.h layer.cpp layer.h map.cpp map.h \ | ||||
entity.cpp entity.h ticker.cpp ticker.h tileset.cpp tileset.h \ | entity.cpp entity.h ticker.cpp ticker.h tileset.cpp tileset.h \ | ||||
forge.cpp forge.h video.cpp video.h timer.cpp timer.h bitfield.h \ | forge.cpp forge.h video.cpp video.h timer.cpp timer.h bitfield.h \ | ||||
@@ -10,8 +10,7 @@ liblol_a_SOURCES = \ | |||||
\ | \ | ||||
sdlinput.cpp sdlinput.h \ | sdlinput.cpp sdlinput.h \ | ||||
\ | \ | ||||
debugfps.cpp debugfps.h debugsprite.cpp debugsprite.h \ | |||||
debugrecord.cpp debugrecord.h debugstats.cpp debugstats.h \ | |||||
debugsphere.cpp debugsphere.h debugboard.cpp debugboard.h | |||||
debugfps.cpp debugfps.h debugsphere.cpp debugsphere.h \ | |||||
debugrecord.cpp debugrecord.h debugstats.cpp debugstats.h | |||||
liblol_a_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image` | liblol_a_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image` | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -24,7 +29,6 @@ | |||||
// Entities | // Entities | ||||
#include "entity.h" | #include "entity.h" | ||||
#include "font.h" | #include "font.h" | ||||
#include "game.h" | |||||
#include "tileset.h" | #include "tileset.h" | ||||
#include "world.h" | #include "world.h" | ||||
@@ -1,74 +0,0 @@ | |||||
// | |||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
#if defined HAVE_CONFIG_H | |||||
# include "config.h" | |||||
#endif | |||||
#include <cstdio> | |||||
#include <cmath> | |||||
#include "core.h" | |||||
#include "debugboard.h" | |||||
/* | |||||
* DebugBoard implementation class | |||||
*/ | |||||
class DebugBoardData | |||||
{ | |||||
friend class DebugBoard; | |||||
private: | |||||
Game *game; | |||||
int tiler; | |||||
float x, y, z; | |||||
}; | |||||
/* | |||||
* Public DebugBoard class | |||||
*/ | |||||
DebugBoard::DebugBoard(Game *game) | |||||
{ | |||||
data = new DebugBoardData(); | |||||
data->game = game; | |||||
Ticker::Ref(game); | |||||
data->tiler = Tiler::Register("monsterz/tiles.png", 48); | |||||
data->x = 32; | |||||
data->y = 0; | |||||
data->z = 112; | |||||
} | |||||
void DebugBoard::TickGame(float deltams) | |||||
{ | |||||
Entity::TickGame(deltams); | |||||
} | |||||
void DebugBoard::TickDraw(float deltams) | |||||
{ | |||||
Entity::TickDraw(deltams); | |||||
int x = data->x; | |||||
int y = data->y; | |||||
int z = data->z; | |||||
for (int j = 0; j < 8; j++) | |||||
for (int i = 0; i < 8; i++) | |||||
{ | |||||
int id = 28 + ((i + 3) * (j + 1) % 10) * 3 + ((i ^ (j + 2)) % 5); | |||||
id += (id % 5) / 4; | |||||
data->game->GetScene()->AddTile((data->tiler << 16) | id, | |||||
x + i * 48 - 16, y + j * 48, z, 1); | |||||
} | |||||
} | |||||
DebugBoard::~DebugBoard() | |||||
{ | |||||
Ticker::Unref(data->game); | |||||
Tiler::Deregister(data->tiler); | |||||
delete data; | |||||
} | |||||
@@ -1,34 +0,0 @@ | |||||
// | |||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
// | |||||
// The DebugBoard class | |||||
// -------------------- | |||||
// | |||||
#if !defined __DH_DEBUGBOARD_H__ | |||||
#define __DH_DEBUGBOARD_H__ | |||||
#include "entity.h" | |||||
#include "game.h" | |||||
class DebugBoardData; | |||||
class DebugBoard : public Entity | |||||
{ | |||||
public: | |||||
DebugBoard(Game *game); | |||||
virtual ~DebugBoard(); | |||||
protected: | |||||
virtual void TickGame(float deltams); | |||||
virtual void TickDraw(float deltams); | |||||
private: | |||||
DebugBoardData *data; | |||||
}; | |||||
#endif // __DH_DEBUGBOARD_H__ | |||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,74 +0,0 @@ | |||||
// | |||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
#if defined HAVE_CONFIG_H | |||||
# include "config.h" | |||||
#endif | |||||
#include <cstdio> | |||||
#include <cmath> | |||||
#include "core.h" | |||||
#include "debugsprite.h" | |||||
/* | |||||
* DebugSprite implementation class | |||||
*/ | |||||
class DebugSpriteData | |||||
{ | |||||
friend class DebugSprite; | |||||
private: | |||||
Game *game; | |||||
int tiler; | |||||
float x, y, z; | |||||
}; | |||||
/* | |||||
* Public DebugSprite class | |||||
*/ | |||||
DebugSprite::DebugSprite(Game *game) | |||||
{ | |||||
data = new DebugSpriteData(); | |||||
data->game = game; | |||||
Ticker::Ref(game); | |||||
data->tiler = Tiler::Register("art/test/character-dress.png", 32); | |||||
data->x = 320; | |||||
data->y = 206; | |||||
data->z = 0; | |||||
} | |||||
void DebugSprite::TickGame(float deltams) | |||||
{ | |||||
Entity::TickGame(deltams); | |||||
Float2 axis = Input::GetAxis(0); | |||||
data->x += 0.1f * sqrtf(2.0f) * deltams * axis.x; | |||||
data->y += 0.1f * deltams * axis.y; | |||||
} | |||||
void DebugSprite::TickDraw(float deltams) | |||||
{ | |||||
Entity::TickDraw(deltams); | |||||
int x = data->x; | |||||
int y = data->y; | |||||
int z = data->z; | |||||
data->game->GetScene()->AddTile((data->tiler << 16) | 31, | |||||
x - 16, y, z, 1); | |||||
data->game->GetScene()->AddTile((data->tiler << 16) | 15, | |||||
x - 16, y, z + 32, 1); | |||||
} | |||||
DebugSprite::~DebugSprite() | |||||
{ | |||||
Ticker::Unref(data->game); | |||||
Tiler::Deregister(data->tiler); | |||||
delete data; | |||||
} | |||||
@@ -1,34 +0,0 @@ | |||||
// | |||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
// | |||||
// The DebugSprite class | |||||
// --------------------- | |||||
// | |||||
#if !defined __DH_DEBUGSPRITE_H__ | |||||
#define __DH_DEBUGSPRITE_H__ | |||||
#include "entity.h" | |||||
#include "game.h" | |||||
class DebugSpriteData; | |||||
class DebugSprite : public Entity | |||||
{ | |||||
public: | |||||
DebugSprite(Game *game); | |||||
virtual ~DebugSprite(); | |||||
protected: | |||||
virtual void TickGame(float deltams); | |||||
virtual void TickDraw(float deltams); | |||||
private: | |||||
DebugSpriteData *data; | |||||
}; | |||||
#endif // __DH_DEBUGSPRITE_H__ | |||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,90 +0,0 @@ | |||||
// | |||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
#if defined HAVE_CONFIG_H | |||||
# include "config.h" | |||||
#endif | |||||
#include <cstdio> | |||||
#include "core.h" | |||||
/* | |||||
* Game implementation class | |||||
*/ | |||||
class GameData | |||||
{ | |||||
friend class Game; | |||||
private: | |||||
Map *map; | |||||
int x, y; | |||||
int mousex, mousey; | |||||
int done; | |||||
Scene *scene; | |||||
}; | |||||
/* | |||||
* Public Game class | |||||
*/ | |||||
Game::Game(char const *mapname) | |||||
{ | |||||
data = new GameData(); | |||||
data->map = new Map(mapname); | |||||
data->x = data->y = 0; | |||||
data->done = 0; | |||||
data->scene = NULL; | |||||
} | |||||
Game::~Game() | |||||
{ | |||||
delete data->map; | |||||
delete data; | |||||
} | |||||
void Game::TickGame(float deltams) | |||||
{ | |||||
Entity::TickGame(deltams); | |||||
} | |||||
void Game::TickDraw(float deltams) | |||||
{ | |||||
Entity::TickDraw(deltams); | |||||
GetScene(); | |||||
data->map->Render(data->scene, -data->mousex, -data->mousey, 0); | |||||
data->scene->Render(); | |||||
delete data->scene; | |||||
data->scene = NULL; | |||||
} | |||||
Scene *Game::GetScene() | |||||
{ | |||||
if (!data->scene) | |||||
data->scene = new Scene(); | |||||
return data->scene; | |||||
} | |||||
void Game::SetMouse(int x, int y) | |||||
{ | |||||
data->mousex = x; | |||||
data->mousey = y; | |||||
} | |||||
void Game::Quit() | |||||
{ | |||||
data->done = 1; | |||||
} | |||||
int Game::Finished() | |||||
{ | |||||
return data->done; | |||||
} | |||||
@@ -1,42 +0,0 @@ | |||||
// | |||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// | |||||
// | |||||
// The Game class | |||||
// -------------- | |||||
// | |||||
#if !defined __DH_GAME_H__ | |||||
#define __DH_GAME_H__ | |||||
#include "entity.h" | |||||
#include "scene.h" | |||||
class GameData; | |||||
class Game : public Entity | |||||
{ | |||||
public: | |||||
Game(char const *mapname); | |||||
~Game(); | |||||
protected: | |||||
/* Inherited from Entity */ | |||||
virtual void TickGame(float deltams); | |||||
virtual void TickDraw(float deltams); | |||||
public: | |||||
/* New methods */ | |||||
Scene *GetScene(); | |||||
void SetMouse(int x, int y); | |||||
void Quit(); | |||||
int Finished(); | |||||
private: | |||||
GameData *data; | |||||
}; | |||||
#endif // __DH_GAME_H__ | |||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -121,7 +126,7 @@ Map::Map(char const *path) | |||||
else if (sscanf(tmp, " <image source=\"%[^\"]\"", str) == 1) | else if (sscanf(tmp, " <image source=\"%[^\"]\"", str) == 1) | ||||
{ | { | ||||
/* This is a tileset image file. Associate it with firstgid. */ | /* This is a tileset image file. Associate it with firstgid. */ | ||||
data->tilers[data->ntilers] = Tiler::Register(str, 32); | |||||
data->tilers[data->ntilers] = Tiler::Register(str, 32, 32); | |||||
data->ntilers++; | data->ntilers++; | ||||
//fprintf(stderr, "new tiler %s\n", str); | //fprintf(stderr, "new tiler %s\n", str); | ||||
} | } | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -12,7 +17,6 @@ | |||||
#define __DH_SDLINPUT_H__ | #define __DH_SDLINPUT_H__ | ||||
#include "entity.h" | #include "entity.h" | ||||
#include "game.h" | |||||
class SdlInputData; | class SdlInputData; | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -28,13 +33,13 @@ static TilerData * const data = &tilerdata; | |||||
* Public Tiler class | * Public Tiler class | ||||
*/ | */ | ||||
int Tiler::Register(char const *path, int size) | |||||
int Tiler::Register(char const *path, int w, int h) | |||||
{ | { | ||||
int id = data->tilesets.MakeSlot(path); | int id = data->tilesets.MakeSlot(path); | ||||
if (!data->tilesets.GetEntity(id)) | if (!data->tilesets.GetEntity(id)) | ||||
{ | { | ||||
TileSet *tileset = new TileSet(path, size); | |||||
TileSet *tileset = new TileSet(path, w, h); | |||||
data->tilesets.SetEntity(id, tileset); | data->tilesets.SetEntity(id, tileset); | ||||
} | } | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -17,7 +22,7 @@ | |||||
class Tiler | class Tiler | ||||
{ | { | ||||
public: | public: | ||||
static int Register(char const *path, int size); | |||||
static int Register(char const *path, int w, int h); | |||||
static void Deregister(int id); | static void Deregister(int id); | ||||
static void BlitTile(uint32_t code, int x, int y, int z, int o); | static void BlitTile(uint32_t code, int x, int y, int z, int o); | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -37,7 +42,7 @@ class TileSetData | |||||
private: | private: | ||||
char *name; | char *name; | ||||
int *tiles; | int *tiles; | ||||
int size, nw, nh, ntiles; | |||||
int w, h, nw, nh, ntiles; | |||||
float tx, ty; | float tx, ty; | ||||
SDL_Surface *img; | SDL_Surface *img; | ||||
@@ -48,7 +53,7 @@ private: | |||||
* Public TileSet class | * Public TileSet class | ||||
*/ | */ | ||||
TileSet::TileSet(char const *path, int size) | |||||
TileSet::TileSet(char const *path, int w, int h) | |||||
{ | { | ||||
data = new TileSetData(); | data = new TileSetData(); | ||||
data->name = strdup(path); | data->name = strdup(path); | ||||
@@ -66,15 +71,19 @@ TileSet::TileSet(char const *path, int size) | |||||
exit(1); | exit(1); | ||||
} | } | ||||
if (size <= 0) | |||||
size = 32; | |||||
if (w <= 0) | |||||
w = 32; | |||||
if (h <= 0) | |||||
h = 32; | |||||
data->size = size; | |||||
data->nw = data->img->w / size; | |||||
data->nh = data->img->h / size; | |||||
data->w = w; | |||||
data->h = h; | |||||
/* FIXME: check for non-zero here */ | |||||
data->nw = data->img->w / w; | |||||
data->nh = data->img->h / h; | |||||
data->ntiles = data->nw * data->nh; | data->ntiles = data->nw * data->nh; | ||||
data->tx = (float)size / data->img->w; | |||||
data->ty = (float)size / data->img->h; | |||||
data->tx = (float)w / data->img->w; | |||||
data->ty = (float)h / data->img->h; | |||||
drawgroup = DRAWGROUP_BEFORE; | drawgroup = DRAWGROUP_BEFORE; | ||||
} | } | ||||
@@ -99,11 +108,14 @@ void TileSet::TickDraw(float deltams) | |||||
} | } | ||||
else if (data->img) | else if (data->img) | ||||
{ | { | ||||
GLuint format = data->img->format->Amask ? GL_RGBA : GL_RGB; | |||||
int planes = data->img->format->Amask ? 4 : 3; | |||||
glGenTextures(1, &data->texture); | glGenTextures(1, &data->texture); | ||||
glBindTexture(GL_TEXTURE_2D, data->texture); | glBindTexture(GL_TEXTURE_2D, data->texture); | ||||
glTexImage2D(GL_TEXTURE_2D, 0, 4, data->img->w, data->img->h, 0, | |||||
GL_RGBA, GL_UNSIGNED_BYTE, data->img->pixels); | |||||
glTexImage2D(GL_TEXTURE_2D, 0, planes, data->img->w, data->img->h, 0, | |||||
format, GL_UNSIGNED_BYTE, data->img->pixels); | |||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | ||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | ||||
@@ -124,10 +136,10 @@ void TileSet::BlitTile(uint32_t id, int x, int y, int z, int o) | |||||
float ty = data->ty * ((id & 0xffff) / data->nw); | float ty = data->ty * ((id & 0xffff) / data->nw); | ||||
float sqrt2 = sqrtf(2.0f); | float sqrt2 = sqrtf(2.0f); | ||||
int off = o ? data->size : 0; | |||||
int dx = data->size; | |||||
int dy = data->size * 38 / 32; /* Magic... fix this one day */ | |||||
int dy2 = data->size * 70 / 32; | |||||
int off = o ? data->h : 0; | |||||
int dx = data->w; | |||||
int dy = data->h * 38 / 32; /* Magic... fix this one day */ | |||||
int dy2 = data->h * 70 / 32; | |||||
if (!data->img) | if (!data->img) | ||||
{ | { | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -23,7 +28,7 @@ class TileSetData; | |||||
class TileSet : public Entity | class TileSet : public Entity | ||||
{ | { | ||||
public: | public: | ||||
TileSet(char const *path, int size); | |||||
TileSet(char const *path, int w, int h); | |||||
virtual ~TileSet(); | virtual ~TileSet(); | ||||
protected: | protected: | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
#if defined HAVE_CONFIG_H | #if defined HAVE_CONFIG_H | ||||
@@ -1,6 +1,11 @@ | |||||
// | // | ||||
// Deus Hax (working title) | |||||
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | // | ||||
// | // | ||||