Browse Source

Add a sprite following the mouse.

legacy
Sam Hocevar sam 14 years ago
parent
commit
b7e768c3c9
2 changed files with 13 additions and 0 deletions
  1. +11
    -0
      src/test-map.cpp
  2. +2
    -0
      src/video.cpp

+ 11
- 0
src/test-map.cpp View File

@@ -31,6 +31,9 @@ int *layers[128];
int width = 32, height = 32;
int nlayers = 0;

/* Player coordinates */
int playerx = 0, playery = 0;

// Load Bitmaps And Convert To Textures
void LoadGLTextures(void)
{
@@ -196,7 +199,13 @@ void DrawScene()
glLoadIdentity();

for (int i = 0; i < nlayers; i++)
{
glPushMatrix();
if (i == 2)
glTranslatef(playerx, playery, 0.0f);
PutMap(layers[i], width, height);
glPopMatrix();
}
}

int main(int argc, char **argv)
@@ -217,6 +226,8 @@ int main(int argc, char **argv)

video->Refresh(33.33333f);

SDL_GetMouseState(&playerx, &playery);

/* This could go in a separate function */
SDL_Event event;
while (SDL_PollEvent(&event))


+ 2
- 0
src/video.cpp View File

@@ -53,6 +53,8 @@ Video::Video(char const *title, int width, int height)
}

SDL_WM_SetCaption(title, NULL);
SDL_ShowCursor(0);
SDL_WM_GrabInput(SDL_GRAB_ON);

/* Initialise OpenGL */
glViewport(0, 0, data->video->w, data->video->h);


Loading…
Cancel
Save