diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2010-12-22 20:19:15 +0000 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2010-12-22 20:19:15 +0000 |
commit | 4804cc49c3e0308ddd47756c46c56dc43c8ecb00 (patch) | |
tree | 2e4b91e6b98e6226e9a2d6fe3bc2dd1933c1cab9 /src | |
parent | 35110621fb18c4a545f991d91c9bfb609e0183cf (diff) | |
download | 2010-netlemmings-4804cc49c3e0308ddd47756c46c56dc43c8ecb00.tar.gz 2010-netlemmings-4804cc49c3e0308ddd47756c46c56dc43c8ecb00.tar.bz2 2010-netlemmings-4804cc49c3e0308ddd47756c46c56dc43c8ecb00.zip |
Le code recompile maintenant. J'avais fait ça dans le train dimanche, et j'ai oublié de commiter
git-svn-id: file:///var/svn/2010-netlemmings/trunk@208 077b3477-7977-48bd-8428-443f22f7bfda
Diffstat (limited to 'src')
-rw-r--r-- | src/game.c | 4 | ||||
-rw-r--r-- | src/graphic.c | 34 | ||||
-rw-r--r-- | src/include/data_localgame.h | 6 | ||||
-rw-r--r-- | src/include/graphic.h | 4 | ||||
-rw-r--r-- | src/netlem.c | 14 |
5 files changed, 36 insertions, 26 deletions
@@ -4,12 +4,12 @@ #include "game.h" #include "utils.h" -void play(tick_t tick, int *dirtRectsCount, SDL_Rect **directRects ) { +void play(tick_t tick, gameObjectsState_t *objStates) { if (tick%100==0) { } //printf("tick==%i\n",tick); } //TODO : boucle de jeu principale ici (maj état de jeu) - printf("%p - %i\n", (void *) *directRects, *dirtRectsCount); + printf("%p\r", (void *) objStates); SDL_Delay(rand()%8); } diff --git a/src/graphic.c b/src/graphic.c index 576cbfa..802fd5d 100644 --- a/src/graphic.c +++ b/src/graphic.c @@ -221,45 +221,47 @@ int paintTerrain(gameIni_t *gIni, gameRess_t *gRess, gameGraphics_t *gGraph) { return 0; } -int repaint(gameGraphSurfaces_t *srcSurfs, SDL_Rect *srcRect, SDL_Surface *dstSurf, SDL_Rect dstRect) { - int objToRepaintCount, i, res; - gameGraphObjState_t *objToRepaint; +int repaint(gameObjectsState_t *objStates, gameGraphSurfaces_t *srcSurfs, SDL_Rect *srcRect, SDL_Surface *dstSurf, SDL_Rect dstRect) { + int res; + gameObjectsState_t objToRepaint; +// int i; - objToRepaintCount=findAndZSortObjects(srcSurfs->objectsStat, srcRect, &objToRepaint); + findAndZSortObjects(objStates, srcRect, &objToRepaint); - for(i=0;i<objToRepaintCount;++i) { - if(objToRepaint[i].zOrder>0) break; - res=paintObject(objToRepaint+i, srcRect, dstSurf, &dstRect); +/* + for(i=0;i<objToRepaint.objCount;++i) { + if(objToRepaint.allObj[i].zOrder>0) break; + res=paintObject(objToRepaint.allObj+i, srcRect, dstSurf, &dstRect); if ( res!=0 ) { logs(LOG_DEBUG, "repaint(), paintObject() failed"); } } - +*/ res=SDL_BlitSurface(srcSurfs->terrain, srcRect, dstSurf, &dstRect); if ( res!=0 ) { logs2(LOG_DEBUG, "repaint(), SDL_BlitSurface()", SDL_GetError()); } - - for(;i<objToRepaintCount;++i) { - res=paintObject(objToRepaint+i, srcRect, dstSurf, &dstRect); +/* + for(;i<objToRepaint.objCount;++i) { + res=paintObject(objToRepaint.allObj+i, srcRect, dstSurf, &dstRect); if ( res!=0 ) { logs(LOG_DEBUG, "repaint(), paintObject() failed"); } } - - free(objToRepaint); +*/ return res; } -int findAndZSortObjects(gameGraphObjState_t *objectsStat, SDL_Rect *offsetRect, gameGraphObjState_t **objectsFound) { +int findAndZSortObjects(gameObjectsState_t *objectsStat, SDL_Rect *offsetRect, gameObjectsState_t *objectsFound) { //TODO fprintf(stderr, "TODO findAndZSortObjects(%p, %p, %p)\n", (void *)objectsStat,(void *)offsetRect,(void *)objectsFound); - *objectsFound=NULL; + objectsFound->objCount=0; return 0; } -int paintObject(gameGraphObjState_t *obj, SDL_Rect *srcRect, SDL_Surface *dstSurf, SDL_Rect *dstRect) { +int paintObject(struct gameObjectState *obj, SDL_Rect *srcRect, SDL_Surface *dstSurf, SDL_Rect *dstRect) { //TODO fprintf(stderr, "TODO paintObject(%p, %p, %p, %p)\n", (void *)obj,(void *)srcRect,(void *)dstSurf, (void *)dstRect); return 0; } + diff --git a/src/include/data_localgame.h b/src/include/data_localgame.h index b4716f7..989444b 100644 --- a/src/include/data_localgame.h +++ b/src/include/data_localgame.h @@ -10,7 +10,7 @@ // Ensemble des buffers graphiques du jeu (sauf l'écran) typedef struct { - SDL_Surface *screen, *terrain, *stencil, *tmpSurf; + SDL_Surface *terrain, *stencil, *tmpSurf; } gameGraphSurfaces_t; // Gestion de l'écran et de la caméra @@ -45,7 +45,9 @@ struct gameObjectState { }; typedef struct { - int objCount; + int objCount; // allObj array item count + // allObj is a list of all objects of the map (objects, lemmings, other GUI objects, all except cursor) + // cursor is the mouse cursor for selecting lemmings struct gameObjectState *allObj, cursor; } gameObjectsState_t; diff --git a/src/include/graphic.h b/src/include/graphic.h index 13ac889..7160b43 100644 --- a/src/include/graphic.h +++ b/src/include/graphic.h @@ -22,7 +22,7 @@ int init(char *winCaption, gameConfig_t *conf, gameGraphics_t *gGraph); int paintTerrain(gameIni_t *gIni, gameRess_t *gRess, gameGraphics_t *gGraph); int repaint(gameObjectsState_t *objStates, gameGraphSurfaces_t *srcSurfs, SDL_Rect *srcRect, SDL_Surface *dstSurf, SDL_Rect dstRect); -int findAndZSortObjects(gameObjectsState_t *objectsStat, SDL_Rect *offsetRect, gameObjectsState_t **objectsFound); -int paintObject(gameObjectsState_t *obj, SDL_Rect *srcRect, SDL_Surface *dstSurf, SDL_Rect *dstRect); +int findAndZSortObjects(gameObjectsState_t *objectsStat, SDL_Rect *offsetRect, gameObjectsState_t *objectsFound); +int paintObject(struct gameObjectState *obj, SDL_Rect *srcRect, SDL_Surface *dstSurf, SDL_Rect *dstRect); #endif /*GRAPHIC_H*/ diff --git a/src/netlem.c b/src/netlem.c index 32b339d..8b6b3da 100644 --- a/src/netlem.c +++ b/src/netlem.c @@ -105,6 +105,8 @@ int main(int argc, char **argv) { // Config file loading loadGameConfig(&conf); + memset(&localParams, 0, sizeof(localParams_t)); + // Libraries initialization result=init(WIN_CAPTION, &conf, &gGraph); if(result!=0) { @@ -179,7 +181,7 @@ int main(int argc, char **argv) { fps=(STATS_TICKCOUNT*1000.0)/(timeBefore_ms[t]-timeBefore_ms[(t+1)%STATS_TICKCOUNT]); wantWaitMean=0; for(;t<STATS_TICKCOUNT;t++) { wantWaitMean+=wantWait[t]; } t=0; wantWaitMean/=(double) STATS_TICKCOUNT; - snprintf(logMsg, 128, "tick:%d\tlastServerTick:%d\tdrift_ms:%d\tFPS:%.1f\t wantWait:%.1f ms (%.1f %%)\n", tick, lastServerTick, drift_ms, fps, wantWaitMean, (double)wantWaitMean/TICK_DURATION_MS); + snprintf(logMsg, 128, "tick:%d\tlastServerTick:%d\tdrift_ms:%d\tFPS:%.1f\t wantWait:%.1f ms (%.1f %%)\n", tick, lastServerTick, drift_ms, fps, wantWaitMean, wantWaitMean*100.0/TICK_DURATION_MS); logs(LOG_DEBUG, logMsg); } } @@ -187,10 +189,10 @@ int main(int argc, char **argv) { // Close communcation with the server, stop threads, close logs and go out SDLNet_TCP_Close(client.sockClient); - SDL_FreeSurface(gGraph.surfaces.screen); + SDL_FreeSurface(gGraph.screen); SDL_FreeSurface(gGraph.surfaces.terrain); SDL_FreeSurface(gGraph.surfaces.stencil); - + //TODO // Pour tout les objectsSurf //SDL_FreeSurface(gGraph->surfaces.objectsSurf[i]); @@ -514,11 +516,15 @@ int updateGraphics(gameObjectsState_t *objStates, localParams_t *params, gameGra tmpSurf=gGraph->surfaces.tmpSurf; if ( lastViewport.x != gGraph->viewport.x ) { lastViewport.x=gGraph->viewport.x; + dstRect.x=0; + dstRect.y=0; + dstRect.w=0; + dstRect.h=0; srcRect.x=lastViewport.x; srcRect.y=lastViewport.y; srcRect.w=gGraph->screen->clip_rect.w; srcRect.h=gGraph->screen->clip_rect.h; - res=repaint(objStates, &gGraph->surfaces, &srcRect, tmpSurf, srcRect); + res=repaint(objStates, &gGraph->surfaces, &srcRect, tmpSurf, dstRect); if ( res != 0 ) { logs(LOG_WARN, "updateGraphics(), repaint() failed"); } |