summaryrefslogtreecommitdiff
path: root/sdl-test
diff options
context:
space:
mode:
authorDamien Appert <dappert>2010-11-17 12:28:48 +0000
committerDamien Appert <dappert>2010-11-17 12:28:48 +0000
commit3b90bf04c8fb6935fa6be7d907d69ea0fddc8218 (patch)
tree832cb57783d93bd22ab95e0d7de0579e382e3486 /sdl-test
parent75d794c84242e812fa54f5c5578d10eb36d43c68 (diff)
download2010-netlemmings-3b90bf04c8fb6935fa6be7d907d69ea0fddc8218.tar.gz
2010-netlemmings-3b90bf04c8fb6935fa6be7d907d69ea0fddc8218.tar.bz2
2010-netlemmings-3b90bf04c8fb6935fa6be7d907d69ea0fddc8218.zip
cursor done ... code louche qui marche
git-svn-id: file:///var/svn/2010-netlemmings/trunk@152 077b3477-7977-48bd-8428-443f22f7bfda
Diffstat (limited to 'sdl-test')
-rw-r--r--sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c135
-rw-r--r--sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy5
2 files changed, 103 insertions, 37 deletions
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c
index 61b5513..5cc9a46 100644
--- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c
+++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/fonctions_non_integrees.c
@@ -1708,6 +1708,8 @@ int stateLemming(struct gameInit *gInit){
//curseur
gInit->mapI.cross.oldX=0;
gInit->mapI.cross.oldY=0;
+ gInit->mapI.cross.oldXI=0;
+ gInit->mapI.cross.oldYI=0;
gInit->mapI.cross.sizeC=0;
gInit->mapI.cross.numScreen=0;
gInit->mapI.cross.imgC=NULL;
@@ -1812,7 +1814,7 @@ int stateLemming(struct gameInit *gInit){
gInit->l.ll->data.pl->cptBrick=0;
gInit->l.ll->data.pl->oldX=k->x;
gInit->l.ll->data.pl->oldY=k->y;
- gInit->l.ll->data.pl->imgF=SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_HWACCEL|SDL_ASYNCBLIT|SDL_RLEACCEL, 32, 20,
+ gInit->l.ll->data.pl->imgF=SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_HWACCEL|/*SDL_ASYNCBLIT|*/SDL_RLEACCEL, 32, 20,
SCREEN_BPP,0,0,0,0);
SDL_SetColorKey(gInit->l.ll->data.pl->imgF, SDL_SRCCOLORKEY|SDL_RLEACCEL, 0);
//SDL_SetColorKey(gInit->l.ll->data.pl->imgF, SDL_SRCCOLORKEY|SDL_RLEACCEL, gInit->mapI.map.cmap.bgColor);
@@ -3018,12 +3020,12 @@ int findTerrain( struct gameInit *gInit,int x, int y, int x0){
int paint_cursor(SDL_Surface *dst1, SDL_Surface *src, int x, int y, int x0, struct gameInit *gInit)
{
- SDL_Rect from, to, before;
+ SDL_Rect from, to, before, after;
int f=0;
int err=0;
struct listeSimplementChainee *k=NULL;
- //Restauration
+ //Restauration
if(gInit->mapI.cross.numScreen==0){
to.x=gInit->mapI.cross.oldX;
@@ -3033,8 +3035,14 @@ int paint_cursor(SDL_Surface *dst1, SDL_Surface *src, int x, int y, int x0, stru
if(gInit->mapI.cross.numScreen==1){
to.x=gInit->mapI.cross.oldX;
- to.y=gInit->mapI.cross.oldY;
- test_blit(gInit->mapI.cross.imgC, NULL, pSpr_Lem, &to,0);
+ to.y=gInit->mapI.cross.oldY;
+ if((gInit->mapI.cross.numSwitch==0)||(gInit->mapI.cross.numSwitch==2)||(gInit->mapI.cross.numSwitch==6)){
+ test_blit(gInit->mapI.cross.imgC, NULL, pSpr_Lem, &to,0);
+ }
+ if((gInit->mapI.cross.numSwitch==1)||(gInit->mapI.cross.numSwitch==3)||(gInit->mapI.cross.numSwitch==5)){
+ test_blit(gInit->mapI.cross.imgC, NULL, pStencil, &to,0);
+ }
+
}
if(gInit->mapI.cross.numScreen==2){
@@ -3043,17 +3051,24 @@ int paint_cursor(SDL_Surface *dst1, SDL_Surface *src, int x, int y, int x0, stru
from.y=0;
to.x=gInit->mapI.cross.oldX;
to.y=gInit->mapI.cross.oldY;
- from.w=gInit->mapI.cross.imgC->w;
- from.h=gInit->mapI.cross.sizeC;
- test_blit(gInit->mapI.cross.imgC, NULL, pSpr_Lem, &to,0);
+ to.w=from.w=gInit->mapI.cross.imgC->w;
+ to.h=from.h=gInit->mapI.cross.sizeC;
+ if((gInit->mapI.cross.numSwitch==0)||(gInit->mapI.cross.numSwitch==2)||(gInit->mapI.cross.numSwitch==6)){
+ test_blit(gInit->mapI.cross.imgC, &from, pSpr_Lem, &to,0);
+ }
+ if((gInit->mapI.cross.numSwitch==1)||(gInit->mapI.cross.numSwitch==3)||(gInit->mapI.cross.numSwitch==5)){
+ test_blit(gInit->mapI.cross.imgC, &from, pStencil, &to,0);
+ }
to.x=gInit->mapI.cross.oldXI;
- to.y=gInit->mapI.cross.oldY-LEVEL_HEIGHT;
+ to.y=gInit->mapI.cross.oldYI;// - LEVEL_HEIGHT;
+
from.y=gInit->mapI.cross.sizeC;
- from.w=gInit->mapI.cross.imgC->w;
- from.h=gInit->mapI.cross.imgC->h-gInit->mapI.cross.sizeC;
- test_blit(gInit->mapI.cross.imgC, NULL,pInterface, &to,0);
+ to.w=from.w=gInit->mapI.cross.imgC->w;
+ to.h=from.h=1000;//gInit->mapI.cross.imgC->h-gInit->mapI.cross.sizeC;
+
+ test_blit(gInit->mapI.cross.imgC, /*&from*/NULL,pInterface, &to,0);
}
/* Render! */
@@ -3073,9 +3088,10 @@ int paint_cursor(SDL_Surface *dst1, SDL_Surface *src, int x, int y, int x0, stru
to.w=gInit->mapI.cross.imgC->w;
to.h=gInit->mapI.cross.imgC->h;
gInit->mapI.cross.numScreen=0;
+ test_FillRect(gInit->mapI.cross.imgC, NULL, gInit->mapI.map.cmap.bgColor,0);
test_blit(pInterface, &to, gInit->mapI.cross.imgC, NULL,0);
-
test_blit(src, &from, pInterface, &to,0);
+
} else {
k=gInit->l.ll;
while(k != NULL){
@@ -3115,36 +3131,52 @@ int paint_cursor(SDL_Surface *dst1, SDL_Surface *src, int x, int y, int x0, stru
}
k=k->next;
}
- to.y -= 4;
+ //to.y -= 4;
//Save
before.x=gInit->mapI.cross.oldX=to.x;
- before.y=gInit->mapI.cross.oldY=to.y;
+ before.y=gInit->mapI.cross.oldY=to.y ;
before.w=gInit->mapI.cross.imgC->w;
- gInit->mapI.cross.sizeC=( ((LEVEL_HEIGHT-y-from.h)<0)? gInit->mapI.cross.imgC->h-LEVEL_HEIGHT-y-from.h : gInit->mapI.cross.imgC->h );
+ //printf("(LEVEL_HEIGHT %d - y %d = %d \n",LEVEL_HEIGHT,y,(LEVEL_HEIGHT-y));
+ gInit->mapI.cross.sizeC=( ((LEVEL_HEIGHT-y-from.h)<0)? (LEVEL_HEIGHT-y) : gInit->mapI.cross.imgC->h );
before.h=gInit->mapI.cross.sizeC;
gInit->mapI.cross.numScreen=1;
- test_blit(dst1, &before, gInit->mapI.cross.imgC, NULL,0);
-
+ after.x=0;
+ after.y=0;
+ after.w=before.w;
+ after.h=gInit->mapI.cross.sizeC;
+ test_FillRect(gInit->mapI.cross.imgC, NULL, gInit->mapI.map.cmap.bgColor,0);
+ test_blit(dst1, &before, gInit->mapI.cross.imgC, &after,0);
+
test_blit(src, &from, dst1, &to,0);
- if(y+from.h>LEVEL_HEIGHT){
- to.x = (f==1)? k->x-x + x0:x0;
- to.y = (f==1)? k->y - 4 - LEVEL_HEIGHT :y -4 - LEVEL_HEIGHT;
- // Save
+ if((gInit->mapI.cross.sizeC >= 0)&&(gInit->mapI.cross.sizeC < from.h)){
+ to.x = (f==1)? k->x-x + x0 : x0;
+ to.y = (f==1)? k->y /*- 4*/ - LEVEL_HEIGHT : y /*- 4*/ - LEVEL_HEIGHT ;
+ // Save
to.w=gInit->mapI.cross.imgC->w;
- to.h=gInit->mapI.cross.imgC->h-gInit->mapI.cross.sizeC;
+ to.h=gInit->mapI.cross.imgC->h - gInit->mapI.cross.sizeC;
+
+ gInit->mapI.cross.oldXI=to.x;
+ gInit->mapI.cross.oldYI=to.y;
+
+ before.x=0;
- before.x=gInit->mapI.cross.oldXI=to.x;
before.y=gInit->mapI.cross.sizeC;
before.w=gInit->mapI.cross.imgC->w;
- before.h=gInit->mapI.cross.imgC->h-gInit->mapI.cross.sizeC;
+ before.h=to.h;
+
+ //printf("gInit->mapI.cross.imgC->h %d -gInit->mapI.cross.sizeC %d = %d \n",gInit->mapI.cross.imgC->h,gInit->mapI.cross.sizeC,gInit->mapI.cross.imgC->h-gInit->mapI.cross.sizeC);
gInit->mapI.cross.numScreen=2;
+
+ test_FillRect(gInit->mapI.cross.imgC, &before, ccc_bgStencil,0);
test_blit(pInterface, &to, gInit->mapI.cross.imgC, &before,0);
+ //test_FillRect(gInit->mapI.cross.imgC, &before, ccc_red,0);
test_blit(src, &from, pInterface, &to,0);
+
}
}
gInit->cptGame[18]=0;
@@ -3509,10 +3541,10 @@ int lancement (){
SDL_WM_SetCaption( gInit.mapI.name , NULL );
- gInit.mapI.cross.imgC=SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_HWACCEL|SDL_ASYNCBLIT|SDL_RLEACCEL, gInit.mapI.map.tabGif[3]->w , gInit.mapI.map.tabGif[3]->h/8,
+ gInit.mapI.cross.imgC=SDL_CreateRGBSurface(SDL_HWSURFACE|SDL_HWACCEL|/*SDL_ASYNCBLIT|*/SDL_RLEACCEL, gInit.mapI.map.tabGif[3]->w , gInit.mapI.map.tabGif[3]->h/8,
SCREEN_BPP,0,0,0,0);
- SDL_SetColorKey(pTerrain, SDL_SRCCOLORKEY|SDL_RLEACCEL, gInit.mapI.map.cmap.bgColor);
- SDL_SetColorKey(pTerrain, SDL_SRCCOLORKEY|SDL_RLEACCEL, ccc_bgStencil);
+ //SDL_SetColorKey(pTerrain, SDL_SRCCOLORKEY|SDL_RLEACCEL, gInit.mapI.map.cmap.bgColor);
+ //SDL_SetColorKey(pTerrain, SDL_SRCCOLORKEY|SDL_RLEACCEL, ccc_bgStencil);
mouseX = gInit.mapI.xPos;
camera.x=gInit.mapI.xPos;
@@ -3584,7 +3616,7 @@ int lancement (){
case SDLK_END : decalFps = FPS-11; break;
case SDLK_PAGEUP : if(decalFps>0){decalFps -=1;}break;
case SDLK_PAGEDOWN : if(decalFps<(FPS-1)){decalFps +=1;}break;
- case SDLK_w : paint_stencil = (paint_stencil==0)? 1 : 0 ; break;
+ case SDLK_w : paint_stencil= (paint_stencil==0)? 1 : ((paint_stencil==1)? 2 : ((paint_stencil==2)? 3 : 0)) ;break;
case SDLK_x : switchMiniMapMode= (switchMiniMapMode==0)? 1 : ((switchMiniMapMode==1)? 2 : ((switchMiniMapMode==2)? 3 : 0)) ;break;
case SDLK_p :{
zoomX=((zoomX >= 1. )? zoomX + 1. : zoomX + 0.1 );
@@ -3681,7 +3713,8 @@ int lancement (){
if(paint_stencil==0){
err=paint_interface (&gInit);
if(err!=0){return err;}
- } else {
+ }
+ if(paint_stencil==2){
//testAlpha(screen, gInit.mapI.map.tabGif[9],gInit.mapI.map.tabGif[1],2,330);
err=legende (&gInit);
if(err!=0){return err;}
@@ -3695,13 +3728,15 @@ int lancement (){
if(paint_stencil==0){
err=miniMap (pSpr_Lem,mouseX+camera.x,mouseY+camera.y,zoomX,zoomY);//0.10,0.10); 5.,5.);
if( err != 0){ return err;}
- } else {
+ }
+ if(paint_stencil==2){
err=miniMap (pStencil,mouseX+camera.x,mouseY+camera.y,zoomX,zoomY);
if( err != 0){ return err;}
}} else {
if(paint_stencil==0){
test_blit(gInit.mapI.miniMapLem,NULL , pInterface, &miniMapR,0);
- } else {
+ }
+ if(paint_stencil==2){
test_blit(gInit.mapI.miniMapLem,NULL , pInterface, &miniMapR,0);
}
@@ -3709,18 +3744,48 @@ int lancement (){
// CURSOR => pSpr_Lem, screen
if(paint_stencil==0){
+
+ switch(gInit.mapI.cross.numSwitch){
+ case 0 : break;
+ case 2 : gInit.mapI.cross.numSwitch=2;break;
+ case 1 : gInit.mapI.cross.numSwitch=5;break;
+ case 3 : gInit.mapI.cross.numSwitch=5;break;
+ default: gInit.mapI.cross.numSwitch=0;break;
+ }
+
+ //if(gInit.mapI.cross.numSwitch==0){gInit.mapI.cross.numSwitch=2;}else{gInit.mapI.cross.numSwitch=0;}
+
err=paint_cursor (pSpr_Lem, gInit.mapI.map.tabGif[3], mouseX+camera.x, mouseY+camera.y, mouseX, &gInit);
- if(err!=0){return err;}
- } else {
+ if(err!=0){return err;}
+
+ if(gInit.mapI.cross.numSwitch==0){gInit.mapI.cross.numSwitch=2;}
+
+ }
+ if(paint_stencil==2) {
err=findTerrain(&gInit,mouseX+camera.x, mouseY+camera.y, mouseX);
if(err!=0){return err;}
+
+ switch(gInit.mapI.cross.numSwitch){
+ case 1 : break;
+ case 3 : gInit.mapI.cross.numSwitch=3;break;
+ case 0 : gInit.mapI.cross.numSwitch=6;break;
+ case 2 : gInit.mapI.cross.numSwitch=6;break;
+ default: gInit.mapI.cross.numSwitch=1;break;
+ }
+
+ //if(gInit.mapI.cross.numSwitch==1){gInit.mapI.cross.numSwitch=3;}else{gInit.mapI.cross.numSwitch=1;}
+
err=paint_cursor (pStencil, gInit.mapI.map.tabGif[3], mouseX+camera.x, mouseY+camera.y, mouseX, &gInit);
if(err!=0){return err;}
+
+ if(gInit.mapI.cross.numSwitch==1){gInit.mapI.cross.numSwitch=3;}
+
//-DEBUG-printf("x=%d y=%d\n",mouseX+camera.x,mouseY+camera.y);
}
if(paint_stencil==0){
test_blit(pSpr_Lem, &camera, screen, NULL,0);
- } else {
+ }
+ if(paint_stencil==2){
test_blit(pStencil, &camera, screen, NULL,0);
}
diff --git a/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy b/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy
index 12acf9a..88759db 100644
--- a/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy
+++ b/sdl-test/SDL_tuto/TestParserLemmingsLVL/parse_ini.yy
@@ -12,7 +12,7 @@
#include <stdlib.h>
/** time per frame in microseconds - this is the timing everything else is based on */
-#define FPS 1500
+#define FPS 150
/** redraw animated level obejcts every 3rd frame (about 100ms) */
#define ANIM_STEP_FPS 3
@@ -358,10 +358,11 @@
int oldX; // positionX du cuseur;default=0
int oldY; // positionY du cuseur;default=0
int oldXI; // positionX dans l'interface; default=0;
+ int oldYI; // positionY dans l'interface; default=0;
int sizeC; // dans le cas où le curseur est à cheval entre 2 Surface
int numScreen; // num ecran; default=0
+ int numSwitch;
SDL_Surface *imgC; // image de l'objet; default=NULL;
-
};
struct infoMap {