Browse Source

Slightly improve the documentation in a few files, add the missing

joystick class, and put a header in each source file.
legacy
Sam Hocevar sam 14 years ago
parent
commit
0fc6a8487c
29 changed files with 311 additions and 63 deletions
  1. +5
    -5
      src/Makefile.am
  2. +8
    -0
      src/asset.cpp
  3. +12
    -4
      src/asset.h
  4. +8
    -0
      src/font.cpp
  5. +9
    -4
      src/font.h
  6. +8
    -0
      src/game.cpp
  7. +9
    -4
      src/game.h
  8. +8
    -0
      src/gtk/editor.cpp
  9. +8
    -0
      src/gtk/gtkvideo.cpp
  10. +11
    -6
      src/gtk/gtkvideo.h
  11. +40
    -0
      src/joystick.cpp
  12. +34
    -0
      src/joystick.h
  13. +8
    -0
      src/layer.cpp
  14. +10
    -4
      src/layer.h
  15. +8
    -0
      src/map.cpp
  16. +11
    -4
      src/map.h
  17. +8
    -0
      src/scene.cpp
  18. +9
    -4
      src/scene.h
  19. +8
    -0
      src/sdlvideo.cpp
  20. +9
    -4
      src/sdlvideo.h
  21. +8
    -1
      src/test-map.cpp
  22. +8
    -4
      src/ticker.cpp
  23. +10
    -4
      src/ticker.h
  24. +8
    -0
      src/tiler.cpp
  25. +9
    -3
      src/tiler.h
  26. +8
    -0
      src/tileset.cpp
  27. +11
    -4
      src/tileset.h
  28. +9
    -6
      src/video.h
  29. +9
    -2
      tools/make-font.cpp

+ 5
- 5
src/Makefile.am View File

@@ -4,17 +4,17 @@ noinst_PROGRAMS = test-map editor
noinst_LIBRARIES = libcommon.a

libcommon_a_SOURCES = \
game.cpp tiler.cpp tileset.cpp scene.cpp \
font.cpp layer.cpp map.cpp joystick.cpp \
asset.h asset.cpp ticker.h ticker.cpp
game.cpp game.h tiler.cpp tiler.h tileset.cpp tileset.h \
scene.cpp scene.h font.cpp font.h layer.cpp layer.h map.cpp map.h \
joystick.cpp joystick.h asset.cpp asset.h ticker.cpp ticker.h
libcommon_a_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image`

test_map_SOURCES = test-map.cpp sdlvideo.cpp
test_map_SOURCES = test-map.cpp sdlvideo.cpp sdlvideo.h
test_map_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image`
test_map_LDADD = libcommon.a
test_map_LDFLAGS = `pkg-config --libs sdl gl SDL_image`

editor_SOURCES = gtk/editor.cpp gtk/gtkvideo.cpp
editor_SOURCES = gtk/editor.cpp gtk/gtkvideo.cpp gtk/gtkvideo.h
editor_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image gtk+-2.0 gtkgl-2.0`
editor_LDADD = libcommon.a
editor_LDFLAGS = `pkg-config --libs sdl gl gtk+-2.0 gtkgl-2.0 SDL_image`


+ 8
- 0
src/asset.cpp View File

@@ -1,3 +1,11 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdlib>



+ 12
- 4
src/asset.h View File

@@ -1,7 +1,15 @@

/*
* The asset object
*/
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

//
// The Asset class
// ---------------
// Assets are objects that can be ticked by the game loop and/or the render
// loop. Assets are implemented as one or several linked lists. See the
// Ticker class for the ticking logic and the linked list implementation.
//

#if !defined __DH_ASSET_H__
#define __DH_ASSET_H__


+ 8
- 0
src/font.cpp View File

@@ -1,3 +1,11 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#ifdef WIN32
# define WIN32_LEAN_AND_MEAN


+ 9
- 4
src/font.h View File

@@ -1,7 +1,12 @@

/*
* The font object
*/
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

//
// The Font class
// --------------
//

#if !defined __DH_FONT_H__
#define __DH_FONT_H__


+ 8
- 0
src/game.cpp View File

@@ -1,3 +1,11 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdio>



+ 9
- 4
src/game.h View File

@@ -1,7 +1,12 @@

/*
* The game object
*/
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

//
// The Game class
// --------------
//

#if !defined __DH_GAME_H__
#define __DH_GAME_H__


+ 8
- 0
src/gtk/editor.cpp View File

@@ -1,3 +1,11 @@
//
// 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>


+ 8
- 0
src/gtk/gtkvideo.cpp View File

@@ -1,3 +1,11 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdlib>



+ 11
- 6
src/gtk/gtkvideo.h View File

@@ -1,7 +1,12 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

/*
* The video driver
*/
//
// The GtkVideo class
// ------------------
//

#if !defined __DH_GTKVIDEO_H__
#define __DH_GTKVIDEO_H__
@@ -16,9 +21,6 @@ public:
GtkVideo(char const *title, int width, int height);
virtual ~GtkVideo();

// New
void *GetWidget();

// Inherited
virtual int GetWidth() const;
virtual int GetHeight() const;
@@ -26,6 +28,9 @@ public:
virtual void PostRender(float milliseconds);
virtual void FullScreen();

// New
void *GetWidget();

private:
GtkVideoData *data;
};


+ 40
- 0
src/joystick.cpp View File

@@ -0,0 +1,40 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <SDL.h>

#include "joystick.h"

/*
* Joystick implementation class
*/

class JoystickData
{
friend class Joystick;

private:
int dummy;
};

/*
* Public Joystick class
*/

Joystick::Joystick()
{
data = new JoystickData();

SDL_WM_GrabInput(SDL_GRAB_ON);
}

Joystick::~Joystick()
{
}


+ 34
- 0
src/joystick.h View File

@@ -0,0 +1,34 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

//
// The Joystick class
// ------------------
//

#if !defined __DH_JOYSTICK_H__
#define __DH_JOYSTICK_H__

class JoystickData;

class Joystick
{
public:
Joystick();
~Joystick();

int GetState();

static int const NORTH = (1<<0);
static int const EAST = (1<<1);
static int const SOUTH = (1<<2);
static int const WEST = (1<<3);

private:
JoystickData *data;
};

#endif // __DH_JOYSTICK_H__


+ 8
- 0
src/layer.cpp View File

@@ -1,3 +1,11 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <stdlib.h>



+ 10
- 4
src/layer.h View File

@@ -1,7 +1,13 @@

/*
* The layer object
*/
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

//
// The Layer class
// ---------------
// A Layer object is a subset of a Map.
//

#if !defined __DH_LAYER_H__
#define __DH_LAYER_H__


+ 8
- 0
src/map.cpp View File

@@ -1,3 +1,11 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdio>
#include <cstring>


+ 11
- 4
src/map.h View File

@@ -1,7 +1,14 @@

/*
* The map object
*/
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

//
// The Map class
// -------------
// A Map object is a collection of Layers and other information (to be
// determined later).
//

#if !defined __DH_MAP_H__
#define __DH_MAP_H__


+ 8
- 0
src/scene.cpp View File

@@ -1,3 +1,11 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <stdlib.h>



+ 9
- 4
src/scene.h View File

@@ -1,7 +1,12 @@

/*
* The scene object
*/
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

//
// The Scene class
// ---------------
//

#if !defined __DH_SCENE_H__
#define __DH_SCENE_H__


+ 8
- 0
src/sdlvideo.cpp View File

@@ -1,3 +1,11 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#ifdef WIN32
# define WIN32_LEAN_AND_MEAN


+ 9
- 4
src/sdlvideo.h View File

@@ -1,7 +1,12 @@

/*
* The video driver
*/
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

//
// The SdlVideo class
// ------------------
//

#if !defined __DH_SDLVIDEO_H__
#define __DH_SDLVIDEO_H__


+ 8
- 1
src/test-map.cpp View File

@@ -1,4 +1,11 @@
// Test stuff
//
// 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>


+ 8
- 4
src/ticker.cpp View File

@@ -1,7 +1,11 @@

/*
* The ticker
*/
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdlib>
#include <cstdio>


+ 10
- 4
src/ticker.h View File

@@ -1,7 +1,13 @@

/*
* The tick manager
*/
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

//
// The Ticker class
// ----------------
// The Ticker is a static class that registers assets and ticks them.
//

#if !defined __DH_TICKER_H__
#define __DH_TICKER_H__


+ 8
- 0
src/tiler.cpp View File

@@ -1,3 +1,11 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstring>
#include <cstdio>


+ 9
- 3
src/tiler.h View File

@@ -1,7 +1,13 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

/*
* The tile manager
*/
//
// The Tiler class
// ---------------
// The Tiler is a static class that manages tilesets.
//

#if !defined __DH_TILER_H__
#define __DH_TILER_H__


+ 8
- 0
src/tileset.cpp View File

@@ -1,3 +1,11 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdlib>



+ 11
- 4
src/tileset.h View File

@@ -1,7 +1,14 @@

/*
* The tile manager
*/
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

//
// The TileSet class
// -----------------
// A TileSet contains the information necesary to blit tiles to the game
// screen.
//

#if !defined __DH_TILESET_H__
#define __DH_TILESET_H__


+ 9
- 6
src/video.h View File

@@ -1,7 +1,13 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

/*
* The video interface
*/
//
// The Video interface
// -------------------
// Not sure yet whether this should exist.
//

#if !defined __DH_VIDEO_H__
#define __DH_VIDEO_H__
@@ -9,9 +15,6 @@
class Video
{
public:
//Video(char const *title, int width, int height);
//virtual ~Video();

virtual int GetWidth() const = 0;
virtual int GetHeight() const = 0;
virtual void PreRender() = 0;


+ 9
- 2
tools/make-font.cpp View File

@@ -1,9 +1,17 @@
//
// Deus Hax (working title)
// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
//

#include <caca.h>
#if defined HAVE_CONFIG_H
# include "config.h"
#endif

#include <cstdlib>
#include <cstdio>

#include <caca.h>

int main(void)
{
caca_canvas_t *cv = caca_create_canvas(16, 16);
@@ -17,7 +25,6 @@ int main(void)
fwrite(buffer, len, 1, stdout);
free(buffer);

/* Free everything */
caca_free_canvas(cv);

return 0;


Loading…
Cancel
Save