From 46b8c4137e99b72d116c24ba98361902ad7ae3e3 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sat, 11 Dec 2010 18:11:20 +0000 Subject: Correction bug défilement du niveau si souris sortie de l'écran MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///var/svn/2010-netlemmings/trunk@195 077b3477-7977-48bd-8428-443f22f7bfda --- src/include/data_ini.h | 3 +++ src/netlem.c | 25 ++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/include/data_ini.h b/src/include/data_ini.h index b00d77a..bec4d48 100644 --- a/src/include/data_ini.h +++ b/src/include/data_ini.h @@ -1,15 +1,18 @@ #ifndef DATA_INI_H #define DATA_INI_H +// Original game level size is fixed to 1664x160. We want to display all the game with a x2 zoom #define LEVEL_WIDTH 1664*2 #define LEVEL_HEIGHT 160*2 #include "SDL/SDL_stdinc.h" +// object_* = entries from level ini files struct styleObjects { int frames, anim, type, sound; }; +// Various keys at the beginning of level ini files struct styleIni { char *name; uint32_t bgColor, debrisColor; diff --git a/src/netlem.c b/src/netlem.c index b77de1c..37193dd 100644 --- a/src/netlem.c +++ b/src/netlem.c @@ -473,7 +473,7 @@ int loadLevelProc(void *a) { #define MAP_SCROLL_BOUND 32 #define MAP_SCROLL_SPEED 16 void processLocalEvents(SDL_Rect *viewport, SDL_Rect *screen, SDL_Rect *terrain) { - static int mouseX=100, mouseY=100; + static int mouseActive=1, mouseX=100, mouseY=100; SDL_Event event; while( SDL_PollEvent( &event ) ) { @@ -504,6 +504,11 @@ void processLocalEvents(SDL_Rect *viewport, SDL_Rect *screen, SDL_Rect *terrain) default:break; } break; + case SDL_ACTIVEEVENT: + if ( event.active.state == SDL_APPMOUSEFOCUS ) { + mouseActive = event.active.gain; + } + break; case SDL_MOUSEMOTION: mouseX = event.motion.x; mouseY = event.motion.y; @@ -520,15 +525,17 @@ void processLocalEvents(SDL_Rect *viewport, SDL_Rect *screen, SDL_Rect *terrain) switch(getState()) { case eMultiGame: - if(mouseY <= terrain->h){ - if (mouseX > (screen->w - MAP_SCROLL_BOUND)){ - if (viewport->x < (terrain->w - screen->w ) ) { - viewport->x += MAP_SCROLL_SPEED; + if (mouseActive) { + if(mouseY <= terrain->h){ + if (mouseX > (screen->w - MAP_SCROLL_BOUND)){ + if (viewport->x < (terrain->w - screen->w ) ) { + viewport->x += MAP_SCROLL_SPEED; + } } - } - if (mouseX < MAP_SCROLL_BOUND){ - if (viewport->x >= MAP_SCROLL_SPEED ) { - viewport->x -= MAP_SCROLL_SPEED; + if (mouseX < MAP_SCROLL_BOUND){ + if (viewport->x >= MAP_SCROLL_SPEED ) { + viewport->x -= MAP_SCROLL_SPEED; + } } } } -- cgit v1.2.3