Changeset 126


Ignore:
Timestamp:
Aug 16, 2010, 2:36:36 AM (10 years ago)
Author:
sam
Message:

Minor updates here and there. Not worth mentioning.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/TODO

    r125 r126  
    88[ ] Add scripting support (lua?).
    99[ ] Open several maps at the same time.
    10 
     10[ ] See whether we should use floats or at least subpixel coordinates for
     11    on-screen objects, in order to handle velocity and other physics stuff
     12    (with rounding when displaying, of course)
    1113
    1214Performances
    1315------------
    1416[ ] Switch rendering to vertex/index buffer objects
    15 
    1617
    1718Editor
     
    2021[ ] Scroller/panner for maps.
    2122[ ] Allow to modify maps.
    22 [ ] Do GTK stuff instead of waiting for the framerate
     23[x] Do GTK stuff instead of waiting for the framerate
     24[ ] "map viewer" object/asset, as opposed to more complex in-game manager
    2325
    2426Specs
     
    2729[ ] Add special zones to the map.
    2830
    29 
    3031Architecture
    3132------------
  • trunk/src/gtk/editor.cpp

    r124 r126  
    8585        while (g_main_context_iteration(NULL, FALSE))
    8686            ;
    87         Ticker::ClampFps(FPS);
     87        Ticker::ClampFps(1.0f / FPS);
    8888    }
    8989
  • trunk/src/map.cpp

    r100 r126  
    1717#include "tiler.h"
    1818
    19 #define MAX_TILERS 128
    20 
    2119/*
    2220 * Map implementation class
     
    2725    friend class Map;
    2826
     27    static int const MAX_TILERS = 128;
     28
    2929private:
    3030    int tilers[MAX_TILERS];
    3131    int ntilers;
     32
    3233    Layer **layers;
    3334    int nlayers;
     35
     36    int width, height;
    3437};
    3538
     
    4447    data->layers = NULL;
    4548    data->nlayers = 0;
     49    data->width = 0;
     50    data->height = 0;
    4651
    4752    char tmp[BUFSIZ];
    48     int gids[MAX_TILERS];
     53    int gids[MapData::MAX_TILERS];
    4954    uint32_t *tiles = NULL;
    50     int width = 0, height = 0, level = 0, orientation = 0, ntiles = 0;
     55    int level = 0, orientation = 0, ntiles = 0;
    5156
    5257    FILE *fp = fopen(path, "r");
     
    6974             * when we have read the expected number of tiles. */
    7075            char const *parser = tmp;
    71             while (ntiles < width * height)
     76            while (ntiles < data->width * data->height)
    7277            {
    7378                uint32_t code = 0;
     
    97102            }
    98103
    99             if (ntiles == width * height)
     104            if (ntiles == data->width * data->height)
    100105            {
    101                 data->layers[data->nlayers] = new Layer(width, height, level, tiles);
     106                data->layers[data->nlayers] = new Layer(data->width,
     107                                                   data->height, level, tiles);
    102108                data->nlayers++;
    103109                tiles = NULL;
    104                 //fprintf(stderr, "new layer %ix%i\n", width, height);
     110                //fprintf(stderr, "new layer %ix%i\n", data->width, data->height);
    105111            }
    106112        }
     
    124130                                       sizeof(Layer **) * (data->nlayers + 1));
    125131            orientation = toupper(a) == 'V' ? 1 : 0;
    126             width = j;
    127             height = k;
    128             tiles = (uint32_t *)malloc(width * height * sizeof(uint32_t));
     132            data->width = j;
     133            data->height = k;
     134            tiles = (uint32_t *)malloc(j * k * sizeof(uint32_t));
    129135            ntiles = 0;
    130136        }
     
    150156}
    151157
     158int Map::GetWidth()
     159{
     160    return data->width * 32;
     161}
     162
     163int Map::GetHeight()
     164{
     165    return data->height * 32;
     166}
     167
  • trunk/src/map.h

    r100 r126  
    2525
    2626    void Render(Scene *scene, int x, int y, int z);
     27    int GetWidth();
     28    int GetHeight();
    2729
    2830private:
  • trunk/src/test-map.cpp

    r122 r126  
    6363        Ticker::TickRender();
    6464        SDL_GL_SwapBuffers();
    65         Ticker::ClampFps(FPS);
     65        Ticker::ClampFps(1.0f / FPS);
    6666    }
    6767
  • trunk/src/ticker.cpp

    r124 r126  
    129129}
    130130
    131 void Ticker::ClampFps(float fps)
     131void Ticker::ClampFps(float delta_time)
    132132{
    133133    Profiler::Stop(Profiler::STAT_TICK_BLIT);
    134134
    135     float ideal_time = 1.0f / fps;
    136     if (ideal_time > data->bias)
    137         data->timer.WaitSeconds(ideal_time - data->bias);
    138     data->bias -= ideal_time;
     135    if (delta_time > data->bias + 0.2f)
     136        delta_time = data->bias + 0.2f; // Don't go below 5 fps
     137    if (delta_time > data->bias)
     138        data->timer.WaitSeconds(delta_time - data->bias);
     139    data->bias -= delta_time;
    139140}
    140141
  • trunk/src/ticker.h

    r116 r126  
    2424    static void TickGame();
    2525    static void TickRender();
    26     static void ClampFps(float fps);
     26    static void ClampFps(float delta_time);
    2727};
    2828
Note: See TracChangeset for help on using the changeset viewer.