summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2010-12-11 18:11:20 +0000
committerLudovic Pouzenc <ludovic@pouzenc.fr>2010-12-11 18:11:20 +0000
commit46b8c4137e99b72d116c24ba98361902ad7ae3e3 (patch)
treea719e1efce36c99bf662ca067125ca50b874e1d8
parent82d69d291f29aba4fb04872e79f21d662a6c3d9f (diff)
download2010-netlemmings-46b8c4137e99b72d116c24ba98361902ad7ae3e3.tar.gz
2010-netlemmings-46b8c4137e99b72d116c24ba98361902ad7ae3e3.tar.bz2
2010-netlemmings-46b8c4137e99b72d116c24ba98361902ad7ae3e3.zip
Correction bug défilement du niveau si souris sortie de l'écran
git-svn-id: file:///var/svn/2010-netlemmings/trunk@195 077b3477-7977-48bd-8428-443f22f7bfda
-rw-r--r--src/include/data_ini.h3
-rw-r--r--src/netlem.c25
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;
+ }
}
}
}