source: trunk/deushax/deushax.cpp @ 297

Last change on this file since 297 was 227, checked in by sam, 12 years ago

Spawn several pieces in Monsterz now that we can.

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