Thak--Gameplay
LifeCheck (Mike Del Giudice)
    Purpose: To check the current health for each of your caveman and Thak.
    Inputs: Player Structure, containing the cavemen's health.
    Outputs: Changes a player status to 0ffh, not there, if his health is less than or equal to 0.  It resets the cavemans position
                  and plays the appropriate sound (Tim Zadigian) if a player dies.  If no unit is killed, it doesn't adjust anything. Does
                  the same for the player's Hut.

MouseCalculate    (Matt Wood)
    Purpose: Calculates exact grid position clicked in the game grid by the mouse.
                   Sets DestinationG for any unit that should begin moving, as well as set
                   the PlayerSelected variable to whoever was selected. Also triggers sounds.
    Inputs: checks MouseX, MouseY, LeftB, and RightB, set by MouseCheck.
    Outputs: Sets DestinationG for any unit that should move as well as PlayerSelected.
                  Triggers start of any necessary sounds.
    Notes: AX will not be maintained.

UpdateStates (Mike Del Giudice & Matt Wood)
    Purpose: To adjust the players status while he is walking.  This would give the impression that he is moving and not sliding
                  across the screen. It also adjust the CavemanBuild counter and WallBuild counter depending on what's needed.
    Inputs: The MyUnits structure, specifically the units status.  It also uses CaveManBuild, WallBuild, and StateTimer.
    Outputs: If a wall or caveman is being built, the CaveManBuild or WallBuild counter is incremented, respectively.  If a wall
                  is building, it changes Thak's status between the diggers to show movement.  It also increments the StateCounter
                  variable.  This allows us to only adjust a CaveMan's status every 5 loops, a more realistic pace than every time.
                  Finally, on the fifth pass, it adjust every CaveMan's position if he is walking to the appropriate state.  If they are
                  standing still or dead, it skips that unit.

BuildCaveMan (Mike Del Giudice)
    Purpose: To build a Caveman when the hut is selected
    Inputs: Checks BPressed variable, CaveManBuild counter
    Outputs: A CaveMan at the foot of the hut.  It resets the CaveManBuild counter after the CaveMan is done.  It recurses
                  through the player structure to find an opening, if there isn't one, it doesn't allow the player to build a CaveMan.
                  When a CaveMan is done, it sets the player's structure to the proper Grid Position and X/Y Coordinates, while
                  setting his status to 1 (a groovy position).

BuildNewWall (Mike Del Giudice & Matt Wood)
    Purpose: To build a wall on the GameScreen and adjust Thak's status in the Player structure.  It also stores the wall in the
                  GameGrid so no CaveMan can move into that square.
    Inputs: WPressed, Player Structure,
    Outputs: Resets the WPressed variable.  If WPressed is 1 and Thak is selected, it sets his position to the first digger
                  position.  If a wall is currently being built, than it checks if it is finished and, if so, reset the counter and reset Thak's
                  status to 1, his groove position.  When the wall is done, it sets in the Grid so no player can move across it.

CheckCaveMan0 (Mike Del Giudice & Matt Wood)
    Purpose: Checks to see if one of your CaveMen should be attacking.
    Inputs: The player's structure, Guy-The Caveman which should be checked for attack status
    Outputs: Sets the CaveMan's status to alternating Status positions to show movement.  It checks every Grid Position
                  adjacent to the CaveMan it is checking.  If there is no CaveMan, than nothing is changed.  If there is a CaveMan,
                  than it sets his status to the Attacking position toward the opposing CaveMan.  If both CaveMen are still attacking
                  the next cycle, than it resets his position back to the original position and then sets the attack position the next cycle
                  again to imitate an attacking motion. This function sets the position once a CaveMan is found, so it attacks in a
                  clockwise direction.

CheckMyPain (Mike Del Giudice & Matt Wood)
    Purpose: To see if one of your CaveMen are being attacked and decrements his health accordingly.
    Inputs: The Other player's structure and your player's structure.
    Outputs: Checks to see if any of the opposing players CaveMen are in attacking status with their club down.  This means
                  you've been hit. It then recursed through your units structure to find which caveman is being attacked by matching
                 Grid positions.  When a hit and CaveMan are detected, the health of that respective CaveMan is decremented by
                 one.

CheckGridPos (Tim Zadigian)
        Purpose:  To take any position on the grid, and to check whether there are any rocks, huts, or walls in the grid array
                       or if there are any units in that spot.
        Inputs: A valid space on the grid
        Outputs:  dh=0 if the gird space given is empty
                       dh=1 if the grid space given is full

MoveUnit (Dan Mueller)
     Purpose: updates player position
                   calls MoveUnitHelper if caveman exists
     Inputs: UnitStatus
     Outputs: updates DestinationG, CurrentG,
                   XPos, YPos, status, and direction variables
 

MoveUnitHelper (Dan Mueller)
     Purpose: does the actual moving work of MoveUnit
                   checks for collisions
                   does not allow unit to move into occupied space,
                   sends unit back to former space if the space
                   he's moving into becomes occupied
     Inputs:  ThisGuy: word--offset of unit in MyUnitStructure
                 Dir: word--offset of direction this unit is moving
     Outputs: updates DestinationG, CurrentG, XPos,Ypos,
                   status, and direction variables

PlayerGridFit (Dan Mueller)
     purpose - checks whether a player is exactly in a gridspace
     input - ThisGuy - word, offset of unit in structure
     output - bl: bit 0 = x alligned
                  bit 1 = y aligned
            hence if bl equals 3 (0000 0011) means
            thisguy is exactly in his gridspace

FindGridCoords (Dan Mueller)
     Purpose: calculates grid x and y for CurrentG
               and DestinationG
     Inputs: ThisGuy: word--offset of unit in MyUnitStructure
     Ouputs: sets DestinationG[X,Y] and CurrentG[X,Y]
 

InstKey (Dan Mueller)
     Purpose: Installs ThakKeyHandler and saves the
                   previously installed KeyHandler

DeInstKey (Dan Mueller)
     Purpose: restores original KeyHandler

ThakKeyHandler (Dan Mueller)
     Purpose: detects key presses important to Thak
     Inputs: keyboard
     Outputs: IPressed, JPressed, XPressed, BPressed, WPressed
               escPressed, SpacePressed, UpPressed, DownPressed,
               LeftPressed, RightPressed set to one if keys
               pressed

MouseCheck (Dan Mueller)
     Purpose: checks position of mouse cursor
                   and whether a button has been pressed
     Inputs: mouse
     Outputs: LeftB = 1 if left button pressed
                   RightB = 1 if right button pressed
                   cx contains column position
                   dx contains row position


Back to Main