Changeset 289


Ignore:
Timestamp:
Jan 26, 2011, 1:33:36 AM (9 years ago)
Author:
sam
Message:

Change the way the Scene object works.

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/deushax/debugsprite.cpp

    r259 r289  
    6161    int z = data->z;
    6262
    63     data->game->GetScene()->AddTile((data->tiler << 16) | 31,
    64                                     x - 16, y, z, 1);
    65     data->game->GetScene()->AddTile((data->tiler << 16) | 15,
    66                                     x - 16, y, z + 32, 1);
     63    Scene::GetDefault()->AddTile((data->tiler << 16) | 31,
     64                                 x - 16, y, z, 1);
     65    Scene::GetDefault()->AddTile((data->tiler << 16) | 15,
     66                                 x - 16, y, z + 32, 1);
    6767}
    6868
  • trunk/deushax/game.cpp

    r259 r289  
    2626    int mousex, mousey;
    2727    int done;
    28 
    29     Scene *scene;
    3028};
    3129
     
    4038    data->x = data->y = 0;
    4139    data->done = 0;
    42     data->scene = NULL;
    4340}
    4441
     
    5855    Entity::TickDraw(deltams);
    5956
    60     GetScene();
    61 
    62     data->map->Render(data->scene, -data->mousex, -data->mousey, 0);
    63     data->scene->Render();
    64 
    65     delete data->scene;
    66     data->scene = NULL;
     57    data->map->Render(-data->mousex, -data->mousey, 0);
    6758}
    6859
     60#if 0
    6961Scene *Game::GetScene()
    7062{
     
    7365    return data->scene;
    7466}
     67#endif
    7568
    7669void Game::SetMouse(int x, int y)
  • trunk/deushax/game.h

    r221 r289  
    1313
    1414#include "entity.h"
    15 #include "scene.h"
    1615
    1716class GameData;
     
    3029public:
    3130    /* New methods */
    32     Scene *GetScene();
    3331    void SetMouse(int x, int y);
    3432    void Quit();
  • trunk/deushax/mapviewer.cpp

    r259 r289  
    2626    int povx, povy;
    2727    int done;
    28 
    29     Scene *scene;
    3028};
    3129
     
    4038    data->x = data->y = 0;
    4139    data->done = 0;
    42     data->scene = NULL;
    4340}
    4441
     
    5855    Entity::TickDraw(deltams);
    5956
    60     GetScene();
    61 
    62     data->map->Render(data->scene, -data->povx, -data->povy, 0);
    63     data->scene->Render();
    64 
    65     delete data->scene;
    66     data->scene = NULL;
    67 }
    68 
    69 Scene *MapViewer::GetScene()
    70 {
    71     if (!data->scene)
    72         data->scene = new Scene(45.0f);
    73     return data->scene;
     57    data->map->Render(-data->povx, -data->povy, 0);
    7458}
    7559
  • trunk/deushax/mapviewer.h

    r220 r289  
    1313
    1414#include "entity.h"
    15 #include "scene.h"
    1615
    1716class MapViewerData;
  • trunk/monsterz/board.cpp

    r287 r289  
    208208    Entity::TickDraw(deltams);
    209209
    210     data->game->GetScene()->AddTile((data->screen << 16) | 0, 0, 1050, 0, 0);
    211     data->game->GetScene()->AddTile((data->board << 16) | 0, 24, 912, 1, 0);
     210    Scene::GetDefault()->AddTile((data->screen << 16) | 0, 0, 1050, 0, 0);
     211    Scene::GetDefault()->AddTile((data->board << 16) | 0, 24, 912, 1, 0);
    212212
    213213    if (data->mouse.x >= 0 && data->mouse.y >= 0)
     
    215215        int x = data->mouse.x - 2;
    216216        int y = data->mouse.y + 59;
    217         data->game->GetScene()->AddTile((data->tiles << 16) | 22, x, y, 10, 0);
     217        Scene::GetDefault()->AddTile((data->tiles << 16) | 22, x, y, 10, 0);
    218218    }
    219219}
  • trunk/monsterz/game.cpp

    r259 r289  
    3030    int mousex, mousey;
    3131    int done;
    32 
    33     Scene *scene;
    3432};
    3533
     
    4341    data->x = data->y = 0;
    4442    data->done = 0;
    45     data->scene = NULL;
    4643}
    4744
     
    5956{
    6057    Entity::TickDraw(deltams);
    61 
    62     GetScene();
    63 
    64     data->scene->Render();
    65 
    66     delete data->scene;
    67     data->scene = NULL;
    68 }
    69 
    70 Scene *Game::GetScene()
    71 {
    72     if (!data->scene)
    73         data->scene = new Scene(0.0f);
    74     return data->scene;
    7558}
    7659
  • trunk/monsterz/game.h

    r221 r289  
    11//
    2 // Deus Hax (working title)
    3 // Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
     2// Monsterz
     3//
     4// Copyright: (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
     5//   This program is free software; you can redistribute it and/or
     6//   modify it under the terms of the Do What The Fuck You Want To
     7//   Public License, Version 2, as published by Sam Hocevar. See
     8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
    49//
    510
     
    1318
    1419#include "entity.h"
    15 #include "scene.h"
    1620
    1721class GameData;
     
    3034public:
    3135    /* New methods */
    32     Scene *GetScene();
    3336    void SetMouse(int x, int y);
    3437    void Quit();
  • trunk/monsterz/piece.cpp

    r287 r289  
    326326
    327327    if (data->state != PieceData::DEAD)
    328         data->game->GetScene()->AddTile((data->tiler << 16) | id, x, y, z, 0);
     328        Scene::GetDefault()->AddTile((data->tiler << 16) | id, x, y, z, 0);
    329329
    330330    if (data->state == PieceData::GRAB)
    331         data->game->GetScene()->AddTile((data->tiler << 16) | 0, x, y, 5, 0);
     331        Scene::GetDefault()->AddTile((data->tiler << 16) | 0, x, y, 5, 0);
    332332}
    333333
  • trunk/src/layer.cpp

    r221 r289  
    4141}
    4242
    43 void Layer::Render(Scene *scene, int x, int y, int z)
     43void Layer::Render(int x, int y, int z)
    4444{
     45    Scene *scene = Scene::GetDefault();
    4546    for (int j = 0; j < height; j++)
    4647        for (int i = 0; i < width; i++)
  • trunk/src/layer.h

    r221 r289  
    2020#include <stdint.h>
    2121
    22 #include "scene.h"
    23 
    2422class Layer
    2523{
     
    3028    int GetZ();
    3129
    32     void Render(Scene *scene, int x, int y, int z);
     30    void Render(int x, int y, int z);
    3331
    3432private:
  • trunk/src/map.cpp

    r259 r289  
    161161}
    162162
    163 void Map::Render(Scene *scene, int x, int y, int z)
     163void Map::Render(int x, int y, int z)
    164164{
    165165    for (int i = 0; i < data->nlayers; i++)
    166         data->layers[i]->Render(scene, x, y, z);
     166        data->layers[i]->Render(x, y, z);
    167167}
    168168
  • trunk/src/map.h

    r221 r289  
    1919#define __DH_MAP_H__
    2020
    21 #include "scene.h"
    22 
    2321class MapData;
    2422
     
    2927    ~Map();
    3028
    31     void Render(Scene *scene, int x, int y, int z);
     29    void Render(int x, int y, int z);
    3230    int GetWidth();
    3331    int GetHeight();
  • trunk/src/scene.cpp

    r259 r289  
    5555    int ntiles;
    5656    float angle;
     57
     58    static Scene *scene;
    5759};
     60
     61Scene *SceneData::scene = NULL;
    5862
    5963/*
     
    7276{
    7377    delete data;
     78}
     79
     80Scene *Scene::GetDefault()
     81{
     82    if (!SceneData::scene)
     83        SceneData::scene = new Scene(0.0f);
     84    return SceneData::scene;
     85}
     86
     87void Scene::Reset()
     88{
     89    if (SceneData::scene)
     90        delete SceneData::scene;
     91    SceneData::scene = NULL;
    7492}
    7593
  • trunk/src/scene.h

    r222 r289  
    2727    ~Scene();
    2828
     29    static Scene *GetDefault();
     30    static void Reset();
     31
    2932    void AddTile(uint32_t code, int x, int y, int z, int o);
    3033    void Render();
  • trunk/src/ticker.cpp

    r221 r289  
    225225    Profiler::Start(Profiler::STAT_TICK_DRAW);
    226226
     227    Scene::GetDefault();
     228
    227229    /* Tick objects for the draw loop */
    228230    for (int i = Entity::DRAWGROUP_BEGIN; i < Entity::DRAWGROUP_END; i++)
     
    231233        {
    232234        case Entity::DRAWGROUP_HUD:
     235            Scene::GetDefault()->Render();
    233236            Video::SetDepth(false);
    234237            break;
     
    255258    }
    256259
     260    Scene::Reset();
     261
    257262    Profiler::Stop(Profiler::STAT_TICK_DRAW);
    258263    Profiler::Start(Profiler::STAT_TICK_BLIT);
Note: See TracChangeset for help on using the changeset viewer.