Contra Wars: Game Input and Logic
Setup
- Variables read:
- Variables updated:
- Calls:
- Description:
- Initializes player when game begins
firebullet
- Variables read:
- Variables updated:
- Calls:
- UPDATESHOTSEND
- startbullet
- Description:
- Allocates a bullet in a player's bullet array if
there's space available
KbdInstall
- Variables read:
- Variables updated:
- Calls:
- Description:
- Installs a keyboard interrup that checks if any of the above
keys have been hit or released and sets or resets the appropriate variable
if so.
KbdUninstall
- Variables read:
- Variables updated:
- Calls:
- Description:
- Uninstalls our keyboard interrupt and replaces the old
one.
MouseInstall
- Variables read:
- Variables updated:
- MouseHeight
- MouseLength
- LeftButton
- RightButton
- Calls:
- Description:
- Installs our mouse interrupt that sets and resets the
above variables when the appropriate actions are taken.
MouseUninstall
- Variables read:
- Variables updated:
- Calls:
- Description:
- Uninstalls our mouse interrupt and sets the old one
back into place.
WaitForInput
- Variables read:
- Variables updated:
- Calls:
- Description:
- Waits for input until the beginning of the next
vertical retrace
movebullet
- Variables read:
- Variables updated:
- Calls:
- Description:
- Moves the bullet in the appropriate direction using
bulletarray to look up it's velocity and terminates the bullet
after a certain count
CollisionDet
- Variables read:
- MyPosition
- TileCanMove
- Collision
- LeftButton
- RightButton
- MyOffset
- UPKEY
- DOWNKEY
- LEFTKEY
- RIGHTKEY
- NewDir
- boxes
- MyxOffset
- MyyOffset
- MyxSize
- MyySize
- BulletCount
- wkey
- HisxSize
- HisySize
- WalkCount
- Players
- Variables updated:
- MyPosition
- collision
- NewDir
- BulletCount
- players
- MyxSize
- MyySize
- HisxSize
- HisySize
- Calls:
- WAVPLAY
- firebullet
- CheckTileMove
- Description:
- Checks for collisions between the player and other
objects in the game and updates the appropriate variables.
startbullet
- Variables read:
- Variables updated:
- Calls:
- Description:
- Determines the initial position of the bullet using
startbularray
Truly global structures, variables, and
constants:
Structures:
PointType struc
x dw ? ; x-position
y dw ? ; y-position
PointType ends
PlayerType struc
Team db ? ; team number the player belongs to
Firing db ? ; a bool as to whether the person is firing
Walk db ? ; a status as to current walk state
GamePos dw 2 dup(?) ; the player's position in game
;coordinates
Dir db ? ; direction player is facing
Bullets db MAX_BULLETS*6 dup(0) ; the bullets fired by the player
Dead db ? ; bool as to whether player is dead
PlayerType ends
BulletType struc
pos dw 2 dup(0) ; the bullet's current location on the screen
dir db 0 ; the direction of the bullet, 1-32
count dw 0 ; determines range of bullet
status db ? ; the status of the bullet
BulletType ends
Variables:
- Players PlayerType NUM_PLAYERS dup (<>) ; holds the stats for all
; players in the game
- tile_map db MAP_WIDTH*MAP_HEIGHT dup (0) ; holds the map tile indices
- MyPosition PointType <> ; the player's current position
- MyDirection db ? ; the player's current orientation
- Maincounter dw ? ; keeps track of time
- LEFTKEY db ? ; set when left arrow
key is hit
- RIGHTKEY db ? ; set when right arrow key is hit
- UPKEY db ? ; set when up arrow key is hit
- DOWNKEY db ? ; set when down arrow key is hit
- KEY db ? ; set when left arrow key is hit
- qkey db ? ; set when left arrow key is hit
- esckey db ?
- wkey db 0 ; set when left arrow key is hit
- LeftButton db ? ; set when left button is hit
- RightButton db ? ; set when right button is hit
- MyOffset dw 0 ; position in players
- MyxOffset db 0 ; used to hold top left offset
- MyyOffset db 0 ; of current bounding box
- NewDir db 0 ; New direction the player is trying to turn in
- MyxSize dw 0 ; Size of current bounding box
- MyySize dw 0 ; ditto
- HisxSize dw 0 ; Size of current bounding box
- HisySize dw 0 ; for another player
- Bulletcount db 0 ; used to enter delay after one bullet is fired before the next can be
- BulletCount2 db 0 ;
- WalkCount db 0 ; used to delay walking animation
- rkey db 0 ; signals r key pressed
- gkey db 0 ; signals g key pressed
- ckey db 0 ; signals c key pressed
- bkey db 0 ; signals b key pressed
- HelloSpew dw 0 ; used to send periodic Hello messages
Constants:
NUM_WALK_STATES ; number of animation states
NUM_PLAYERS equ 18 ; the maximum number of players
MAX_BULLETS equ 6 ; the maximum number of bullets a
; player can fire
NUM_TEAMS equ 3 ; the number of teams allowed in
; the game
TRUE EQU 1 ; for boolean logic
FALSE EQU 0
MAP_WIDTH equ 50 ; number of tiles in the
; x-direction in world map
MAP_HEIGHT equ 32 ; number of tiles in the
; y-direction in world map
WALK_STATE_STILL equ 0 ; state when standing still
WALK_STATE_LEFT equ 1 ; state when walking on left foot
WALK_STATE_RIGHT equ2 ; state when walking on right
foot
SIZEPLAYERSTRUCT equ 58
SIZEBULLETSTRUCT equ 8
BULLET_WAIT equ 20 ; delay after which a player can fire a bullet again
BULLET_RANGE equ 40 ; count at which bullet disappears
WALK_TIME equ 23 ; determines time before next animation
MACROS:
DOSEXIT ; macro from macros.inc
CheckCol ; checks for collisions given the sizes and
; offsets in game coordinates of two bounding boxes
MapLookUp ; given game coordinates, figures out tile
; coordinates