rnd-19980930-1
[rocksndiamonds.git] / src / events.c
index 039be790270c51f9eb82c11990f3d6986d67d1be..d0684ed3d220061fbcb3076b55b6ddd1c97054b2 100644 (file)
@@ -1,13 +1,12 @@
 /***********************************************************
 *  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
 *----------------------------------------------------------*
-*  ©1995 Artsoft Development                               *
-*        Holger Schemel                                    *
-*        33659 Bielefeld-Senne                             *
-*        Telefon: (0521) 493245                            *
-*        eMail: aeglos@valinor.owl.de                      *
-*               aeglos@uni-paderborn.de                    *
-*               q99492@pbhrzx.uni-paderborn.de             *
+*  (c) 1995-98 Artsoft Entertainment                       *
+*              Holger Schemel                              *
+*              Oststrasse 11a                              *
+*              33604 Bielefeld                             *
+*              phone: ++49 +521 290471                     *
+*              email: aeglos@valinor.owl.de                *
 *----------------------------------------------------------*
 *  events.c                                                *
 ***********************************************************/
@@ -167,11 +166,11 @@ void HandleExposeEvent(XExposeEvent *event)
 
     SetDrawtoField(DRAW_BACKBUFFER);
 
-    for(xx=0;xx<SCR_FIELDX;xx++)
-      for(yy=0;yy<SCR_FIELDY;yy++)
+    for(xx=0; xx<SCR_FIELDX; xx++)
+      for(yy=0; yy<SCR_FIELDY; yy++)
        if (xx>=x1 && xx<=x2 && yy>=y1 && yy<=y2)
          DrawScreenField(xx,yy);
-    DrawPlayerField(JX,JY);
+    DrawAllPlayers();
 
     SetDrawtoField(DRAW_DIRECT);
   }
@@ -180,8 +179,8 @@ void HandleExposeEvent(XExposeEvent *event)
   {
     int fx = FX, fy = FY;
 
-    fx += (local_player->MovDir & (MV_LEFT|MV_RIGHT) ? ScreenMovPos : 0);
-    fy += (local_player->MovDir & (MV_UP|MV_DOWN)    ? ScreenMovPos : 0);
+    fx += (ScreenMovDir & (MV_LEFT|MV_RIGHT) ? ScreenGfxPos : 0);
+    fy += (ScreenMovDir & (MV_UP|MV_DOWN)    ? ScreenGfxPos : 0);
 
     XCopyArea(display,fieldbuffer,backbuffer,gc,
              fx,fy, SXSIZE,SYSIZE,
@@ -267,6 +266,29 @@ void HandleButton(int mx, int my, int button)
     HandleGameButtons(mx,my,button);
   }
 
+#ifdef DEBUG
+  if (game_status == PLAYING && !button)
+  {
+    int sx = (mx - SX) / TILEX;
+    int sy = (my - SY) / TILEY;
+
+    if (IN_VIS_FIELD(sx,sy))
+    {
+      int x = LEVELX(sx);
+      int y = LEVELY(sy);
+
+      printf("INFO: Feld[%d][%d] == %d\n", x,y, Feld[x][y]);
+      printf("      Store[%d][%d] == %d\n", x,y, Store[x][y]);
+      printf("      Store2[%d][%d] == %d\n", x,y, Store2[x][y]);
+      printf("      StorePlayer[%d][%d] == %d\n", x,y, StorePlayer[x][y]);
+      printf("      MovPos[%d][%d] == %d\n", x,y, MovPos[x][y]);
+      printf("      MovDir[%d][%d] == %d\n", x,y, MovDir[x][y]);
+      printf("      MovDelay[%d][%d] == %d\n", x,y, MovDelay[x][y]);
+      printf("\n");
+    }
+  }
+#endif
+
   switch(game_status)
   {
     case MAINMENU:
@@ -438,7 +460,7 @@ void HandleKey(KeySym key, int key_status)
   if (key_status == KEY_RELEASED)
     return;
 
-  if (key==XK_Return && game_status==PLAYING && GameOver)
+  if (key==XK_Return && game_status==PLAYING && AllPlayersGone)
   {
     CloseDoor(DOOR_CLOSE_1);
     game_status = MAINMENU;
@@ -611,6 +633,7 @@ void HandleKey(KeySym key, int key_status)
          break;
 
        case XK_y:
+         /*
          {
            printf("FX = %d, FY = %d\n", FX,FY);
 
@@ -622,6 +645,40 @@ void HandleKey(KeySym key, int key_status)
            XSync(display,FALSE);
            Delay(1000);
          }
+         */
+
+         printf("direct_draw_on == %d\n", direct_draw_on);
+
+         break;
+
+       case XK_z:
+         {
+           int i;
+
+           for(i=0; i<MAX_PLAYERS; i++)
+           {
+             printf("Player %d:\n", i);
+             printf("  jx == %d, jy == %d\n",
+                    stored_player[i].jx, stored_player[i].jy);
+             printf("  last_jx == %d, last_jy == %d\n",
+                    stored_player[i].last_jx, stored_player[i].last_jy);
+           }
+           printf("\n");
+         }
+
+         break;
+
+       case XK_t:
+         {
+           char *color[] = { "yellow", "red", "green", "blue" };
+
+           do
+             TestPlayer = (TestPlayer + 1) % MAX_PLAYERS;
+           while(!stored_player[TestPlayer].active);
+
+           printf("TestPlayer = %d (%s player)\n",
+                  TestPlayer, color[TestPlayer]);
+         }
 
          break;
 #endif
@@ -670,7 +727,12 @@ void HandleJoystick()
 {
   int joystick = Joystick();
   int keyboard = key_joystick_mapping;
+
+  /*
   int joy      = (tape.playing ? TapePlayAction() : (joystick | keyboard));
+  */
+
+  int joy      = (joystick | keyboard);
   int left     = joy & JOY_LEFT;
   int right    = joy & JOY_RIGHT;
   int up       = joy & JOY_UP;
@@ -712,7 +774,7 @@ void HandleJoystick()
       if (tape.playing || keyboard)
        newbutton = ((joy & JOY_BUTTON) != 0);
 
-      if (GameOver && newbutton)
+      if (AllPlayersGone && newbutton)
       {
        CloseDoor(DOOR_CLOSE_1);
        game_status = MAINMENU;
@@ -720,7 +782,7 @@ void HandleJoystick()
        return;
       }
 
-      if (tape.pausing || PlayerGone)
+      if (tape.pausing || AllPlayersGone)
        joy = 0;
 
       HandleGameActions(joy);