source: trunk/src/test-map.cpp @ 203

Last change on this file since 203 was 203, checked in by sam, 10 years ago

Add a stats logger entity.

  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1//
2// Deus Hax (working title)
3// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
4//
5
6#if defined HAVE_CONFIG_H
7#   include "config.h"
8#endif
9
10#include <cstdio>
11#include <cmath>
12
13#include <SDL.h>
14
15#include "core.h"
16#include "sdlinput.h"
17#include "debugfps.h"
18#include "debugsprite.h"
19#include "debugrecord.h"
20#include "debugstats.h"
21
22static float const FPS = 30.0f;
23
24int main(int argc, char **argv)
25{
26    /* Initialise SDL */
27    if (SDL_Init(SDL_INIT_VIDEO) < 0)
28    {
29        fprintf(stderr, "Cannot initialise SDL: %s\n", SDL_GetError());
30        return EXIT_FAILURE;
31    }
32
33    SDL_Surface *video = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
34    if (!video)
35    {
36        fprintf(stderr, "Cannot create OpenGL screen: %s\n", SDL_GetError());
37        SDL_Quit();
38        return EXIT_FAILURE;
39    }
40
41    SDL_WM_SetCaption("Map Test (SDL)", NULL);
42    SDL_ShowCursor(0);
43    //SDL_WM_GrabInput(SDL_GRAB_ON);
44
45    /* Initialise OpenGL */
46    Video::Setup(video->w, video->h);
47
48    /* Create a game */
49    Game *game = new Game("maps/testmap2.tmx");
50
51    /* Register an input driver and some debug stuff */
52    new SdlInput();
53    new DebugFps();
54    new DebugSprite(game);
55    //new DebugRecord("lolengine.ogg");
56    new DebugStats("stats.txt");
57
58    while (!Ticker::Finished())
59    {
60        /* Tick the game */
61        Ticker::TickGame();
62
63        /* Clear the screen, tick the renderer, show the frame and
64         * clamp to desired framerate. */
65        Video::Clear();
66        Ticker::TickDraw();
67        SDL_GL_SwapBuffers();
68        Ticker::ClampFps(1000.0f / FPS);
69    }
70
71    SDL_Quit();
72
73    return EXIT_SUCCESS;
74}
75
Note: See TracBrowser for help on using the repository browser.