CS306 Processing Systems and Structures Lockwood, Spring 2002
Final Project:
Rampart
Team Members:
· Ben Kwasnick: Data Structures / Graphics
· David Barnett: User I / O
· Steve Heisler: Rendering of Graphics
· Jared Macke: Computer AI
Introduction:
Rampart is a castle simulation game in which 2 users set up a
castle-style battle and the computer carries out the simulation. User I/O will
be at the beginning of each battle to set up pieces each user’s pieces. Graphics (mode 13h) will include different
military units- castles, light tanks, and heavy tanks. AI will involve figuring
out which pieces to attack first, and random factors will be used to decide the
outcome of the battle.
Implementation:
The graphical view of the battle will be displayed using mode 13h. The view will be a bird’s eye view of the battle. The battlefield will be represented much like the maze in MP3 and MP4, with constants representing the different pieces on the field. Lookup-table data structures will be used to keep track of the health of each unit. The main function will be a loop that takes user input, updates the screen and then carries out the simulation of the battle. Once each piece has fired, the simulation for that round is done. If, after the simulation, one player has no pieces left or their castle is destroyed, that player loses and the program quits. There will be three types of units in the battle: light tanks, heavy tanks, and castles. Also, different generals have been created that allows the user to choose which one he would like to command. Each general attacks in a different way. 4 battlefields have been created where each one has its own order of attack. Each map has its own color.
Problem
Description:
The challenging part of this project will be implementing the graphics so the program flows well. Also, the actual simulation of the battle will be a difficult procedure to implement. There are many graphical procedures that need to be implemented. Heavy tanks and castles will have two different graphics: one when healthy and one when damaged more than 50%. Light tanks can’t be damaged because they are destroyed when hit by any type of unit. Two of the more difficult procedures are drawing the projectiles and simulating the battle.
Procedures:
·
GetInput
§
Purpose: Takes
input from user to move pieces around the map
§
Inputs: map
§
Outputs: Updates
screen
§
Description:
Two sets of keys are mapped on the keyboard, one for Player 1 and one
for Player 2. Each user will be able to
move their pieces around until they are in the desired positions. Uses Highlight to draw box around the tile
the user is currently in. Uses UpdateScreen
to draw new positions on the screen.
Moves pieces around in map variable. Uses kbdin to get input from keyboard.
§
Team Member:
David
·
GetPosition
§
Purpose: Helper
method that calculates upper left corner of map position
§
Inputs:
·
DX: index of
map
§
Outputs:
·
DX: upper left
corner coordinates of index of map
§
Description:
Used by many drawing functions to get the correct starting point to draw
to the screen. Uses table lookup
functions to find the correct placement
§
Team Member:
David
·
Highlight
§
Purpose:
Draws an outline of a box around a map position
§
Inputs:
·
DX: index to
hightlight
·
AL: color
§
Outputs: Writes
to screen
§
Description:
Draws an outline of a box around a map position so the user knows
where his/her cursor is
§
Team Member:
David
·
UpdateScreen
§
Purpose:
Draws the correct piece on the screen given a map position
§
Inputs:
·
DX: index of map to update
§
Outputs:
Writes to screen
§
Description:
Uses jump table to draw the piece of the map at index DX to the screen
§
Team Member:
David
·
SimulateAction
§
Purpose: Goes
through simulation of having units attack each other
§
Inputs: map
§
Outputs: map
§
Description:
The meat of the program.
Alternates firing between players and calculates damage to the unit
being fired upon. Will switch off
between Player 1’s units and Player 2’s units until there are no pieces left to
fire. If a unit is damaged past 50%, a
different constant is put in the map variable and the corresponding graphic
function is called.
§
Team Member:
Jared
·
DrawCastle
§
Purpose: Draws
a 'castle' piece to the screen
§
Inputs:
· DX: upper left corner to draw on
· AH: 0 for Player 1 controlled, 1 for Player 2 controlled
§ Outputs: Draws to screen
§
Description:
Uses DrawBox and DrawTrap to draw a castle facing the correct
direction
§
Team Member:
Ben
·
DrawBrokenCastle
§
Purpose: Draws
an attacked castle piece to the screen
§
Inputs:
· DX: upper left corner
· AH: 0 for Player 1 controlled, 1 for Player 2 controlled
§
Outputs: Draws
to screen
§
Description:
Uses DrawBox, DrawTrap, and DrawFlame to draw a broken castle facing
the correct direction
§
Team Member:
Ben
·
DrawHeavyTank
§ Purpose: Draws a heavy tank to the screen
§
Inputs:
· DX: starting position
· AL: 0 for Player 1 controlled, 1 for Player 2 controlled
· AH: 0 for facing left, 1 for facing right
§ Outputs: Draws to screen
§
Description:
Uses DrawTrap and DrawBox to draw a heavy tank to the screen facing the
correct direction.
§
Team Member:
Ben
·
DrawDHeavyTank
§ Purpose: Draws a damaged heavy tank to the screen
§
Inputs:
· DX: starting position
· AH: 0 for Player 1 controlled, 1 for Player 2 controlled
§ Outputs: Draws to screen
§
Description:
Uses DrawTrap and DrawBox to draw a damaged heavy tank to the screen
facing the correct direction.
§
Team Member:
Ben
·
DrawLightTank
§ Purpose: Draws a light tank to the screen
§
Inputs:
· DX: starting position
· AL: 0 for Player 1 controlled, 1 for Player 2 controlled
· AH: 0 for facing left, 1 for facing right
§ Outputs: Draws to screen
§
Description:
Uses DrawTrap and DrawBox to draw a light tank to the screen facing the
correct direction.
§
Team Member:
Ben
·
DrawSplash
§
Purpose: Draws
the splash screen
§
Inputs:
None
§
Outputs: Draws
to screen
§
Description:
Draws the splash screen to the screen. Uses helper functions RampartR, RampartA, RampartM, RampartT to
draw the letters as they move across the screen. Calls delay afterward so the user can see it.
§
Team Member:
Ben
·
DrawFlame
§
Purpose:
Draws a flame to the screen
§
Inputs:
·
DI: top /
middle position of flame
·
BX: left /
right flame
§
Outputs:
Draws to screen
§
Description:
Called by the draw damaged functions to show the unit being
damaged. The flames represent that the
unit is on fire and not at full strength.
§
Team Member:
Ben
·
DHTD3C
§
Purpose:
Draws wheels of heavy tank
§
Inputs:
·
DX: upper left coordinate of wheels
·
AL: color
§
Outputs:
Draws to screen
§
Description:
Draws the wheels of a heavy tank to the screen with the given color
§
Team Member:
Ben
·
DrawGrSq
§
Purpose:
Draws a square to the screen
§
Inputs:
·
DX: upper left coordinate
·
AL: color
§
Outputs:
Draws to screen
§
Description:
Draws an square with the given color to the screen at the given
coordinate
§
Team Member:
Ben
·
DrawBox
§
Purpose: Draws
a box to the screen
§
Inputs:
· DX: upper left corner
· CX: width of box
· BX: height of box
· AL: color
§ Outputs: Draws to screen
§ Description: Draws a box with the correct height, width, color, and position to the screen
§ Team Member: Ben
·
DrawCircle
§ Purpose: Draws a circle to the screen
§
Inputs:
· DX: middle left coordinate of circle
· CX: diameter
·
AL: color
§ Outputs: Draws to screen
§
Description:
Draws a circle on the screen with a set radius
§
Team Member:
Ben
·
DrawTrap
§ Purpose: Draws a trapezoid to the screen
§
Inputs:
· DX: upper left/right
· CX: width
· BX: height
· AL: color
· AH: direction (0=left, 1=right)
§ Outputs: Draws to screen
§ Description: Draws a trapezoid to the screen with the given attributes
§ Team Member: Ben
· DrawTopTri
§ Purpose: Draws top triangle of a trapezoid
§ Inputs:
· DX: upper coordinate
· CX: width
· BX: height
· AL: color
· AH: direction
§ Outputs: Draws to screen
§ Description: Draws the top part of a trapezoid to the screen with the given attributes
§ Team Member: Ben
· DrawBotTri
§ Purpose: Draws bottom triangle of a trapezoid
§ Inputs:
· DX: lower coordinate
· CX: width
· BX: height
· AL: color
· AH: direction
§ Outputs: Draws to screen
§ Description: Draws the bottom part of a trapezoid to the screen with the given attributes
§ Team Member: Ben
·
DrawTerrain
§ Purpose: Draws the landscape to the screen
§ Inputs: None
§ Outputs: Draws to screen
§
Description:
Uses DrawBox to draw the terrain to the screen
§
Team Member:
Steve
·
DrawMountain
§
Purpose:
Draws a mountain to the screen
§
Inputs:
·
DX: Placement of peak of the mountain
§
Outputs:
Draws to screen
§
Description:
Draws a mountain to the screen as part of the landscape
§
Team Member:
Steve
·
DrawProjectile
§ Purpose: Draws a projectile weapon shot
§
Inputs:
· SI: index of shooting unit
· DI: index of unit being shot at
§ Outputs: Draws to screen
§
Description:
Will color the backgrounds of the units so the user knows what is
firing at what. A gray background means
the unit is shooting, and a red background means the unit is being fired upon.
§
Team Member: Steve
·
DrawExplosion
§ Purpose: Draws an explosion upon impact
§
Inputs:
· DX: upper left corner of tile
§ Outputs: Draws to screen
§ Description: Draws an explosion on the screen at the given position using DrawCircle
§ Team Member: Steve
We also use kbdin, dspout, and dspmsg from the LIB306 and a modified delay function that always has the same delay.
§ USSR