'Gapper(1986) Clone
'10\25\2019 Cobalt
'ÃInital Start; Layout, Gapper, Seeker, L1 Grid finished [13:55EDT]
'ÀCorreted 'Catcher' to 'Seeker' as per original game
'10\31\2021
'ÃFixed Seeker movement issue with help from Bplus and Keybone, used ABS as per Bplus
'Àadded startup screen, player initials input,game options
'11\1\2021
'ÃAdded the instructions screens
'Àenabled collision of Seeker and Gapper
'11\11\2021
'ÃFinished all 8 boards
'11\12\2021
'Ã
Start
AS _BYTE 'is level started or not(nothing happens until started) Caught
AS _BYTE 'has the seeker caught the gapper?
CONST TRUE
= -1, FALSE
= NOT TRUE
, Gapper
= 1, Seeker
= 2 CONST UP
= 1, DOWN
= 2, LEFT
= 3, RIGHT
= 4 CONST Key_Right
= 19712, Key_Left
= 19200, Key_Up
= 18432, Key_Down
= 20480 CONST Key_Space
= 32, Key_Enter
= 13 CONST Cyan
= &HFF10E0E0~&
'_RGB32(0, 170, 170) CONST Magenta
= &HFFC040C0~&
CONST OffWhite
= &HFFC0C0C0~&
CONST Brown
= &HFFB06000~&
CONST Yellow
= &HFFFFFF00~&
CONST Black
= &HFF000000~&
Layer
(1) = _NEWIMAGE(640, 440, 32) 'mix layerLayer
(2) = _NEWIMAGE(320, 220, 32) 'Grid LayerLayer
(3) = _NEWIMAGE(640, 440, 32) 'Sprite layerLayer
(4) = _NEWIMAGE(320, 220, 32) 'Info layerLayer
(5) = _NEWIMAGE(640, 440, 32) 'Collision 'Gapper\Catcher' layerLayer
(6) = _NEWIMAGE(640, 440, 32) 'Collision 'Grid' layerLayer
(7) = _NEWIMAGE(640, 440, 32) 'debug layerLayer
(8) = _NEWIMAGE(320, 220, 32) 'Menu layerLayer
(9) = _NEWIMAGE(320, 240, 32) 'instructions layerLayer
(10) = _NEWIMAGE(320, 8, 32) 'title bar layer
'Title_Startup
'END
Game_INIT
DrawBoard
G.Start = TRUE
IF NOT Collision_Grid
(Gapper
, UP
) THEN G.GD
= UP
G.Start = TRUE
IF NOT Collision_Grid
(Gapper
, DOWN
) THEN G.GD
= DOWN
G.Start = TRUE
IF NOT Collision_Grid
(Gapper
, LEFT
) THEN G.GD
= LEFT
G.Start = TRUE
IF NOT Collision_Grid
(Gapper
, RIGHT
) THEN G.GD
= RIGHT
IF G.Start
THEN Move_Seeker: Move_Gapper
Game_Data_Update
Place_Gapper
Place_Seeker
ClearLayer Layer(5)
Reset_Pos
DrawBoard
G.Lives = G.Lives - 1
IF G.Lives
= -1 THEN ExitFlag%%
= TRUE
ClearLayer Layer(1)
Frames% = Frames% + 1
LINE (G.GX
- 2, G.GY
- 2)-STEP(20, 18), Black
, BF
'place gapper-----
_PUTIMAGE (G.GX
, G.GY
), Layer
(3), Layer
(1), (318, 218)-STEP(15, 13) 'place Gapper shadow
_PUTIMAGE (G.GX
, G.GY
), Layer
(3), Layer
(5), (318, 218)-STEP(15, 13)
'place Seeker----
_PUTIMAGE (G.SX
, G.SY
), Layer
(3), Layer
(1), (341, 218)-STEP(14, 11) '-----------------
'Player----
DRAW "c" + STR$(Cyan
) + "drurd8l2dr3u9d2rd5ru5rd5ru5ru2d9r3ul2u8r2dlbl3c" + STR$(Magenta
) + "u3ld3lu3ld3" DRAW "bd7d3ru3rd3ru3bu3br3r4ul4bl9l4dr4" '----------
'Seeker----
DRAW "c" + STR$(Cyan
) + "r3dl3bd10r3ul3br10r3dl3bu10r3ul3c" + STR$(Magenta
) + "bd2brl3dr3bd5l3dr3bl6l3ur3" DRAW "bu5l3ur3d2lr5dl5dr5dl5" '------------
Title_Header
G.Score = 0
G.Lives = 2
G.Level = 1
'Header
'Info area updating ---------------
_PRINTSTRING (7, 192), "Score[ ] Lives[ ] Level[ ]", Layer
(4) '-----------------------------------
CASE 1 'draw level 1 grid Level_1_Board
Level_2_Board
Level_3_Board
Level_4_Board
Level_5_Board
Level_6_Board
Level_7_Board
Level_8_Board
CASE ELSE 'after level 8 board is random between 5 and 8 Level_5_Board
Level_6_Board
Level_7_Board
Level_8_Board
ClearLayer Layer(6)
_PUTIMAGE , Layer
(2), Layer
(6) 'make a copy for the collision layer
Result%% = FALSE
IF POINT(G.SX
+ 8, G.SY
+ 8) <> Black
THEN Result%%
= TRUE
Collision_Seeker = Result%%
FUNCTION Collision_Grid%%
(who%%
, Direction%%
) Result%% = TRUE 'always assume collision
SELECT CASE who%%
'who are we checking collision for? CASE UP
'see if there is grid up from Gappers position Check~&
= POINT(G.GX
+ 8, G.GY
+ 5) CASE DOWN
'see if there is Grid below Gapper Check~&
= POINT(G.GX
+ 8, G.GY
+ 9) CASE LEFT
'check for grid to the left of Gapper Check~&
= POINT(G.GX
+ 6, G.GY
+ 7) CASE RIGHT
'Check for grid to the Right of Gapper Check~&
= POINT(G.GX
+ 10, G.GY
+ 7) CASE UP
'see if there is grid up from Gappers position Check~&
= POINT(G.SX
+ 8, G.SY
+ 5) CASE DOWN
'see if there is Grid below Gapper Check~&
= POINT(G.SX
+ 8, G.SY
+ 9) CASE LEFT
'check for grid to the left of Gapper Check~&
= POINT(G.SX
+ 6, G.SY
+ 7) CASE RIGHT
'Check for grid to the Right of Gapper Check~&
= POINT(G.SX
+ 10, G.SY
+ 7) Blue~%%
= _BLUE32(Check~&
) 'check for Blue, grid is Cyan in color IF Blue~%%
THEN Result%%
= FALSE
'there is grid to move onto, no collision with edge of grid
Collision_Grid = Result%%
'_SOURCE Layer(0)
Seeker_Logic
Mover%% = Mover%% + 1 'Slow our seeker down
Mover%% = 0
IF NOT Collision_Grid
(Seeker
, UP
) THEN G.SY
= G.SY
- 2 IF NOT Collision_Grid
(Seeker
, DOWN
) THEN G.SY
= G.SY
+ 2 IF NOT Collision_Grid
(Seeker
, LEFT
) THEN G.SX
= G.SX
- 2 IF NOT Collision_Grid
(Seeker
, RIGHT
) THEN G.SX
= G.SX
+ 2 IF Collision_Seeker
THEN G.Caught
= TRUE
IF NOT Collision_Grid
(Gapper
, UP
) THEN G.GY
= G.GY
- 2 IF NOT Collision_Grid
(Gapper
, DOWN
) THEN G.GY
= G.GY
+ 2 IF NOT Collision_Grid
(Gapper
, LEFT
) THEN G.GX
= G.GX
- 2 IF NOT Collision_Grid
(Gapper
, RIGHT
) THEN G.GX
= G.GX
+ 2 Color_Line
DistX% = (G.SX - G.GX) 'find X distance between seeker and gapper
DistY% = (G.SY - G.GY) 'find Y distance between Seeker and Gapper
IF ABS(DistX%
) > ABS(DistY%
) THEN 'if player is farther on the X then Turn_Seeker RIGHT 'try going right to get closer
Turn_Seeker LEFT 'try going left to get closer
ELSE 'player is farther on the Y then Turn_Seeker DOWN 'try going down to get closer
Turn_Seeker UP 'try going up to get closer
SUB Turn_Seeker
(Direction%%
) IF NOT Collision_Grid
(Seeker
, UP
) THEN G.SD
= UP
IF NOT Collision_Grid
(Seeker
, DOWN
) THEN G.SD
= DOWN
IF NOT Collision_Grid
(Seeker
, LEFT
) THEN G.SD
= LEFT
IF NOT Collision_Grid
(Seeker
, RIGHT
) THEN G.SD
= RIGHT
LINE (4 + G.GX \
2, 3 + G.GY \
2)-STEP(0, 0), Magenta
, BF
G.FPS = Frames%
Frames% = 0
Get_Player
IF Search_For_Player
THEN AddPlayer
'first time this player has played! Display_HighScores
Blink%% = TRUE: I$ = ""
LINE (168, 210)-(248, 219), Black
, BF
LINE (168, 210)-(248, 219), Black
, BF
CASE 13 'accept input(if any) ExitFlag%% = TRUE
G.Quit = TRUE
t%% = t%% + 1
IF t%%
= 4 THEN Blink%%
= NOT Blink%%: t%%
= 0 G.Player = I$
ExitFlag%% = TRUE
G.Quit = TRUE
Instructions
ExitFlag%% = TRUE
G.Quit = TRUE
IF G.Player
= Scores
(i%%
).Nam
THEN COLOR Yellow
'player shows up Yellow COLOR Magenta
'High score if not player shows magenta COLOR OffWhite
'everybody else is off white
ClearLayer Layer(0)
'end of page 1
'end of page 2
ClearLayer Layer(0)
GET #1, , Scores
(i%%
).Nam
IF G.Player
= Scores
(i%%
).Nam
THEN Result%%
= TRUE: i%%
= 11 ELSE Result%%
= FALSE
Search_For_Player = Result%%
IF Count%%
< 10 THEN Count%%
= Count%%
+ 1 PUT #1, 1 + 10 * Count%%
, G.Player
PUT #1, , NULL&
'filler for score PUT #1, , NULL%
'filler for level Load_Scores 'reload score list
G.Start = FALSE
G.Caught = FALSE
'Level 1 Start Pos.------
G.GX = 0: G.GY = 14 'Gapper
G.SX = 626: G.SY = 374 'Seeker
'------------------------
DIM Grid_Check
(7, 6) AS _BYTE 'largest board(8) is 8x7(0-7,0-6) 'check horizontals
FOR Ix%%
= 0 TO 2 'check top line IF POINT(4 + x%%
+ 60 * Ix%%
, 10) = Magenta
THEN full%%
= TRUE
ELSE full%%
= FALSE: x%%
= 66 IF full%%
THEN Grid_Check
(Ix%%
, Iy%%
) = TRUE
'check verticals
IF POINT(4 + x%%
+ 60 * Ix%%
, 10) = Magenta
THEN full%%
= TRUE
ELSE full%%
= FALSE: x%%
= 66 IF full%%
THEN Grid_Check
(Ix%%
, Iy%%
) = TRUE
Grid_Check(Ix%%, Iy%%) = FALSE
LINE (4, 10 + I%%
* 60)-STEP(311, 0), Cyan
'horizontal lines LINE (4 + I%%
* 104, 10)-STEP(0, 180), Cyan
'vertical lines G.SS = 2 'set seeker speed 1\4th player speed
G.Start = FALSE
'Level 1 Start Pos.------
G.GX = 0: G.GY = 14 'Gapper
G.SX = 626: G.SY = 374 'Seeker
'------------------------
LINE (8, 12 + I%%
* 44)-STEP(304, 0), Cyan
'horizontal lines LINE (8 + I%%
* 76, 12)-STEP(0, 176), Cyan
'vertical lines G.SS = 1 'set seeker speed 1\4th player speed
G.Start = FALSE
'Level 2 Start Pos.------
G.GX = 8: G.GY = 18 'Gapper
G.SX = 616: G.SY = 370 'Seeker
'------------------------
LINE (10, 10 + I%%
* 36)-STEP(300, 0), Cyan
'horizontal lines LINE (10 + I%%
* 60, 10)-STEP(0, 180), Cyan
'vertical lines G.SS = 1 'set seeker speed 1\4th player speed
G.Start = FALSE
'Level 5 Start Pos.------
G.GX = 12: G.GY = 14 'Gapper
G.SX = 612: G.SY = 374 'Seeker
'------------------------
LINE (16, 16 + I%%
* 24)-STEP(288, 0), Cyan
'horizontal lines LINE (16 + I%%
* 48, 16)-STEP(0, 168), Cyan
'vertical lines LINE (16, 16 + I%%
* 24)-STEP(288, 0), Cyan
'horizontal lines G.SS = 1 'set seeker speed 1\4th player speed
G.Start = FALSE
'Level 4 Start Pos.------
G.GX = 24: G.GY = 26 'Gapper
G.SX = 600: G.SY = 362 'Seeker
'------------------------
LINE (16, 16 + I%%
* 24)-STEP(288, 0), Cyan
'horizontal lines LINE (88 + I%%
* 36, 16)-STEP(0, 168), Cyan
'vertical lines LINE (88, 136 + I%%
* 24)-STEP(144, 0), Cyan
'horizontal lines LINE (16 + I%%
* 36, 16)-STEP(0, 96), Cyan
'vertical lines LINE (268 + I%%
* 36, 16)-STEP(0, 96), Cyan
'vertical lines
G.SS = 1 'set seeker speed = player speed
G.Start = FALSE
'Level 5 Start Pos.------
G.GX = 24: G.GY = 26 'Gapper
G.SX = 458: G.SY = 362 'Seeker
'------------------------
LINE (16, 64 + I%%
* 24)-STEP(288, 0), Cyan
'horizontal lines LINE (88 + I%%
* 36, 16)-STEP(0, 168), Cyan
'vertical lines LINE (88 + I%%
* 36, 16)-STEP(0, 168), Cyan
'vertical lines
LINE (88, 16 + I%%
* 24)-STEP(144, 0), Cyan
'horizontal lines LINE (88, 160 + I%%
* 24)-STEP(144, 0), Cyan
'horizontal lines LINE (16 + I%%
* 36, 64)-STEP(0, 72), Cyan
'vertical lines LINE (268 + I%%
* 36, 64)-STEP(0, 72), Cyan
'vertical lines
G.SS = 1 'set seeker speed = player speed
G.Start = FALSE
'Level 6 Start Pos.------
G.GX = 168: G.GY = 26 'Gapper
G.SX = 458: G.SY = 362 'Seeker
'------------------------
LINE (16, 88 + I%%
* 24)-STEP(288, 0), Cyan
'horizontal lines LINE (88 + I%%
* 36, 16)-STEP(0, 168), Cyan
'vertical lines LINE (88, 16 + I%%
* 24)-STEP(144, 0), Cyan
'horizontal lines LINE (16 + I%%
* 36, 88)-STEP(0, 96), Cyan
'vertical lines LINE (268 + I%%
* 36, 88)-STEP(0, 96), Cyan
'vertical lines LINE (88, 16 + I%%
* 24)-STEP(144, 0), Cyan
'horizontal lines
G.SS = 1 'set seeker speed = player speed
G.Start = FALSE
'Level 5 Start Pos.------
G.GX = 168: G.GY = 26 'Gapper
G.SX = 600: G.SY = 362 'Seeker
'------------------------
LINE (16, 16 + I%%
* 24)-STEP(288, 0), Cyan
'horizontal lines LINE (16 + I%%
* 36, 16)-STEP(0, 168), Cyan
'vertical lines LINE (16 + I%%
* 36, 16)-STEP(0, 168), Cyan
'vertical lines G.SS = 1 'set seeker speed 1\4th player speed
G.Start = FALSE
'Level 8 Start Pos.------
G.GX = 24: G.GY = 26 'Gapper
G.SX = 600: G.SY = 362 'Seeker
'------------------------