#include "editor.h"
#include "misc.h"
#include "tape.h"
+#include "joystick.h"
void EventLoop(void)
{
SleepWhileUnmapped();
break;
case ButtonPress:
- HandleButtonEvent((XButtonEvent *) &event);
- break;
case ButtonRelease:
HandleButtonEvent((XButtonEvent *) &event);
break;
HandleMotionEvent((XMotionEvent *) &event);
break;
case KeyPress:
- HandleKeyEvent((XKeyEvent *) &event);
- break;
case KeyRelease:
HandleKeyEvent((XKeyEvent *) &event);
break;
case FocusIn:
- HandleFocusEvent(FOCUS_IN);
- break;
case FocusOut:
- HandleFocusEvent(FOCUS_OUT);
+ HandleFocusEvent((XFocusChangeEvent *) &event);
break;
default:
break;
key_joystick_mapping = 0;
break;
case FocusIn:
- HandleFocusEvent(FOCUS_IN);
- break;
case FocusOut:
- HandleFocusEvent(FOCUS_OUT);
+ HandleFocusEvent((XFocusChangeEvent *) &event);
break;
default:
break;
int x = event->x, y = event->y;
int width = event->width, height = event->height;
- XCopyArea(display,drawto,window,gc, x,y, width,height, x,y);
-
if (direct_draw_on && game_status==PLAYING)
{
int xx,yy;
int x1 = (x-SX)/TILEX, y1 = (y-SY)/TILEY;
int x2 = (x-SX+width)/TILEX, y2 = (y-SY+height)/TILEY;
+ SetDrawtoField(DRAW_BACKBUFFER);
+
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);
- DrawLevelElement(JX,JY,EL_SPIELFIGUR);
+ DrawPlayerField();
+
+ SetDrawtoField(DRAW_DIRECT);
}
+ if (soft_scrolling_on && game_status==PLAYING)
+ XCopyArea(display,fieldbuffer,backbuffer,gc,
+ FX,FY, SXSIZE,SYSIZE,
+ SX,SY);
+
+ XCopyArea(display,drawto,window,gc, x,y, width,height, x,y);
+
XFlush(display);
}
HandleKey(key, key_status);
}
-void HandleFocusEvent(int focus_status)
+void HandleFocusEvent(XFocusChangeEvent *event)
{
static int old_joystick_status = -1;
- if (focus_status==FOCUS_OUT)
+ if (event->type == FocusOut)
{
XAutoRepeatOn(display);
old_joystick_status = joystick_status;
joystick_status = JOYSTICK_OFF;
+ key_joystick_mapping = 0;
}
- else
+ else if (event->type == FocusIn)
{
if (game_status == PLAYING)
XAutoRepeatOff(display);
}
int Gamespeed = 4;
-int Movemethod = 0;
-int Movespeed[2] = { 10, 3 };
+int Movemethod = 1;
+int Movespeed[2] = { 10, 4 };
+char *Movespeed_text[2] = { "asynchron", "syncron" };
void HandleKey(KeySym key, int key_status)
{
joy |= JOY_BUTTON_1 | JOY_DOWN;
break;
case XK_Shift_L: /* Linker Feuerknopf */
+ case XK_Control_L:
+ case XK_Alt_L:
+ case XK_Meta_L:
joy |= JOY_BUTTON_1;
break;
case XK_Shift_R: /* Rechter Feuerknopf */
+ case XK_Control_R:
+ case XK_Alt_R:
+ case XK_Meta_R:
+ case XK_Mode_switch:
+ case XK_Multi_key:
case XK_B: /* (Bombe legen) */
case XK_b:
joy |= JOY_BUTTON_2;
key_joystick_mapping &= ~joy;
HandleJoystick();
-
- if (game_status != PLAYING)
- key_joystick_mapping = 0;
}
+ if (game_status != PLAYING)
+ key_joystick_mapping = 0;
+
if (key_status == KEY_RELEASED)
return;
+ if (key==XK_Return && game_status==PLAYING && GameOver)
+ {
+ CloseDoor(DOOR_CLOSE_1);
+ game_status = MAINMENU;
+ DrawMainMenu();
+ return;
+ }
+
if (key==XK_Escape && game_status!=MAINMENU) /* quick quit to MAINMENU */
{
CloseDoor(DOOR_CLOSE_1 | DOOR_NO_DELAY);
case XK_8:
case XK_9:
Movespeed[Movemethod] = (Movemethod == 0 ? 4 : 0) + (key - XK_0);
- printf("method == %d, speed == %d\n",
- Movemethod, Movespeed[Movemethod]);
+ printf("method == %d, speed == %d (%s)\n",
+ Movemethod, Movespeed[Movemethod],
+ Movespeed_text[Movemethod]);
break;
case XK_a:
Movemethod = !Movemethod;
- printf("method == %d, speed == %d\n",
- Movemethod, Movespeed[Movemethod]);
+ printf("method == %d, speed == %d (%s)\n",
+ Movemethod, Movespeed[Movemethod],
+ Movespeed_text[Movemethod]);
break;
case XK_f:
printf("gamespeed == %d\n", Gamespeed);
break;
case XK_l:
- Gamespeed = 10;
+ Gamespeed = 50;
printf("gamespeed == %d\n", Gamespeed);
break;
case XK_q:
Dynamite = 1000;
break;
-#endif
case XK_x:
- /*
+
{
- int i,j,k, num_steps = 4, step_size = TILEX / num_steps;
+ int i,j,k, num_steps = 16, step_size = TILEX / num_steps;
+ static long scroll_delay=0;
+ long scroll_delay_value = 4*4 / num_steps;
+
+ printf("Scroll test\n");
for(i=0;i<10;i++)
{
for(k=0;k<num_steps;k++)
{
int xxx = j*TILEX+k*step_size;
-
- XCopyArea(display,backbuffer,window,gc,
- REAL_SX+xxx,REAL_SY,
- FULL_SXSIZE-xxx,FULL_SYSIZE,
- REAL_SX,REAL_SY);
- XCopyArea(display,backbuffer,window,gc,
- REAL_SX,REAL_SY,
- xxx,FULL_SYSIZE,
- REAL_SX+FULL_SXSIZE-xxx,REAL_SY);
-
- XFlush(display);
- XSync(display,FALSE);
+ int done = 0;
+
+ while(!done)
+ {
+ if (DelayReached(&scroll_delay, scroll_delay_value))
+ {
+ XCopyArea(display,fieldbuffer,window,gc,
+ SX+xxx,SY,
+ SXSIZE-xxx,SYSIZE,
+ SX,SY);
+ XCopyArea(display,fieldbuffer,window,gc,
+ SX,SY,
+ xxx,SYSIZE,
+ SX+SXSIZE-xxx,SY);
+
+ XFlush(display);
+ XSync(display,FALSE);
+
+ done = 1;
+ }
+ else
+ {
+ Delay(1000);
+ }
+ }
+
+ /*
+ Delay(160000 / num_steps);
+ */
+ /*
Delay(120000 / num_steps);
+ */
}
}
}
}
- */
+
break;
+ case XK_y:
+ {
+ printf("FX = %d, FY = %d\n", FX,FY);
+
+ XCopyArea(display,fieldbuffer,window,gc,
+ 0,0,
+ MIN(WIN_XSIZE,FXSIZE),MIN(WIN_YSIZE,FYSIZE),
+ 0,0);
+ XFlush(display);
+ XSync(display,FALSE);
+ Delay(1000000);
+ }
+
+ break;
+#endif
+
default:
break;
}
void HandleNoXEvent()
{
- if (button_status && game_status!=PLAYING)
+ if (button_status && game_status != PLAYING)
{
HandleButton(-1,-1,button_status);
return;
int dx = (left ? -1 : right ? 1 : 0);
int dy = (up ? -1 : down ? 1 : 0);
+ if (game_status==PLAYING && (tape.playing || keyboard))
+ newbutton = ((joy & JOY_BUTTON) != 0);
+
switch(game_status)
{
case MAINMENU:
static long joystickmove_delay = 0;
if (joystick && !button && !DelayReached(&joystickmove_delay,15))
- break;
+ newbutton = dx = dy = 0;
if (game_status==MAINMENU)
HandleMainMenu(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK);
{
BOOL moved = FALSE, snapped = FALSE, bombed = FALSE;
- if (tape.pausing)
- joy = 0;
-
- if (!joy)
- {
- DigField(0,0,0,0,DF_NO_PUSH);
- SnapField(0,0);
- break;
- }
-
if (GameOver && newbutton)
{
CloseDoor(DOOR_CLOSE_1);
return;
}
- if (button1)
- snapped = SnapField(dx,dy);
+ if (tape.pausing || PlayerGone)
+ joy = 0;
+
+ if (joy)
+ {
+ if (button1)
+ snapped = SnapField(dx,dy);
+ else
+ {
+ if (button2)
+ bombed = PlaceBomb();
+ moved = MoveFigure(dx,dy);
+ }
+
+ if (tape.recording && (moved || snapped || bombed))
+ {
+ if (bombed && !moved)
+ joy &= JOY_BUTTON;
+ TapeRecordAction(joy);
+ }
+ else if (tape.playing && snapped)
+ SnapField(0,0); /* stop snapping */
+ }
else
{
- if (button2)
- bombed = PlaceBomb();
- moved = MoveFigure(dx,dy);
+ DigField(0,0,0,0,DF_NO_PUSH);
+ SnapField(0,0);
+ PlayerFrame = 0;
}
- if (tape.recording && (moved || snapped || bombed))
+ if (tape.playing && !tape.pausing && !joy && tape.counter<tape.length)
{
- if (bombed && !moved)
- joy &= JOY_BUTTON;
- TapeRecordAction(joy);
- }
- else if (tape.playing && snapped)
- SnapField(0,0); /* stop snapping */
+ int next_joy =
+ tape.pos[tape.counter].joystickdata & (JOY_LEFT|JOY_RIGHT);
+ if (next_joy == JOY_LEFT || next_joy == JOY_RIGHT)
+ {
+ int dx = (next_joy == JOY_LEFT ? -1 : +1);
+
+ if (IN_LEV_FIELD(JX+dx,JY) && IS_PUSHABLE(Feld[JX+dx][JY]))
+ {
+ int el = Feld[JX+dx][JY];
+ int push_delay = (IS_SB_ELEMENT(el) || el==EL_SONDE ? 2 : 10);
+
+ if (tape.delay_played + push_delay >= tape.pos[tape.counter].delay)
+ {
+ PlayerMovDir = next_joy;
+ PlayerFrame = FrameCounter % 4;
+ PlayerPushing = TRUE;
+ }
+ }
+ }
+ }
break;
}
default: