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

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

Support CSV .tmx files to get rid of that pathetic system() call.

  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1// Test stuff
2
3#include <SDL.h>
4
5#include <stdio.h>
6#include <math.h>
7
8#include "video.h"
9#include "tileset.h"
10#include "map.h"
11
12int main(int argc, char **argv)
13{
14    Video *video = new Video("Deus Hax", 640, 480);
15    Tileset *tileset = new Tileset();
16    Map *map = new Map("maps/testmap-grass.tmx");
17
18    for (int done = 0; !done; )
19    {
20        video->Clear();
21
22        map->Draw(tileset);
23
24        /* Test stuff */
25        int playerx, playery;
26        SDL_GetMouseState(&playerx, &playery);
27        playerx = playerx * (640 - 32) / 640;
28        playery = playery * (480 - 32) / 480;
29
30        tileset->AddTile(50, playerx, playery, 1);
31
32        tileset->Render();
33        video->Refresh(33.33333f);
34
35        /* This could go in a separate function */
36        SDL_Event event;
37        while (SDL_PollEvent(&event))
38        {
39            if (event.type == SDL_QUIT)
40                done = 1;
41            if (event.type == SDL_KEYDOWN)
42            {
43                if (event.key.keysym.sym == SDLK_RETURN)
44                    video->FullScreen();
45                else if (event.key.keysym.sym == SDLK_ESCAPE)
46                    done = 1;
47            }
48        }
49    }
50
51    delete map;
52    delete tileset;
53    delete video;
54
55    return EXIT_SUCCESS;
56}
57
Note: See TracBrowser for help on using the repository browser.