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

Last change on this file since 100 was 100, checked in by sam, 11 years ago

Slightly improve the documentation in a few files, add the missing
joystick class, and put a header in each source file.

  • Property svn:keywords set to Id
File size: 1.3 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 "sdlvideo.h"
16#include "game.h"
17#include "ticker.h"
18
19int main(int argc, char **argv)
20{
21    Video *video = new SdlVideo("Deus Hax", 640, 480);
22    Game *game = new Game("maps/testmap.tmx");
23
24    for (int done = 0; !done; )
25    {
26        /* Test stuff */
27        int mx, my;
28        SDL_GetMouseState(&mx, &my);
29        game->SetMouse(mx * (640 - 32) / 640, my * (480 - 32) / 480);
30
31        Ticker::TickGame(33.33333f);
32
33        video->PreRender();
34        Ticker::TickRender(33.33333f);
35        game->Render();
36        video->PostRender(33.33333f);
37
38        /* This could go in a separate function */
39        SDL_Event event;
40        while (SDL_PollEvent(&event))
41        {
42            if (event.type == SDL_QUIT)
43                done = 1;
44            if (event.type == SDL_KEYDOWN)
45            {
46                if (event.key.keysym.sym == SDLK_RETURN)
47                    video->FullScreen();
48                else if (event.key.keysym.sym == SDLK_ESCAPE)
49                    done = 1;
50            }
51        }
52    }
53
54    delete game;
55    delete video;
56
57    return EXIT_SUCCESS;
58}
59
Note: See TracBrowser for help on using the repository browser.