Browse Source

Start creating the World class.

legacy
Sam Hocevar sam 14 years ago
parent
commit
83a82034ae
4 changed files with 119 additions and 2 deletions
  1. +3
    -2
      src/Makefile.am
  2. +1
    -0
      src/core.h
  3. +74
    -0
      src/world.cpp
  4. +41
    -0
      src/world.h

+ 3
- 2
src/Makefile.am View File

@@ -8,7 +8,7 @@ libcommon_a_SOURCES = \
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 \
profiler.cpp profiler.h input.h input.cpp mapviewer.cpp mapviewer.h \
profiler.cpp profiler.h input.h input.cpp world.cpp world.h \
debugfps.cpp debugfps.h debugsprite.cpp debugsprite.h \
debugrecord.cpp debugrecord.h
libcommon_a_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image`
@@ -18,7 +18,8 @@ test_map_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image` @PIPI_CFLAGS@
test_map_LDADD = libcommon.a
test_map_LDFLAGS = `pkg-config --libs sdl gl SDL_image` @PIPI_LIBS@

editor_SOURCES = gtk/editor.cpp gtk/glmapview.cpp gtk/glmapview.h
editor_SOURCES = gtk/editor.cpp gtk/glmapview.cpp gtk/glmapview.h \
mapviewer.cpp mapviewer.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`


+ 1
- 0
src/core.h View File

@@ -27,6 +27,7 @@
#include "game.h"
#include "tileset.h"
#include "mapviewer.h"
#include "world.h"

// Other objects
#include "dict.h"


+ 74
- 0
src/world.cpp View File

@@ -0,0 +1,74 @@
//
// 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>
#include <cstdlib>
#include <ctype.h>

#include "core.h"

/*
* World implementation class
*/

class WorldData
{
friend class World;

private:
int width, height;
};

/*
* Public World class
*/

World::World()
{
data = new WorldData();
data->width = 0;
data->height = 0;
}

World::~World()
{
delete data;
}

Entity::Group World::GetGroup()
{
return GROUP_BEFORE;
}

char const *World::GetName()
{
return "<world>";
}

void World::TickGame(float deltams)
{
Entity::TickGame(deltams);
}

void World::TickDraw(float deltams)
{
Entity::TickDraw(deltams);
}

int World::GetWidth()
{
return data->width * 32;
}

int World::GetHeight()
{
return data->height * 32;
}


+ 41
- 0
src/world.h View File

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

//
// The World class
// ---------------
//

#if !defined __DH_WORLD_H__
#define __DH_WORLD_H__

#include "entity.h"

class WorldData;

class World : public Entity
{
public:
World();
virtual ~World();

protected:
/* Inherited from Entity */
virtual char const *GetName();
virtual Group GetGroup();
virtual void TickGame(float deltams);
virtual void TickDraw(float deltams);

public:
/* New methods */
int GetWidth();
int GetHeight();

private:
WorldData *data;
};

#endif // __DH_WORLD_H__


Loading…
Cancel
Save