Changeset 103


Ignore:
Timestamp:
Aug 11, 2010, 6:18:48 PM (10 years ago)
Author:
sam
Message:

Reimplement the SDL input as a ticked asset object.

Location:
trunk/src
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r100 r103  
    1010libcommon_a_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image`
    1111
    12 test_map_SOURCES = test-map.cpp sdlvideo.cpp sdlvideo.h
     12test_map_SOURCES = test-map.cpp sdlvideo.cpp sdlvideo.h sdlinput.cpp sdlinput.h
    1313test_map_CXXFLAGS = `pkg-config --cflags sdl gl SDL_image`
    1414test_map_LDADD = libcommon.a
  • trunk/src/test-map.cpp

    r102 r103  
    1414
    1515#include "sdlvideo.h"
     16#include "sdlinput.h"
    1617#include "game.h"
    1718#include "ticker.h"
     
    2223    Game *game = new Game("maps/testmap.tmx");
    2324
     25    /* Register the input driver */
     26    new SdlInput(game);
     27
    2428    while (!game->Finished())
    2529    {
    26         /* Test stuff */
    27         int mx, my;
    28         SDL_GetMouseState(&mx, &my);
    29         game->SetMouse(mx * (640 - 32) / 640, my * (480 - 32) / 480);
    30 
    3130        Ticker::TickGame(33.33333f);
    3231
     
    3534        game->Render();
    3635        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                 game->Quit();
    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                     game->Quit();
    50             }
    51         }
    5236    }
    5337
Note: See TracChangeset for help on using the changeset viewer.