瀏覽代碼

Allow other classes to request the Game's Scene object.

legacy
Sam Hocevar sam 14 年之前
父節點
當前提交
4ba04a7bfd
共有 2 個文件被更改,包括 16 次插入6 次删除
  1. +14
    -6
      src/game.cpp
  2. +2
    -0
      src/game.h

+ 14
- 6
src/game.cpp 查看文件

@@ -26,7 +26,7 @@ private:
int mousex, mousey;
int done;

int frame;
Scene *scene;
};

/*
@@ -39,7 +39,7 @@ Game::Game(char const *mapname)
data->map = new Map(mapname);
data->x = data->y = 0;
data->done = 0;
data->frame = 0;
data->scene = NULL;
}

Game::~Game()
@@ -62,12 +62,20 @@ void Game::TickRender(float delta_time)
{
Asset::TickRender(delta_time);

Scene *scene = new Scene();
GetScene();

data->map->Render(scene, data->mousex, data->mousey, 0);
data->map->Render(data->scene, data->mousex, data->mousey, 0);
data->scene->Render();

scene->Render();
delete scene;
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)


+ 2
- 0
src/game.h 查看文件

@@ -12,6 +12,7 @@
#define __DH_GAME_H__

#include "asset.h"
#include "scene.h"

class GameData;

@@ -29,6 +30,7 @@ protected:

public:
/* New methods */
Scene *GetScene();
void SetMouse(int x, int y);
void Quit();
int Finished();


Loading…
取消
儲存