Changeset 150


Ignore:
Timestamp:
Aug 21, 2010, 7:50:47 PM (10 years ago)
Author:
sam
Message:

Replace mouse scrolling with a joystick simulated by the e/s/d/f keys.

Location:
trunk/src
Files:
5 added
2 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r147 r150  
    55
    66libcommon_a_SOURCES = \
    7     game.cpp game.h tiler.cpp tiler.h tileset.cpp tileset.h \
     7    core.h matrix.h game.cpp game.h tiler.cpp tiler.h \
    88    scene.cpp scene.h font.cpp font.h layer.cpp layer.h map.cpp map.h \
    9     joystick.cpp joystick.h entity.cpp entity.h ticker.cpp ticker.h \
    10     forge.cpp forge.h video.cpp video.h timer.cpp timer.h \
    11     profiler.cpp profiler.h \
     9    entity.cpp entity.h ticker.cpp ticker.h tileset.cpp tileset.h \
     10    forge.cpp forge.h video.cpp video.h timer.cpp timer.h bitfield.h \
     11    profiler.cpp profiler.h input.h input.cpp \
    1212    debugfps.cpp debugfps.h debugsprite.cpp debugsprite.h \
    1313    debugrecord.cpp debugrecord.h
  • trunk/src/debugfps.cpp

    r149 r150  
    1010#include <cstdio>
    1111
     12#include "core.h"
    1213#include "debugfps.h"
    13 #include "forge.h"
    14 #include "profiler.h"
    1514
    1615/*
  • trunk/src/debugrecord.cpp

    r149 r150  
    1313#include <pipi.h>
    1414
     15#include "core.h"
    1516#include "debugrecord.h"
    16 #include "video.h"
    1717
    1818/*
  • trunk/src/debugsprite.cpp

    r149 r150  
    1010#include <cstdio>
    1111
     12#include "core.h"
    1213#include "debugsprite.h"
    13 #include "game.h"
    14 #include "tiler.h"
    1514
    1615/*
     
    2524    Game *game;
    2625    int tiler;
    27     int frame;
     26    float x, y, z;
    2827};
    2928
     
    3736    data->game = game;
    3837    data->tiler = Tiler::Register("art/test/character-dress.png");
     38    data->x = 320;
     39    data->y = 206;
     40    data->z = 0;
    3941}
    4042
     
    4749{
    4850    Entity::TickGame(deltams);
     51
     52    Float2 axis = Input::GetAxis(0);
     53    data->x += 0.1f * deltams * axis.x;
     54    data->y += 0.1f * deltams * axis.y;
    4955}
    5056
     
    5359    Entity::TickRender(deltams);
    5460
    55     data->game->GetScene()->AddTile((data->tiler << 16) | 15, 320, 240, 32, 1);
    56     data->game->GetScene()->AddTile((data->tiler << 16) | 31, 320, 240, 0, 1);
     61    int x = data->x;
     62    int y = data->y;
     63    int z = data->z;
     64
     65    data->game->GetScene()->AddTile((data->tiler << 16) | 15, x, y, z + 32, 1);
     66    data->game->GetScene()->AddTile((data->tiler << 16) | 31, x, y, z, 1);
    5767}
    5868
  • trunk/src/entity.cpp

    r149 r150  
    1111#include <cstdio>
    1212
    13 #include "entity.h"
    14 #include "ticker.h"
     13#include "core.h"
    1514
    1615/*
  • trunk/src/font.cpp

    r149 r150  
    2222#include <SDL_image.h>
    2323
    24 #include "font.h"
     24#include "core.h"
    2525
    2626/*
  • trunk/src/forge.cpp

    r111 r150  
    1212#include <cstdlib>
    1313
    14 #include "forge.h"
     14#include "core.h"
    1515
    1616#if defined WIN32
  • trunk/src/game.cpp

    r149 r150  
    1010#include <cstdio>
    1111
    12 #include "game.h"
    13 #include "map.h"
     12#include "core.h"
    1413
    1514/*
  • trunk/src/gtk/editor.cpp

    r149 r150  
    1515#include <gtkgl/gtkglarea.h>
    1616
    17 #include "ticker.h"
     17#include "core.h"
    1818#include "debugfps.h"
    19 #include "video.h"
    20 #include "game.h"
    2119
    2220static volatile int quit = 0;
  • trunk/src/layer.cpp

    r141 r150  
    1010#include <cstdlib>
    1111
    12 #include "layer.h"
     12#include "core.h"
    1313
    1414Layer::Layer(int w, int h, int z, int o, uint32_t *in_data)
  • trunk/src/map.cpp

    r141 r150  
    1313#include <ctype.h>
    1414
    15 #include "map.h"
    16 #include "layer.h"
    17 #include "tiler.h"
     15#include "core.h"
    1816
    1917/*
  • trunk/src/profiler.cpp

    r149 r150  
    1212#include <stdint.h>
    1313
    14 #include "profiler.h"
    15 #include "timer.h"
     14#include "core.h"
    1615
    1716/*
  • trunk/src/scene.cpp

    r147 r150  
    2222#endif
    2323
    24 #include "scene.h"
    25 #include "tiler.h"
     24#include "core.h"
    2625
    2726struct Tile
  • trunk/src/sdlinput.cpp

    r149 r150  
    1010#include <SDL.h>
    1111
     12#include "core.h"
    1213#include "sdlinput.h"
    1314
     
    2223private:
    2324    Game *game;
     25    int mx, my;
    2426};
    2527
     
    3436    data = new SdlInputData();
    3537    data->game = game;
     38    SDL_GetMouseState(&data->mx, &data->my);
    3639}
    3740
     
    4952
    5053    /* Handle mouse input */
    51     int mx, my;
    52     SDL_GetMouseState(&mx, &my);
    53     data->game->SetMouse(mx * (640 - 32) / 320 - 320, my * (480 - 32) / 240 - 240);
     54    SDL_GetMouseState(&data->mx, &data->my);
    5455
    55     /* Handle keyboard and WM input */
     56    /* Handle keyboard and WM events */
    5657    SDL_Event event;
    5758    while (SDL_PollEvent(&event))
     
    5960        if (event.type == SDL_QUIT)
    6061            data->game->Quit();
    61         if (event.type == SDL_KEYDOWN)
    62         {
    63             if (event.key.keysym.sym == SDLK_ESCAPE)
    64                 data->game->Quit();
    6562#if 0
    66             else if (event.key.keysym.sym == SDLK_RETURN)
    67                 video->FullScreen();
     63        else if (event.type == SDL_KEYDOWN)
     64            Input::KeyPressed(event.key.keysym.sym, deltams);
    6865#endif
    69         }
    7066    }
    7167
     68    /* Send the whole keyboard state to the input system */
     69#if 0
     70    Uint8 *keystate = SDL_GetKeyState(NULL);
     71    for (int i = 0; i < 256; i++)
     72        if (keystate[i])
     73            Input::KeyPressed(i, deltams);
     74#endif
    7275}
    7376
  • trunk/src/test-map.cpp

    r149 r150  
    1313#include <SDL.h>
    1414
     15#include "core.h"
    1516#include "sdlinput.h"
    1617#include "debugfps.h"
    1718#include "debugsprite.h"
    1819#include "debugrecord.h"
    19 #include "game.h"
    20 #include "ticker.h"
    21 #include "profiler.h"
    22 #include "video.h"
    2320
    2421static float const FPS = 30.0f;
     
    4340    SDL_WM_SetCaption("Map Test (SDL)", NULL);
    4441    SDL_ShowCursor(0);
    45     SDL_WM_GrabInput(SDL_GRAB_ON);
     42    //SDL_WM_GrabInput(SDL_GRAB_ON);
    4643
    4744    /* Initialise OpenGL */
  • trunk/src/ticker.cpp

    r149 r150  
    1212#include <stdint.h>
    1313
    14 #include "profiler.h"
    15 #include "ticker.h"
    16 #include "entity.h"
    17 #include "timer.h"
     14#include "core.h"
    1815
    1916/*
  • trunk/src/tiler.cpp

    r138 r150  
    1212#include <cstdlib>
    1313
    14 #include "tiler.h"
    15 #include "tileset.h"
     14#include "core.h"
    1615
    1716#if defined WIN32
  • trunk/src/tileset.cpp

    r149 r150  
    2525#include <SDL_image.h>
    2626
    27 #include "tileset.h"
     27#include "core.h"
    2828
    2929/*
  • trunk/src/timer.cpp

    r149 r150  
    2323#endif
    2424
    25 #include "timer.h"
     25#include "core.h"
    2626
    2727/*
  • trunk/src/video.cpp

    r142 r150  
    1919#endif
    2020
    21 #include "video.h"
     21#include "core.h"
    2222
    2323/*
  • trunk/src/video.h

    r140 r150  
    1313#define __DH_VIDEO_H__
    1414
     15#include <stdint.h>
     16
    1517class Video
    1618{
Note: See TracChangeset for help on using the changeset viewer.