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

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

Replace mouse scrolling with a joystick simulated by the e/s/d/f keys.

  • Property svn:keywords set to Id
File size: 1.5 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
21static float const FPS = 30.0f;
22
23int main(int argc, char **argv)
24{
25    /* Initialise SDL */
26    if (SDL_Init(SDL_INIT_VIDEO) < 0)
27    {
28        fprintf(stderr, "Cannot initialise SDL: %s\n", SDL_GetError());
29        return EXIT_FAILURE;
30    }
31
32    SDL_Surface *video = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
33    if (!video)
34    {
35        fprintf(stderr, "Cannot create OpenGL screen: %s\n", SDL_GetError());
36        SDL_Quit();
37        return EXIT_FAILURE;
38    }
39
40    SDL_WM_SetCaption("Map Test (SDL)", NULL);
41    SDL_ShowCursor(0);
42    //SDL_WM_GrabInput(SDL_GRAB_ON);
43
44    /* Initialise OpenGL */
45    Video::Setup(video->w, video->h);
46
47    /* Create a game */
48    Game *game = new Game("maps/testmap.tmx");
49
50    /* Register an input driver and some debug stuff */
51    new SdlInput(game);
52    new DebugFps();
53    new DebugSprite(game);
54    //new DebugRecord("lolengine.ogg");
55
56    while (!game->Finished())
57    {
58        /* Tick the game */
59        Ticker::TickGame();
60
61        /* Clear the screen, tick the renderer, show the frame and
62         * clamp to desired framerate. */
63        Video::Clear();
64        Ticker::TickRender();
65        SDL_GL_SwapBuffers();
66        Ticker::ClampFps(1000.0f / FPS);
67    }
68
69    SDL_Quit();
70
71    return EXIT_SUCCESS;
72}
73
Note: See TracBrowser for help on using the repository browser.