Changeset 147


Ignore:
Timestamp:
Aug 21, 2010, 4:20:33 AM (10 years ago)
Author:
sam
Message:

Rename "asset" to "entity". It's way cooler.

Location:
trunk/src
Files:
19 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r144 r147  
    77    game.cpp game.h tiler.cpp tiler.h tileset.cpp tileset.h \
    88    scene.cpp scene.h font.cpp font.h layer.cpp layer.h map.cpp map.h \
    9     joystick.cpp joystick.h asset.cpp asset.h ticker.cpp ticker.h \
     9    joystick.cpp joystick.h entity.cpp entity.h ticker.cpp ticker.h \
    1010    forge.cpp forge.h video.cpp video.h timer.cpp timer.h \
    1111    profiler.cpp profiler.h \
  • trunk/src/debugfps.cpp

    r130 r147  
    3939}
    4040
    41 Asset::Group DebugFps::GetGroup()
     41Entity::Group DebugFps::GetGroup()
    4242{
    4343    return GROUP_AFTER;
     
    4646void DebugFps::TickRender(float delta_time)
    4747{
    48     Asset::TickRender(delta_time);
     48    Entity::TickRender(delta_time);
    4949
    5050    data->frame++;
  • trunk/src/debugfps.h

    r111 r147  
    1212#define __DH_DEBUGFPS_H__
    1313
    14 #include "asset.h"
     14#include "entity.h"
    1515
    1616class DebugFpsData;
    1717
    18 class DebugFps : public Asset
     18class DebugFps : public Entity
    1919{
    2020public:
  • trunk/src/debugrecord.cpp

    r144 r147  
    4343}
    4444
    45 Asset::Group DebugRecord::GetGroup()
     45Entity::Group DebugRecord::GetGroup()
    4646{
    4747    return GROUP_RENDER_CAPTURE;
     
    5050void DebugRecord::TickGame(float delta_time)
    5151{
    52     Asset::TickGame(delta_time);
     52    Entity::TickGame(delta_time);
    5353}
    5454
    5555void DebugRecord::TickRender(float delta_time)
    5656{
    57     Asset::TickRender(delta_time);
     57    Entity::TickRender(delta_time);
    5858
    5959    int width = Video::GetWidth();
  • trunk/src/debugrecord.h

    r144 r147  
    1212#define __DH_DEBUGRECORD_H__
    1313
    14 #include "asset.h"
     14#include "entity.h"
    1515
    1616class DebugRecordData;
    1717
    18 class DebugRecord : public Asset
     18class DebugRecord : public Entity
    1919{
    2020public:
  • trunk/src/debugsprite.cpp

    r141 r147  
    3939}
    4040
    41 Asset::Group DebugSprite::GetGroup()
     41Entity::Group DebugSprite::GetGroup()
    4242{
    4343    return GROUP_DEFAULT;
     
    4646void DebugSprite::TickGame(float delta_time)
    4747{
    48     Asset::TickGame(delta_time);
     48    Entity::TickGame(delta_time);
    4949}
    5050
    5151void DebugSprite::TickRender(float delta_time)
    5252{
    53     Asset::TickRender(delta_time);
     53    Entity::TickRender(delta_time);
    5454
    5555    data->game->GetScene()->AddTile((data->tiler << 16) | 15, 320, 240, 32, 1);
  • trunk/src/debugsprite.h

    r132 r147  
    1212#define __DH_DEBUGSPRITE_H__
    1313
    14 #include "asset.h"
     14#include "entity.h"
    1515#include "game.h"
    1616
    1717class DebugSpriteData;
    1818
    19 class DebugSprite : public Asset
     19class DebugSprite : public Entity
    2020{
    2121public:
  • trunk/src/entity.cpp

    r146 r147  
    1111#include <cstdio>
    1212
    13 #include "asset.h"
     13#include "entity.h"
    1414#include "ticker.h"
    1515
    1616/*
    17  * Public Asset class
     17 * Public Entity class
    1818 */
    1919
    20 Asset::Asset() :
     20Entity::Entity() :
    2121    next(0),
    2222    ref(0),
     
    2929}
    3030
    31 Asset::~Asset()
     31Entity::~Entity()
    3232{
    3333#if !FINAL_RELEASE
    3434    if (!destroy)
    35         fprintf(stderr, "ERROR: asset destructor called directly\n");
     35        fprintf(stderr, "ERROR: entity destructor called directly\n");
    3636#endif
    3737}
    3838
    39 Asset::Group Asset::GetGroup()
     39Entity::Group Entity::GetGroup()
    4040{
    4141    return GROUP_DEFAULT;
    4242}
    4343
    44 void Asset::TickGame(float delta_time)
     44void Entity::TickGame(float delta_time)
    4545{
    4646#if !FINAL_RELEASE
    4747    if (state != STATE_PRETICK_GAME)
    48         fprintf(stderr, "ERROR: invalid asset game tick\n");
     48        fprintf(stderr, "ERROR: invalid entity game tick\n");
    4949    state = STATE_POSTTICK_GAME;
    5050#endif
    5151}
    5252
    53 void Asset::TickRender(float delta_time)
     53void Entity::TickRender(float delta_time)
    5454{
    5555#if !FINAL_RELEASE
    5656    if (state != STATE_PRETICK_RENDER)
    57         fprintf(stderr, "ERROR: invalid asset render tick\n");
     57        fprintf(stderr, "ERROR: invalid entity render tick\n");
    5858    state = STATE_POSTTICK_RENDER;
    5959#endif
    6060}
    6161
    62 void Asset::Ref()
     62void Entity::Ref()
    6363{
    6464    ref++;
    6565}
    6666
    67 int Asset::Unref()
     67int Entity::Unref()
    6868{
    6969    return --ref;
  • trunk/src/entity.h

    r146 r147  
    55
    66//
    7 // The Asset class
     7// The Entity class
    88// ---------------
    9 // Assets are objects that can be ticked by the game loop and/or the render
    10 // loop. Assets are implemented as one or several linked lists. See the
     9// Entities are objects that can be ticked by the game loop and/or the render
     10// loop. Entities are implemented as one or several linked lists. See the
    1111// Ticker class for the ticking logic and the linked list implementation.
    1212//
    1313
    14 #if !defined __DH_ASSET_H__
    15 #define __DH_ASSET_H__
     14#if !defined __DH_ENTITY_H__
     15#define __DH_ENTITY_H__
    1616
    1717#include <stdint.h>
    1818
    19 class Asset
     19class Entity
    2020{
    2121    friend class Ticker;
     
    3838    Group;
    3939
    40     Asset();
    41     virtual ~Asset();
     40    Entity();
     41    virtual ~Entity();
    4242
    4343    virtual Group GetGroup();
     
    4646    virtual void TickRender(float delta_time);
    4747
    48     Asset *next;
     48    Entity *next;
    4949    int ref, destroy;
    5050
     
    6262};
    6363
    64 #endif // __DH_ASSET_H__
     64#endif // __DH_ENTITY_H__
    6565
  • trunk/src/font.cpp

    r127 r147  
    7777}
    7878
    79 Asset::Group Font::GetGroup()
     79Entity::Group Font::GetGroup()
    8080{
    8181    return GROUP_BEFORE;
     
    8484void Font::TickRender(float delta_time)
    8585{
    86     Asset::TickRender(delta_time);
     86    Entity::TickRender(delta_time);
    8787}
    8888
  • trunk/src/font.h

    r121 r147  
    1212#define __DH_FONT_H__
    1313
    14 #include "asset.h"
     14#include "entity.h"
    1515
    1616class FontData;
    1717
    18 class Font : public Asset
     18class Font : public Entity
    1919{
    2020public:
     
    2323
    2424protected:
    25     /* Inherited from Asset */
     25    /* Inherited from Entity */
    2626    virtual Group GetGroup();
    2727    virtual void TickRender(float delta_time);
  • trunk/src/game.cpp

    r137 r147  
    4949}
    5050
    51 Asset::Group Game::GetGroup()
     51Entity::Group Game::GetGroup()
    5252{
    53     return Asset::GetGroup();
     53    return Entity::GetGroup();
    5454}
    5555
    5656void Game::TickGame(float delta_time)
    5757{
    58     Asset::TickGame(delta_time);
     58    Entity::TickGame(delta_time);
    5959}
    6060
    6161void Game::TickRender(float delta_time)
    6262{
    63     Asset::TickRender(delta_time);
     63    Entity::TickRender(delta_time);
    6464
    6565    GetScene();
  • trunk/src/game.h

    r131 r147  
    1212#define __DH_GAME_H__
    1313
    14 #include "asset.h"
     14#include "entity.h"
    1515#include "scene.h"
    1616
    1717class GameData;
    1818
    19 class Game : public Asset
     19class Game : public Entity
    2020{
    2121public:
     
    2424
    2525protected:
    26     /* Inherited from Asset */
     26    /* Inherited from Entity */
    2727    virtual Group GetGroup();
    2828    virtual void TickGame(float delta_time);
  • trunk/src/gtk/editor.cpp

    r126 r147  
    3939    // FIXME: do not do anything if the previous tick was too recent?
    4040
    41     // FIXME: only quit if all assets have been cleaned
     41    // FIXME: only quit if all entities have been cleaned
    4242    if (quit)
    4343        return FALSE;
  • trunk/src/scene.cpp

    r145 r147  
    8484void Scene::Render() // XXX: rename to Blit()
    8585{
     86#if 0
     87    // Randomise, then sort.
     88    for (int i = 0; i < data->ntiles; i++)
     89    {
     90        Tile tmp = data->tiles[i];
     91        int j = rand() % data->ntiles;
     92        data->tiles[i] = data->tiles[j];
     93        data->tiles[j] = tmp;
     94    }
     95#endif
    8696    qsort(data->tiles, data->ntiles, sizeof(Tile), SceneData::Compare);
    8797
     
    92102    glTranslatef(320.0f, 240.0f, 0.0f);
    93103    glRotatef(45.0f, 1.0f, 0.0f, 0.0f);
    94     //glRotatef(5.0f + 3.0f * sinf(f), 1.0f, 0.0f, 0.0f);
    95     //glRotatef(20.0f * cosf(f), 0.0f, 0.0f, 1.0f);
    96     //glRotatef(30.0f, 0.0f, 0.0f, 1.0f);
     104#if 0
     105    glRotatef(3.0f * sinf(f), 1.0f, 0.0f, 0.0f);
     106    glRotatef(8.0f * cosf(f), 0.0f, 0.0f, 1.0f);
     107#endif
    97108    glTranslatef(-320.0f, -240.0f, 0.0f);
    98109
  • trunk/src/sdlinput.cpp

    r138 r147  
    3636}
    3737
    38 Asset::Group SdlInput::GetGroup()
     38Entity::Group SdlInput::GetGroup()
    3939{
    4040    return GROUP_BEFORE;
     
    4343void SdlInput::TickGame(float delta_time)
    4444{
    45     Asset::TickGame(delta_time);
     45    Entity::TickGame(delta_time);
    4646
    4747    if (data->game->Finished())
  • trunk/src/sdlinput.h

    r103 r147  
    1212#define __DH_SDLINPUT_H__
    1313
    14 #include "asset.h"
     14#include "entity.h"
    1515#include "game.h"
    1616
    1717class SdlInputData;
    1818
    19 class SdlInput : public Asset
     19class SdlInput : public Entity
    2020{
    2121public:
  • trunk/src/ticker.cpp

    r130 r147  
    1414#include "profiler.h"
    1515#include "ticker.h"
    16 #include "asset.h"
     16#include "entity.h"
    1717#include "timer.h"
    1818
     
    2828    TickerData() :
    2929        todo(0),
    30         nassets(0)
     30        nentities(0)
    3131    {
    32         for (int i = 0; i < Asset::GROUP_COUNT; i++)
     32        for (int i = 0; i < Entity::GROUP_COUNT; i++)
    3333            list[i] = NULL;
    3434        bias = 0.0f;
     
    3838    {
    3939#if !FINAL_RELEASE
    40         if (nassets)
    41             fprintf(stderr, "ERROR: still %i assets in ticker\n", nassets);
     40        if (nentities)
     41            fprintf(stderr, "ERROR: still %i entities in ticker\n", nentities);
    4242#endif
    4343    }
    4444
    4545private:
    46     /* Asset management */
    47     Asset *todo;
    48     Asset *list[Asset::GROUP_COUNT];
    49     int nassets;
     46    /* Entity management */
     47    Entity *todo;
     48    Entity *list[Entity::GROUP_COUNT];
     49    int nentities;
    5050
    5151    /* Fixed framerate management */
     
    6161 */
    6262
    63 void Ticker::Register(Asset *asset)
     63void Ticker::Register(Entity *entity)
    6464{
    6565    /* If we are called from its constructor, the object's vtable is not
    66      * ready yet, so we do not know which group this asset belongs to. Wait
     66     * ready yet, so we do not know which group this entity belongs to. Wait
    6767     * until the first tick. */
    68     asset->next = data->todo;
    69     data->todo = asset;
     68    entity->next = data->todo;
     69    data->todo = entity;
    7070}
    7171
     
    8383     * before inserting awaiting objects, because there is no way these
    8484     * are already marked for destruction. */
    85     for (int i = 0; i < Asset::GROUP_COUNT; i++)
    86         for (Asset *a = data->list[i], *prev = NULL; a; prev = a, a = a->next)
     85    for (int i = 0; i < Entity::GROUP_COUNT; i++)
     86        for (Entity *a = data->list[i], *prev = NULL; a; prev = a, a = a->next)
    8787            if (a->destroy)
    8888            {
     
    9292                    data->list[i] = a->next;
    9393
    94                 data->nassets--;
     94                data->nentities--;
    9595                delete a;
    9696            }
     
    9999    while (data->todo)
    100100    {
    101         Asset *a = data->todo;
     101        Entity *a = data->todo;
    102102        data->todo = a->next;
    103103
     
    105105        a->next = data->list[i];
    106106        data->list[i] = a;
    107         data->nassets++;
     107        data->nentities++;
    108108    }
    109109
    110110    /* Tick objects for the game loop */
    111     for (int i = 0; i < Asset::GROUP_COUNT; i++)
    112         for (Asset *a = data->list[i]; a; a = a->next)
     111    for (int i = 0; i < Entity::GROUP_COUNT; i++)
     112        for (Entity *a = data->list[i]; a; a = a->next)
    113113            if (!a->destroy)
    114114            {
    115115#if !FINAL_RELEASE
    116                 if (a->state != Asset::STATE_IDLE)
    117                     fprintf(stderr, "ERROR: asset not idle for game tick\n");
    118                 a->state = Asset::STATE_PRETICK_GAME;
     116                if (a->state != Entity::STATE_IDLE)
     117                    fprintf(stderr, "ERROR: entity not idle for game tick\n");
     118                a->state = Entity::STATE_PRETICK_GAME;
    119119#endif
    120120                a->TickGame(data->delta_time);
    121121#if !FINAL_RELEASE
    122                 if (a->state != Asset::STATE_POSTTICK_GAME)
    123                     fprintf(stderr, "ERROR: asset missed super game tick\n");
    124                 a->state = Asset::STATE_IDLE;
     122                if (a->state != Entity::STATE_POSTTICK_GAME)
     123                    fprintf(stderr, "ERROR: entity missed super game tick\n");
     124                a->state = Entity::STATE_IDLE;
    125125#endif
    126126            }
     
    134134
    135135    /* Tick objects for the render loop */
    136     for (int i = 0; i < Asset::GROUP_COUNT; i++)
    137         for (Asset *a = data->list[i]; a; a = a->next)
     136    for (int i = 0; i < Entity::GROUP_COUNT; i++)
     137        for (Entity *a = data->list[i]; a; a = a->next)
    138138            if (!a->destroy)
    139139            {
    140140#if !FINAL_RELEASE
    141                 if (a->state != Asset::STATE_IDLE)
    142                     fprintf(stderr, "ERROR: asset not idle for render tick\n");
    143                 a->state = Asset::STATE_PRETICK_RENDER;
     141                if (a->state != Entity::STATE_IDLE)
     142                    fprintf(stderr, "ERROR: entity not idle for render tick\n");
     143                a->state = Entity::STATE_PRETICK_RENDER;
    144144#endif
    145145                a->TickRender(data->delta_time);
    146146#if !FINAL_RELEASE
    147                 if (a->state != Asset::STATE_POSTTICK_RENDER)
    148                     fprintf(stderr, "ERROR: asset missed super render tick\n");
    149                 a->state = Asset::STATE_IDLE;
     147                if (a->state != Entity::STATE_POSTTICK_RENDER)
     148                    fprintf(stderr, "ERROR: entity missed super render tick\n");
     149                a->state = Entity::STATE_IDLE;
    150150#endif
    151151            }
  • trunk/src/ticker.h

    r126 r147  
    77// The Ticker class
    88// ----------------
    9 // The Ticker is a static class that registers assets and ticks them.
     9// The Ticker is a static class that registers entities and ticks them.
    1010//
    1111
     
    1515#include <stdint.h>
    1616
    17 #include "asset.h"
     17#include "entity.h"
    1818
    1919class Ticker
    2020{
    2121public:
    22     static void Register(Asset *asset);
     22    static void Register(Entity *entity);
    2323
    2424    static void TickGame();
  • trunk/src/tileset.cpp

    r138 r147  
    7575}
    7676
    77 Asset::Group TileSet::GetGroup()
     77Entity::Group TileSet::GetGroup()
    7878{
    7979    return GROUP_BEFORE;
     
    8282void TileSet::TickRender(float delta_time)
    8383{
    84     Asset::TickRender(delta_time);
     84    Entity::TickRender(delta_time);
    8585
    8686    if (data->img)
  • trunk/src/tileset.h

    r138 r147  
    1717#include <stdint.h>
    1818
    19 #include "asset.h"
     19#include "entity.h"
    2020
    2121class TileSetData;
    2222
    23 class TileSet : public Asset
     23class TileSet : public Entity
    2424{
    2525public:
     
    2828
    2929protected:
    30     /* Inherited from Asset */
     30    /* Inherited from Entity */
    3131    virtual Group GetGroup();
    3232    virtual void TickRender(float delta_time);
Note: See TracChangeset for help on using the changeset viewer.