joystick class, and put a header in each source file.legacy
| @@ -4,17 +4,17 @@ noinst_PROGRAMS = test-map editor | |||||
| noinst_LIBRARIES = libcommon.a | noinst_LIBRARIES = libcommon.a | ||||
| libcommon_a_SOURCES = \ | 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` | 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_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image` | ||||
| test_map_LDADD = libcommon.a | test_map_LDADD = libcommon.a | ||||
| test_map_LDFLAGS = `pkg-config --libs sdl gl SDL_image` | 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_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image gtk+-2.0 gtkgl-2.0` | ||||
| editor_LDADD = libcommon.a | editor_LDADD = libcommon.a | ||||
| editor_LDFLAGS = `pkg-config --libs sdl gl gtk+-2.0 gtkgl-2.0 SDL_image` | editor_LDFLAGS = `pkg-config --libs sdl gl gtk+-2.0 gtkgl-2.0 SDL_image` | ||||
| @@ -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> | #include <cstdlib> | ||||
| @@ -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__ | #if !defined __DH_ASSET_H__ | ||||
| #define __DH_ASSET_H__ | #define __DH_ASSET_H__ | ||||
| @@ -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 | #ifdef WIN32 | ||||
| # define WIN32_LEAN_AND_MEAN | # define WIN32_LEAN_AND_MEAN | ||||
| @@ -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__ | #if !defined __DH_FONT_H__ | ||||
| #define __DH_FONT_H__ | #define __DH_FONT_H__ | ||||
| @@ -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 <cstdio> | ||||
| @@ -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__ | #if !defined __DH_GAME_H__ | ||||
| #define __DH_GAME_H__ | #define __DH_GAME_H__ | ||||
| @@ -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 <cstdio> | ||||
| #include <cmath> | #include <cmath> | ||||
| @@ -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> | #include <cstdlib> | ||||
| @@ -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__ | #if !defined __DH_GTKVIDEO_H__ | ||||
| #define __DH_GTKVIDEO_H__ | #define __DH_GTKVIDEO_H__ | ||||
| @@ -16,9 +21,6 @@ public: | |||||
| GtkVideo(char const *title, int width, int height); | GtkVideo(char const *title, int width, int height); | ||||
| virtual ~GtkVideo(); | virtual ~GtkVideo(); | ||||
| // New | |||||
| void *GetWidget(); | |||||
| // Inherited | // Inherited | ||||
| virtual int GetWidth() const; | virtual int GetWidth() const; | ||||
| virtual int GetHeight() const; | virtual int GetHeight() const; | ||||
| @@ -26,6 +28,9 @@ public: | |||||
| virtual void PostRender(float milliseconds); | virtual void PostRender(float milliseconds); | ||||
| virtual void FullScreen(); | virtual void FullScreen(); | ||||
| // New | |||||
| void *GetWidget(); | |||||
| private: | private: | ||||
| GtkVideoData *data; | GtkVideoData *data; | ||||
| }; | }; | ||||
| @@ -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() | |||||
| { | |||||
| } | |||||
| @@ -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__ | |||||
| @@ -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> | #include <stdlib.h> | ||||
| @@ -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__ | #if !defined __DH_LAYER_H__ | ||||
| #define __DH_LAYER_H__ | #define __DH_LAYER_H__ | ||||
| @@ -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 <cstdio> | ||||
| #include <cstring> | #include <cstring> | ||||
| @@ -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__ | #if !defined __DH_MAP_H__ | ||||
| #define __DH_MAP_H__ | #define __DH_MAP_H__ | ||||
| @@ -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> | #include <stdlib.h> | ||||
| @@ -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__ | #if !defined __DH_SCENE_H__ | ||||
| #define __DH_SCENE_H__ | #define __DH_SCENE_H__ | ||||
| @@ -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 | #ifdef WIN32 | ||||
| # define WIN32_LEAN_AND_MEAN | # define WIN32_LEAN_AND_MEAN | ||||
| @@ -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__ | #if !defined __DH_SDLVIDEO_H__ | ||||
| #define __DH_SDLVIDEO_H__ | #define __DH_SDLVIDEO_H__ | ||||
| @@ -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 <cstdio> | ||||
| #include <cmath> | #include <cmath> | ||||
| @@ -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 <cstdlib> | ||||
| #include <cstdio> | #include <cstdio> | ||||
| @@ -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__ | #if !defined __DH_TICKER_H__ | ||||
| #define __DH_TICKER_H__ | #define __DH_TICKER_H__ | ||||
| @@ -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 <cstring> | ||||
| #include <cstdio> | #include <cstdio> | ||||
| @@ -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__ | #if !defined __DH_TILER_H__ | ||||
| #define __DH_TILER_H__ | #define __DH_TILER_H__ | ||||
| @@ -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> | #include <cstdlib> | ||||
| @@ -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__ | #if !defined __DH_TILESET_H__ | ||||
| #define __DH_TILESET_H__ | #define __DH_TILESET_H__ | ||||
| @@ -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__ | #if !defined __DH_VIDEO_H__ | ||||
| #define __DH_VIDEO_H__ | #define __DH_VIDEO_H__ | ||||
| @@ -9,9 +15,6 @@ | |||||
| class Video | class Video | ||||
| { | { | ||||
| public: | public: | ||||
| //Video(char const *title, int width, int height); | |||||
| //virtual ~Video(); | |||||
| virtual int GetWidth() const = 0; | virtual int GetWidth() const = 0; | ||||
| virtual int GetHeight() const = 0; | virtual int GetHeight() const = 0; | ||||
| virtual void PreRender() = 0; | virtual void PreRender() = 0; | ||||
| @@ -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 <cstdlib> | ||||
| #include <cstdio> | #include <cstdio> | ||||
| #include <caca.h> | |||||
| int main(void) | int main(void) | ||||
| { | { | ||||
| caca_canvas_t *cv = caca_create_canvas(16, 16); | caca_canvas_t *cv = caca_create_canvas(16, 16); | ||||
| @@ -17,7 +25,6 @@ int main(void) | |||||
| fwrite(buffer, len, 1, stdout); | fwrite(buffer, len, 1, stdout); | ||||
| free(buffer); | free(buffer); | ||||
| /* Free everything */ | |||||
| caca_free_canvas(cv); | caca_free_canvas(cv); | ||||
| return 0; | return 0; | ||||