DESCRIPTION:
You are in control of a submarine. It is your task to navigate through the underwater caverns from one side of the ocean to the other.
IMPLEMENTATION:
We use a pcx image as the background picture. An array of size 16x10 stores values corresponding to the background image (i.e. water, cavern wall, etc.). We use this array to check the location of the sub relative to the background, determine whether a user-specified move is valid, and determine if the sub has collided with the cavern wall. The submarine automatically moves forward while listening to keyboard input. The player can use the up and down arrows to move the sub up and down as it advances.
BREAK UP OF TASKS:
Automatic movement of the Sub:
When the game is started, the submarine will begin moving forward continuously. Before each forward movement, it calls the method that checks to see if a key has been pressed to move the sub up or down and the method that checks to see if the next move will cause a collision.
(Kuhio)
Collision Checking and Reseting Sub:
We will check the next position of the sub each time before it moves. If that position is a cavern wall, the collision procedure is called. A life is lost, the sub resets to the 'safe' position and flashes to indicate the start of a new round.
(Cristin)
Displaying and Updating the Screen:
The screen-updating methods will be called after each movement of the automatic forwarding. They redraw the background and then draw the sub in its new position.
(Marc)
Keyboard Inputs:
The user will be able to maneuver the sub through the caverns by pressing the up and down arrows. We will check to see if one of these keys has been pressed before each forward movement of the sub.
(Mehdi)
SECTIONS/LABELS:
ShowBG:
purpose: Draws a 320x200 PCX image on the screen.
input: DX = what file to print
output: none – all registers preserved
notes: ShowBG doesn't take an input... its computes what stage to print from GetStage. ShowSPLASH does take in DX. (This file is modified from the code on the message board written by Brandon Long.)
ShowLives:
input: none
output: none – all registers preserved
purpose: displays sub images in the lower right corner of the screen corresponding to the number stored in the SUBLIVES variable
ReadSUB:
input: none
output: none – all registers preserved
purpose: reads the 20x20 sub image into the sub buffer
ReadMissile:
input: none
output: none – all registers preserved
purpose: reads the 20x20 missile image into the missile buffer
ReadExplosion:
input: none
output: none – all registers preserved
purpose: reads the 20x20 explosion image into the explosion buffer
ReadMine:
input: none
output: none – all registers preserved
purpose: reads the 20x20 mine image into the mine buffer
ShowIMG:
input: DX = the buffer of the 20x20 image to display
DI = the position at which to draw it (top left corner coord)
output: none – all registers preserved
purpose: reads in dx and displays image from that buffer to screen
notes: we used this to display every 20x20 image we used. Very similar to ShowBG, but it does a lot more!!
CheckPos:
input: DI = the current position at which to print
BX = a block on the grid {0..159}
output: DI = the new position at which to print
purpose: changes DI so the 20x20 img prints in the correct place
UpdateScreen:
input: di = new square = offset in SCREEN_ARRAY
output: none – all registers preserved
purpose: call ShowBG and ShowSUB to display sub in new position (20x20 block indicated by di)
DrawMines:
input: SCREENARR = holds all info about the current stage, where mines go etc.
output: none – all registers preserved
purpose: draws mines in the appropriate positions on the screen, according to SCREENARR
CheckKey:
input: none (reads interrupts)
output: di = new position
purpose: check if key has been pressed. if up or down arrow pressed, move sub up or down. if right or left arrow or spacebar pressed, do nothing.
ShootMissile:
input: none (reads interrupts)
output: none – all registers preserved
purpose: when user presses right arrow key, shoots a missile from the sub
CheckCollision:
input: di = new position of sub
output: none -- all registers preserved
purpose: checks to see if new position is valid move. if new position = water: do nothing. if new position = end of screen: call NewScreen. if new position = wall: decrement SUBLIVES variable, set COLLISION variable to 1, move sub to SAFE_POS, flash sub. also checks for missile and mine collisions
GameOver:
input: none
output: none -- all registers preserved
purpose: ends game....
NewScreen:
input: none
output: none -- all registers preserved
purpose: displays next pcx file as background and sub at SAFE_POS
GameOver:
input: none
output: none -- all registers preserved
purpose: ends game, displays screen indicating that the player has won the game
GetStage:
input: none (uses STAGENUM)
output: DX = current stage to draw
(SCREENARR = current array of stage to use)
purpose: finds out which array it should be using and sets the stage for ShowBG
AutoForward:
input: di = position of sub
ouput: none -- all registers preserved
purpose: continously moves sub forward. calls CheckKey, checkCollision, and UpdateScreen
Delay:
input: variable mazedelay (0..255) - Delay constant
output: none -- all registers preserved
purpose: burn CPU cycles between movements
notes: Lockwood's method (given to us for free)