From 1146572677fd6858df5fc1fabfd7f7294bdefed7 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 24 Oct 1998 01:36:24 +0200 Subject: [PATCH] rnd-19981024-1 --- src/events.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/game.c | 70 +++++++++++++++++++++++++++++++++-------- src/game.h | 2 +- src/init.c | 22 ++++++------- src/joystick.c | 2 +- src/main.c | 1 - src/main.h | 21 ++++++++----- src/network.c | 2 +- src/screens.c | 63 +++++++++++++++++-------------------- src/screens.h | 2 +- 10 files changed, 197 insertions(+), 72 deletions(-) diff --git a/src/events.c b/src/events.c index a38a6ef0..dc398df7 100644 --- a/src/events.c +++ b/src/events.c @@ -372,6 +372,68 @@ void HandleButton(int mx, int my, int button) void HandleKey(KeySym key, int key_status) { int joy = 0; + static struct SetupKeyboardInfo custom_key; + static struct + { + KeySym *keysym_custom; + KeySym keysym_default; + byte action; + } key_info[] = + { + { &custom_key.left, DEFAULT_KEY_LEFT, JOY_LEFT }, + { &custom_key.right, DEFAULT_KEY_RIGHT, JOY_RIGHT }, + { &custom_key.up, DEFAULT_KEY_UP, JOY_UP }, + { &custom_key.down, DEFAULT_KEY_DOWN, JOY_DOWN }, + { &custom_key.snap, DEFAULT_KEY_SNAP, JOY_BUTTON_1 }, + { &custom_key.bomb, DEFAULT_KEY_BOMB, JOY_BUTTON_2 } + }; + + if (game_status == PLAYING) + { + int pnr; + + for (pnr=0; pnraction |= key_action; + else + stored_player[pnr].action |= key_action; + } + else + { + if (network_playing) + local_player->action &= ~key_action; + else + stored_player[pnr].action &= ~key_action; + } + } + } + else + { + int i; + + for (i=0; i<6; i++) + if (key == key_info[i].keysym_default) + joy |= key_info[i].action; + } + + +#if 0 + /* Map cursor keys to joystick directions */ @@ -507,6 +569,10 @@ void HandleKey(KeySym key, int key_status) break; } + +#endif + + if (joy) { if (key_status == KEY_PRESSED) @@ -616,6 +682,8 @@ void HandleKey(KeySym key, int key_status) GAME_FRAME_DELAY * 100 / GameFrameDelay, GameFrameDelay); break; + +#if 0 case XK_a: if (ScrollStepSize == TILEX/8) ScrollStepSize = TILEX/4; @@ -623,6 +691,7 @@ void HandleKey(KeySym key, int key_status) ScrollStepSize = TILEX/8; printf("ScrollStepSize == %d\n", ScrollStepSize); break; +#endif case XK_f: ScrollStepSize = TILEX/8; @@ -706,6 +775,8 @@ void HandleKey(KeySym key, int key_status) break; + +#if 0 case XK_y: /* { @@ -724,6 +795,8 @@ void HandleKey(KeySym key, int key_status) printf("direct_draw_on == %d\n", setup.direct_draw_on); break; +#endif + case XK_z: { @@ -861,10 +934,17 @@ void HandleJoystick() return; } + /* if (tape.pausing || AllPlayersGone) - joy = 0; + { + int i; + + for (i=0; isetup &= ~SETUP_SOUND; @@ -47,14 +47,14 @@ void GetPlayerConfig() setup.joystick_nr = SETUP_2ND_JOYSTICK_ON(local_player->setup); #endif - setup.joy_input[0].joystick_nr = SETUP_2ND_JOYSTICK_ON(local_player->setup); + setup.input[0].joystick_nr = SETUP_2ND_JOYSTICK_ON(local_player->setup); setup.quick_doors = SETUP_QUICK_DOORS_ON(local_player->setup); setup.scroll_delay_on = SETUP_SCROLL_DELAY_ON(local_player->setup); setup.soft_scrolling_on = SETUP_SOFT_SCROLL_ON(local_player->setup); #ifndef MSDOS - if (setup.joy_input[0].joystick_nr != old_joystick_nr) + if (setup.input[0].joystick_nr != old_joystick_nr) { if (joystick_device) close(joystick_device); @@ -82,6 +82,8 @@ void InitGame() player->present = FALSE; player->active = FALSE; + player->action = 0; + /* player->local = FALSE; */ @@ -199,7 +201,7 @@ void InitGame() */ player->present = TRUE; - if (player->connected) + if (!network_playing || player->connected) { player->active = TRUE; @@ -2881,7 +2883,7 @@ void PlayerActions(struct PlayerInfo *player, byte player_action) stored_player_action[player->index_nr] = 0; num_stored_actions++; - if (!player->active || player->gone) + if (!player->active || player->gone || tape.pausing) return; if (player_action) @@ -2948,7 +2950,7 @@ void PlayerActions(struct PlayerInfo *player, byte player_action) } } -void GameActions(byte player_action) +void GameActions() { static long action_delay = 0; long action_delay_value; @@ -2999,13 +3001,11 @@ void GameActions(byte player_action) recorded_player_action = (tape.playing ? TapePlayAction() : NULL); if (network_playing) - SendToServer_MovePlayer(player_action); + SendToServer_MovePlayer(local_player->action); for(i=0; iindex_nr); + + + /* actual player has left the screen -- scroll in that direction */ if (jx != old_jx) /* player has moved horizontally */ scroll_x += (jx - old_jx); @@ -3376,9 +3388,19 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) { if (jx != old_jx) /* player has moved horizontally */ { + /* if ((scroll_x < jx-MIDPOSX-offset || scroll_x > jx-MIDPOSX+offset) && jx >= MIDPOSX-1-offset && jx <= lev_fieldx-(MIDPOSX-offset)) - scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : offset); + scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : +offset); + */ + + if ((player->MovDir == MV_LEFT && scroll_x > jx-MIDPOSX+offset) || + (player->MovDir == MV_RIGHT && scroll_x < jx-MIDPOSX-offset)) + scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : +offset); + + /* don't scroll over playfield boundaries */ + if (scroll_x < -1 || scroll_x > lev_fieldx - SCR_FIELDX + 2) + scroll_x = (scroll_x < -1 ? -1 : lev_fieldx - SCR_FIELDX + 2); /* don't scroll more than one field at a time */ scroll_x = old_scroll_x + SIGN(scroll_x - old_scroll_x); @@ -3390,9 +3412,19 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) } else /* player has moved vertically */ { + /* if ((scroll_y < jy-MIDPOSY-offset || scroll_y > jy-MIDPOSY+offset) && jy >= MIDPOSY-1-offset && jy <= lev_fieldy-(MIDPOSY-offset)) - scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : offset); + scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : +offset); + */ + + if ((player->MovDir == MV_UP && scroll_y > jy-MIDPOSY+offset) || + (player->MovDir == MV_DOWN && scroll_y < jy-MIDPOSY-offset)) + scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : +offset); + + /* don't scroll over playfield boundaries */ + if (scroll_y < -1 || scroll_y > lev_fieldy - SCR_FIELDY + 2) + scroll_y = (scroll_y < -1 ? -1 : lev_fieldy - SCR_FIELDY + 2); /* don't scroll more than one field at a time */ scroll_y = old_scroll_y + SIGN(scroll_y - old_scroll_y); @@ -3424,11 +3456,23 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) { if (!options.network && !AllPlayersInVisibleScreen()) { + + + printf("oops! not all players visible if we scroll now\n"); + + + scroll_x = old_scroll_x; scroll_y = old_scroll_y; } else { + + + printf("ok, scrolling screen...\n"); + + + ScrollScreen(player, SCROLL_INIT); ScrollLevel(old_scroll_x - scroll_x, old_scroll_y - scroll_y); } diff --git a/src/game.h b/src/game.h index c8684fe7..9db0ef6b 100644 --- a/src/game.h +++ b/src/game.h @@ -74,7 +74,7 @@ void AusgangstuerBlinken(int, int); void EdelsteinFunkeln(int, int); void MauerWaechst(int, int); void MauerAbleger(int, int); -void GameActions(byte); +void GameActions(void); void ScrollLevel(int, int); boolean MoveFigureOneStep(struct PlayerInfo *, int, int, int, int); diff --git a/src/init.c b/src/init.c index 4a5578e6..c3798d5a 100644 --- a/src/init.c +++ b/src/init.c @@ -108,16 +108,16 @@ void InitLevelAndPlayerInfo() setup.quick_doors = FALSE; for (i=0; i= 0 ? 0 : 1); int the_other_joystick_nr = (dx >= 0 ? 1 : 0); - if (setup.joy_input[player_nr].use_joystick) + if (setup.input[player_nr].use_joystick) { - if (setup.joy_input[player_nr].joystick_nr == one_joystick_nr) - setup.joy_input[player_nr].joystick_nr = the_other_joystick_nr; + if (setup.input[player_nr].joystick_nr == one_joystick_nr) + setup.input[player_nr].joystick_nr = the_other_joystick_nr; else - setup.joy_input[player_nr].use_joystick = FALSE; + setup.input[player_nr].use_joystick = FALSE; } else { - setup.joy_input[player_nr].use_joystick = TRUE; - setup.joy_input[player_nr].joystick_nr = one_joystick_nr; + setup.input[player_nr].use_joystick = TRUE; + setup.input[player_nr].joystick_nr = one_joystick_nr; } drawPlayerSetupInputInfo(player_nr); } else if (y == 5) { - if (setup.joy_input[player_nr].use_joystick) - CalibrateJoystick(setup.joy_input[player_nr].joystick_nr); + if (setup.input[player_nr].use_joystick) + CalibrateJoystick(setup.input[player_nr].joystick_nr); else CustomizeKeyboard(player_nr); @@ -1374,7 +1369,7 @@ void CustomizeKeyboard(int player_nr) }; /* read existing key bindings from player setup */ - custom_key = setup.key_input[player_nr]; + custom_key = setup.input[player_nr].key; ClearWindow(); DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW); @@ -1473,7 +1468,7 @@ void CustomizeKeyboard(int player_nr) } /* write new key bindings back to player setup */ - setup.key_input[player_nr] = custom_key; + setup.input[player_nr].key = custom_key; StopAnimation(); DrawSetupInputScreen(); @@ -1678,7 +1673,7 @@ void CalibrateJoystick_OLD() char joy_nr[4]; #endif - int joystick_nr = setup.joy_input[0].joystick_nr; + int joystick_nr = setup.input[0].joystick_nr; int new_joystick_xleft, new_joystick_xright, new_joystick_xmiddle; int new_joystick_yupper, new_joystick_ylower, new_joystick_ymiddle; @@ -1833,7 +1828,7 @@ void CalibrateJoystick_OLD() DrawSetupScreen(); } -void HandleGameActions(byte player_action) +void HandleGameActions() { if (game_status != PLAYING) return; @@ -1844,7 +1839,7 @@ void HandleGameActions(byte player_action) if (AllPlayersGone && !TAPE_IS_STOPPED(tape)) TapeStop(); - GameActions(player_action); + GameActions(); BackToFront(); } diff --git a/src/screens.h b/src/screens.h index a521b6c7..cf7ec696 100644 --- a/src/screens.h +++ b/src/screens.h @@ -47,7 +47,7 @@ void DrawSetupInputScreen(void); void HandleSetupInputScreen(int, int, int, int, int); void CustomizeKeyboard(int); void CalibrateJoystick(int); -void HandleGameActions(byte); +void HandleGameActions(void); void HandleVideoButtons(int, int, int); void HandleSoundButtons(int, int, int); void HandleGameButtons(int, int, int); -- 2.34.1