Browse Source

Complete Lol Engine / Deus Hax / Monsterz split.

legacy
Sam Hocevar sam 14 years ago
parent
commit
0ed566d3cc
52 changed files with 333 additions and 462 deletions
  1. +1
    -1
      .gitignore
  2. +1
    -1
      configure.ac
  3. +3
    -4
      src/Makefile.am
  4. +7
    -2
      src/bitfield.h
  5. +7
    -3
      src/core.h
  6. +0
    -74
      src/debugboard.cpp
  7. +0
    -34
      src/debugboard.h
  8. +7
    -2
      src/debugfps.cpp
  9. +7
    -2
      src/debugfps.h
  10. +7
    -2
      src/debugrecord.cpp
  11. +7
    -2
      src/debugrecord.h
  12. +7
    -2
      src/debugsphere.cpp
  13. +7
    -2
      src/debugsphere.h
  14. +0
    -74
      src/debugsprite.cpp
  15. +0
    -34
      src/debugsprite.h
  16. +7
    -2
      src/debugstats.cpp
  17. +7
    -2
      src/debugstats.h
  18. +7
    -2
      src/dict.cpp
  19. +7
    -2
      src/dict.h
  20. +7
    -2
      src/entity.cpp
  21. +7
    -2
      src/entity.h
  22. +7
    -2
      src/font.cpp
  23. +7
    -2
      src/font.h
  24. +7
    -2
      src/forge.cpp
  25. +7
    -2
      src/forge.h
  26. +0
    -90
      src/game.cpp
  27. +0
    -42
      src/game.h
  28. +7
    -2
      src/input.cpp
  29. +7
    -2
      src/input.h
  30. +7
    -2
      src/layer.cpp
  31. +7
    -2
      src/layer.h
  32. +8
    -3
      src/map.cpp
  33. +7
    -2
      src/map.h
  34. +7
    -2
      src/matrix.h
  35. +7
    -2
      src/profiler.cpp
  36. +7
    -2
      src/profiler.h
  37. +7
    -2
      src/scene.cpp
  38. +7
    -2
      src/scene.h
  39. +7
    -2
      src/sdlinput.cpp
  40. +7
    -3
      src/sdlinput.h
  41. +7
    -2
      src/ticker.cpp
  42. +7
    -2
      src/ticker.h
  43. +9
    -4
      src/tiler.cpp
  44. +8
    -3
      src/tiler.h
  45. +29
    -17
      src/tileset.cpp
  46. +8
    -3
      src/tileset.h
  47. +7
    -2
      src/timer.cpp
  48. +7
    -2
      src/timer.h
  49. +7
    -2
      src/video.cpp
  50. +7
    -2
      src/video.h
  51. +7
    -2
      src/world.cpp
  52. +7
    -2
      src/world.h

+ 1
- 1
.gitignore View File

@@ -22,7 +22,7 @@ configure
libtool
stamp-*
*-stamp
deushax-*.tar.*
lolengine-*.tar.*
# Debugging cruft
core
core.*


+ 1
- 1
configure.ac View File

@@ -1,6 +1,6 @@
# $Id$

AC_INIT(deushax, 0.0)
AC_INIT(lolengine, 0.0)
AC_PREREQ(2.50)
AC_CONFIG_AUX_DIR(.auto)
AC_CANONICAL_SYSTEM


+ 3
- 4
src/Makefile.am View File

@@ -2,7 +2,7 @@
noinst_LIBRARIES = liblol.a

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 \
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 \
@@ -10,8 +10,7 @@ liblol_a_SOURCES = \
\
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`


+ 7
- 2
src/bitfield.h View File

@@ -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.
//

//


+ 7
- 3
src/core.h View File

@@ -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
#include "entity.h"
#include "font.h"
#include "game.h"
#include "tileset.h"
#include "world.h"



+ 0
- 74
src/debugboard.cpp View File

@@ -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;
}


+ 0
- 34
src/debugboard.h View File

@@ -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__


+ 7
- 2
src/debugfps.cpp View File

@@ -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


+ 7
- 2
src/debugfps.h View File

@@ -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.
//

//


+ 7
- 2
src/debugrecord.cpp View File

@@ -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


+ 7
- 2
src/debugrecord.h View File

@@ -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.
//

//


+ 7
- 2
src/debugsphere.cpp View File

@@ -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


+ 7
- 2
src/debugsphere.h View File

@@ -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.
//

//


+ 0
- 74
src/debugsprite.cpp View File

@@ -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;
}


+ 0
- 34
src/debugsprite.h View File

@@ -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__


+ 7
- 2
src/debugstats.cpp View File

@@ -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


+ 7
- 2
src/debugstats.h View File

@@ -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.
//

//


+ 7
- 2
src/dict.cpp View File

@@ -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


+ 7
- 2
src/dict.h View File

@@ -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.
//

//


+ 7
- 2
src/entity.cpp View File

@@ -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


+ 7
- 2
src/entity.h View File

@@ -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.
//

//


+ 7
- 2
src/font.cpp View File

@@ -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


+ 7
- 2
src/font.h View File

@@ -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.
//

//


+ 7
- 2
src/forge.cpp View File

@@ -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


+ 7
- 2
src/forge.h View File

@@ -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.
//

//


+ 0
- 90
src/game.cpp View File

@@ -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;
}


+ 0
- 42
src/game.h View File

@@ -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__


+ 7
- 2
src/input.cpp View File

@@ -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


+ 7
- 2
src/input.h View File

@@ -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.
//

//


+ 7
- 2
src/layer.cpp View File

@@ -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


+ 7
- 2
src/layer.h View File

@@ -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.
//

//


+ 8
- 3
src/map.cpp View File

@@ -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
@@ -121,7 +126,7 @@ Map::Map(char const *path)
else if (sscanf(tmp, " <image source=\"%[^\"]\"", str) == 1)
{
/* 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++;
//fprintf(stderr, "new tiler %s\n", str);
}


+ 7
- 2
src/map.h View File

@@ -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.
//

//


+ 7
- 2
src/matrix.h View File

@@ -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.
//

//


+ 7
- 2
src/profiler.cpp View File

@@ -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


+ 7
- 2
src/profiler.h View File

@@ -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.
//

//


+ 7
- 2
src/scene.cpp View File

@@ -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


+ 7
- 2
src/scene.h View File

@@ -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.
//

//


+ 7
- 2
src/sdlinput.cpp View File

@@ -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


+ 7
- 3
src/sdlinput.h View File

@@ -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__

#include "entity.h"
#include "game.h"

class SdlInputData;



+ 7
- 2
src/ticker.cpp View File

@@ -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


+ 7
- 2
src/ticker.h View File

@@ -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.
//

//


+ 9
- 4
src/tiler.cpp View File

@@ -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
@@ -28,13 +33,13 @@ static TilerData * const data = &tilerdata;
* 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);

if (!data->tilesets.GetEntity(id))
{
TileSet *tileset = new TileSet(path, size);
TileSet *tileset = new TileSet(path, w, h);
data->tilesets.SetEntity(id, tileset);
}



+ 8
- 3
src/tiler.h View File

@@ -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
{
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 BlitTile(uint32_t code, int x, int y, int z, int o);


+ 29
- 17
src/tileset.cpp View File

@@ -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
@@ -37,7 +42,7 @@ class TileSetData
private:
char *name;
int *tiles;
int size, nw, nh, ntiles;
int w, h, nw, nh, ntiles;
float tx, ty;

SDL_Surface *img;
@@ -48,7 +53,7 @@ private:
* Public TileSet class
*/

TileSet::TileSet(char const *path, int size)
TileSet::TileSet(char const *path, int w, int h)
{
data = new TileSetData();
data->name = strdup(path);
@@ -66,15 +71,19 @@ TileSet::TileSet(char const *path, int size)
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->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;
}
@@ -99,11 +108,14 @@ void TileSet::TickDraw(float deltams)
}
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);
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_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 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)
{


+ 8
- 3
src/tileset.h View File

@@ -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
{
public:
TileSet(char const *path, int size);
TileSet(char const *path, int w, int h);
virtual ~TileSet();

protected:


+ 7
- 2
src/timer.cpp View File

@@ -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


+ 7
- 2
src/timer.h View File

@@ -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.
//

//


+ 7
- 2
src/video.cpp View File

@@ -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


+ 7
- 2
src/video.h View File

@@ -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.
//

//


+ 7
- 2
src/world.cpp View File

@@ -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


+ 7
- 2
src/world.h View File

@@ -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.
//

//


Loading…
Cancel
Save