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
RevLine 
[100]1//
2// Deus Hax (working title)
3// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
4//
[13]5
[100]6#if defined HAVE_CONFIG_H
7#   include "config.h"
8#endif
9
[98]10#include <cstdio>
11#include <cmath>
12
[13]13#include <SDL.h>
14
[90]15#include "sdlvideo.h"
[79]16#include "game.h"
[96]17#include "ticker.h"
[14]18
[38]19int main(int argc, char **argv)
20{
[90]21    Video *video = new SdlVideo("Deus Hax", 640, 480);
[93]22    Game *game = new Game("maps/testmap.tmx");
[13]23
[38]24    for (int done = 0; !done; )
[20]25    {
[38]26        /* Test stuff */
[79]27        int mx, my;
28        SDL_GetMouseState(&mx, &my);
29        game->SetMouse(mx * (640 - 32) / 640, my * (480 - 32) / 480);
[13]30
[96]31        Ticker::TickGame(33.33333f);
32
33        video->PreRender();
34        Ticker::TickRender(33.33333f);
[79]35        game->Render();
[93]36        video->PostRender(33.33333f);
[13]37
[18]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        }
[13]52    }
[14]53
[79]54    delete game;
[18]55    delete video;
[14]56
[18]57    return EXIT_SUCCESS;
[13]58}
59
Note: See TracBrowser for help on using the repository browser.