else /* got no event, but don't be lazy... */
{
HandleNoXEvent();
- Delay(10000); /* don't use all CPU time when idle */
+ Delay(1000); /* don't use all CPU time when idle */
}
XSync(display,FALSE);
}
}
-int Gamespeed = 4;
-int Movemethod = 1;
-int Movespeed[2] = { 10, 4 };
-char *Movespeed_text[2] = { "asynchron", "syncron" };
+int GameSpeed = 2;
+int MoveSpeed = 8;
void HandleKey(KeySym key, int key_status)
{
case XK_7:
case XK_8:
case XK_9:
- Movespeed[Movemethod] = (Movemethod == 0 ? 4 : 0) + (key - XK_0);
- printf("method == %d, speed == %d (%s)\n",
- Movemethod, Movespeed[Movemethod],
- Movespeed_text[Movemethod]);
+ /*
+ MoveSpeed = key - XK_0;
+ printf("speed == %d\n", MoveSpeed);
+ break;
+ */
+
+ if (key == XK_0)
+ GameSpeed = 50;
+ else
+ GameSpeed = key - XK_0;
+ printf("GameSpeed == %d\n", GameSpeed);
break;
case XK_a:
- Movemethod = !Movemethod;
- printf("method == %d, speed == %d (%s)\n",
- Movemethod, Movespeed[Movemethod],
- Movespeed_text[Movemethod]);
+ if (ScrollSteps == TILEX/4)
+ ScrollSteps = TILEX/8;
+ else
+ ScrollSteps = TILEX/4;
break;
case XK_f:
- Gamespeed = 2;
- printf("gamespeed == %d\n", Gamespeed);
+ GameSpeed = 2;
+ printf("GameSpeed == %d\n", GameSpeed);
break;
case XK_g:
- Gamespeed = 3;
- printf("gamespeed == %d\n", Gamespeed);
+ GameSpeed = 3;
+ printf("GameSpeed == %d\n", GameSpeed);
break;
case XK_h:
- Gamespeed = 4;
- printf("gamespeed == %d\n", Gamespeed);
+ GameSpeed = 4;
+ printf("GameSpeed == %d\n", GameSpeed);
break;
case XK_l:
- Gamespeed = 50;
- printf("gamespeed == %d\n", Gamespeed);
+ GameSpeed = 50;
+ printf("GameSpeed == %d\n", GameSpeed);
break;
case XK_Q:
case XK_x:
{
- int i,j,k, num_steps = 16, step_size = TILEX / num_steps;
+ int i,j,k, num_steps = 8, 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(i=0;i<3;i++)
{
for(j=0;j<SCR_FIELDX;j++)
{
#include "tape.h"
#include "joystick.h"
-extern int Gamespeed;
-extern int Movemethod;
-extern int Movespeed[2];
+
+
+int tst = 0;
+int tst2 = 0;
+
+
+
+extern int GameSpeed;
+extern int MoveSpeed;
void GetPlayerConfig()
{
ScreenMovPos = 0;
PlayerMovDir = MV_NO_MOVING;
PlayerMovPos = 0;
+ PlayerGfxPos = 0;
PlayerFrame = 0;
PlayerPushing = FALSE;
PlayerGone = LevelSolved = GameOver = SiebAktiv = FALSE;
break;
case EL_FELSBROCKEN:
sound = SND_KLOPF;
-
-
-
- printf("FUMPF!\n");
-
-
-
break;
case EL_SCHLUESSEL:
case EL_SCHLUESSEL1:
int dy = (direction==MV_UP ? -1 : direction==MV_DOWN ? +1 : 0);
int horiz_move = (dx!=0);
int newx = x + dx, newy = y + dy;
- int step = (horiz_move ? dx : dy)*TILEX/4;
+ int step = (horiz_move ? dx : dy) * TILEX/8;
if (CAN_FALL(element) && horiz_move)
step*=2;
if (!Gems && !SokobanFields && !Lights)
{
Feld[x][y] = EL_AUSGANG_ACT;
- PlaySoundLevel(x,y,SND_OEFFNEN);
+
+ if (IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
+ PlaySoundLevel(x,y,SND_OEFFNEN);
+ else
+ PlaySoundLevel(JX,JY,SND_OEFFNEN);
}
}
if (Feld[x][y] == EL_EDELSTEIN_BD)
{
- const int delay = 2;
+ const int delay = 4; /* war: 2 */
const int frames = 4;
int phase = (FrameCounter % (delay*frames)) / delay;
void GameActions()
{
- static long action_delay=0;
+ static long action_delay = 0;
long action_delay_value;
if (game_status != PLAYING)
*/
action_delay_value =
- (tape.playing && tape.fast_forward ? FFWD_FRAME_DELAY : Gamespeed);
+ (tape.playing && tape.fast_forward ? FFWD_FRAME_DELAY : GameSpeed);
/*
if (DelayReached(&action_delay, action_delay_value))
*/
+
if (PlayerMovPos)
ScrollFigure(0);
DrawPlayerField();
+
+
+ tst++;
+
+ if (0)
+ {
+ static long last_Counter = 0;
+ long new_Counter = Counter();
+
+ printf("--> %ld / %ld [%d]\n",
+ new_Counter - last_Counter,
+ new_Counter,
+ FrameCounter);
+ last_Counter = new_Counter;
+ }
+
+
+
+
+ /*
if (!DelayReached(&action_delay, action_delay_value))
return;
+ */
+
+
+ while(!DelayReached(&action_delay, action_delay_value))
+ Delay(1000);
+
+
+
+
+ /*
+ printf("-----------\n");
+ */
+
+
+
+ FrameCounter++;
+
+
+
+ /*
+ if (PlayerMovPos)
+ ScrollFigure(0);
+
+ DrawPlayerField();
+ */
+
+
+ tst2 = tst;
+ tst = 0;
+
+
+
+ if (0)
+ {
+ static long last_Counter = 0;
+ long new_Counter = Counter();
+
+ printf("--> %ld / %ld [%d]\n",
+ new_Counter - last_Counter,
+ new_Counter,
+ FrameCounter);
+ last_Counter = new_Counter;
+ }
+
+
+ /*
+ printf("--> %ld / ", Counter());
+ */
+
{
int x,y,element;
else if (tape.recording)
TapeRecordDelay();
+
+ /*
FrameCounter++;
+ */
+
+
TimeFrames++;
for(y=0;y<lev_fieldy;y++) for(x=0;x<lev_fieldx;x++)
}
}
- if (TimeLeft>0 && TimeFrames>=25 && !tape.pausing)
+
+ /*
+ printf("%ld\n", Counter());
+ */
+
+
+ if (TimeLeft>0 && TimeFrames>=(100/GameSpeed) && !tape.pausing)
{
TimeFrames = 0;
TimeLeft--;
int softscroll_offset = (soft_scrolling_on ? TILEX : 0);
int x,y;
- ScreenMovPos = PlayerMovPos;
+ ScreenMovPos = PlayerGfxPos;
XCopyArea(display,drawto_field,drawto_field,gc,
FX + TILEX*(dx==-1) - softscroll_offset,
JX = newJX;
JY = newJY;
- PlayerMovPos = (dx > 0 || dy > 0 ? -1 : 1) * 3*TILEX/4;
+ PlayerMovPos = (dx > 0 || dy > 0 ? -1 : 1) * 7*TILEX/8;
ScrollFigure(-1);
if (PlayerGone || (!dx && !dy))
return(FALSE);
- if (Movemethod == 0)
- {
- if (!DelayReached(&move_delay,Movespeed[0]) && !tape.playing)
- return(FALSE);
- }
- else
- {
- if (!FrameReached(&move_delay,Movespeed[1]) && !tape.playing)
- return(FALSE);
- }
+ if (!FrameReached(&move_delay,MoveSpeed) && !tape.playing)
+ return(FALSE);
if (last_move_dir & (MV_LEFT | MV_RIGHT))
{
void ScrollFigure(int init)
{
- static long actual_frame_counter;
+ static long actual_frame_counter = 0;
static int oldJX = -1, oldJY = -1;
if (init)
{
+
+ PlayerGfxPos =
+ (TILEX/ScrollSteps) * (PlayerMovPos / (TILEX/ScrollSteps));
+
+
+
+ if (0)
+ {
+ static long last_Counter = 0;
+ long new_Counter = Counter();
+
+ printf("--> %ld / %ld [%d, %d]\n",
+ new_Counter - last_Counter,
+ new_Counter,
+ FrameCounter,
+ tst2);
+ last_Counter = new_Counter;
+ }
+
+
+
+
if (oldJX != -1 && oldJY != -1)
DrawLevelElement(oldJX,oldJY, Feld[oldJX][oldJY]);
else if (!FrameReached(&actual_frame_counter,1))
return;
- PlayerMovPos += (PlayerMovPos > 0 ? -1 : 1) * TILEX/4;
+ PlayerMovPos += (PlayerMovPos > 0 ? -1 : 1) * TILEX/8;
+
+
+ PlayerGfxPos =
+ (TILEX/ScrollSteps) * (PlayerMovPos / (TILEX/ScrollSteps));
if (ScreenMovPos)
{
- ScreenMovPos = PlayerMovPos;
+ ScreenMovPos = PlayerGfxPos;
redraw_mask |= REDRAW_FIELD;
}
int nextJX = JX + (JX - lastJX);
int nextJY = JY + (JY - lastJY);
- if (PlayerMovPos)
+ if (PlayerGfxPos)
{
if (Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL)
DrawLevelElement(nextJX,nextJY, EL_SOKOBAN_FELD_LEER);
int level_nr, leveldir_nr, num_leveldirs;
int lev_fieldx,lev_fieldy, scroll_x,scroll_y;
-int FX = SX, FY = SY, ScreenMovPos = 0;
+int FX = SX, FY = SY, ScreenMovPos = 0, ScrollSteps = TILEX/4;
int BX1 = 0, BY1 = 0, BX2 = SCR_FIELDX-1, BY2 = SCR_FIELDY-1;
int JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY;
-int PlayerMovDir, PlayerMovPos, PlayerFrame, PlayerPushing;
-int PlayerGone,LevelSolved,GameOver;
-int FrameCounter,TimeFrames,TimeLeft,Score;
-int Gems,SokobanFields,Lights,Friends;
-int Dynamite,Key[4],MampferNr;
+int PlayerMovDir, PlayerMovPos, PlayerPushing;
+int PlayerFrame, PlayerGfxPos;
+int PlayerGone, LevelSolved, GameOver;
+int FrameCounter, TimeFrames, TimeLeft, Score;
+int Gems, SokobanFields, Lights, Friends;
+int Dynamite, Key[4], MampferNr;
int DynaBombCount, DynaBombSize, DynaBombsLeft, DynaBombXL;
int SiebAktiv;
extern int level_nr, leveldir_nr, num_leveldirs;
extern int lev_fieldx,lev_fieldy, scroll_x,scroll_y;
-extern int FX,FY, ScreenMovPos;
+extern int FX,FY, ScreenMovPos, ScrollSteps;
extern int BX1,BY1, BX2,BY2;
extern int JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY;
-extern int PlayerMovDir, PlayerMovPos, PlayerFrame, PlayerPushing;
+extern int PlayerMovDir, PlayerMovPos, PlayerPushing;
+extern int PlayerFrame, PlayerGfxPos;
extern int PlayerGone,LevelSolved,GameOver;
extern int FrameCounter,TimeFrames,TimeLeft,Score;
extern int Gems,SokobanFields,Lights,Friends;
XCopyArea(display,buffer,window,gc,
fx,fy, SXSIZE,SYSIZE,
SX,SY);
-
-
-
- printf("Full screen redraw (%d) (%ld)\n",
- ScreenMovPos,
- Counter());
-
-
-
}
redraw_mask &= ~REDRAW_MAIN;
}
graphic += PlayerFrame;
- if (PlayerMovPos)
+ if (PlayerGfxPos)
{
if (PlayerMovDir == MV_LEFT || PlayerMovDir == MV_RIGHT)
- sxx = PlayerMovPos;
+ sxx = PlayerGfxPos;
else
- syy = PlayerMovPos;
+ syy = PlayerGfxPos;
}
- if (PlayerPushing && PlayerMovPos)
+ if (PlayerPushing && PlayerGfxPos)
{
int nextJX = JX + (JX - lastJX);
int nextJY = JY + (JY - lastJY);
if (element == EL_FELSBROCKEN && sxx)
{
- int phase = PlayerMovPos / (TILEX/4);
+ int phase = PlayerGfxPos / (TILEX/4);
if (PlayerMovDir == MV_LEFT)
graphic += phase;