Death Star Run

Introduction:


The goal of this project is to create a simulation type game for the attack on the Death Star from Star Wars. The user will navigate an X-Wing through a 3d trench while avoiding obstacles.
Download xwing.zip

* Note: this thing sketches out sometimes on winME and 98, but there have been no problems so far with NT-based.
** For best results, play a StarWars MP3 as background music and turn off the lights.


Implementation:


The implementation of the trench will be very similar to lab 5 with a few changes. We've decided to change the width:height ratio of the top of the trapezoids, giving the user a different perspective to suggest flying rather than walking. The X-Wing will be rendered as a sprite which will move left and right in reponse to keystrokes. The forward motion of the X-Wing through the trench will be not be controlled by the user since the craft will move forwards whether or not the user is pressing keys. A collision check will occur each step as the player flies through the trench to determine if an obstacle has been hit.

Procedures:


  • DrawBox

    This routine will draw a rectanglular filled box at the specified position on the screen.
  • DrawWalls

    This routine draws the trapezoidal walls at each depth of the trench by making two calls to the drawTrapezoid procedure. A table lookup will be used to determine the correct parameter values to drawTrapezoid at each depth. The color of the trapezoids will be determined by the byte in _TRENCH at that depth. The obstacles are drawn in the corners first and then in the middle from top to bottom to avoid having edge colors overlap.
  • DrawTrapezoid

    This routine will draw a trapezoid at the specified position on the screen. Two trapezoids are available, left and right. Instead of being symmetrical about X though, the bottom part of the trapezoid will maintain a 2:1 width to height ratio, while the top will become 4:1.
  • DrawFloorCeiling

    This routine will draw in the base of the trench at each depth with gray and fill in the sky with black by setting up the proper colors, determining the correct starting pixel from the table lookups and making a call to DrawBox.
  • DrawXWing

    The procedure takes the image of an X-Wing and displays it on the screen over the trench image in a location designated by the inputs. The image will probably be represented as pallete numbers for each pixel. One pallete will be designated as "transparent" and the trench colors won't be overridden. By having the location of the image in the data segment be passed in, this procedure can be used to display different images (ie xwing from different angles or exploding).
  • CheckCollision

    The screen will be broken up into 6 equal sections (a 3x2 grid). Each of these grid cells represents a possible location for an obstacle. Each of these cells, in turn, is split into a smaller 4x4 grid. When these smaller grids are combined, they represent all possible locations for the Xwing. So, the position of the Xwing on the screen is passed in as di. Then the procedure determines which obstacle cell the xwing is in (probably using a lookup table), and then checks to see if there is an obstacle in that cell in that position along the trench (from _MAZE[si]). Returns 1 if there is, 0 if not.
  • ReadFile

    This routine simply reads the text file "Trench.dta" one byte at a time and writes the corresponding data into _TRENCH. Opening, reading, and closing of the file are all done using INT21h Dos commands.
  • UpdateScreen

    This routine will use di to look at the player's position in the trench. Then it will call DrawFloorCeiling, DrawWalls, and DrawObstacles at each depth to render the trench.
  • DrawObstacles

    This routine will examine the contents of _TRENCH to determine what kind of obstacle to render. Based on that it will calculate the appropriate starting position from an obstacle table lookup function. Then it will render the obstacle at that position using DrawBox and DrawParaT and DrawParaS.
  • DrawParaT

    This routine draws a vertical parallelgram on the screen at the specified location, creating a 3d effect for a box.
  • DrawParaT

    This routine draws a horizontal parallelgram on the screen at the specified location, creating a 3d effect for a box.
  • MainLoop

    This routine will be the main execution loop that keeps the program running until the player wins or dies. It will call UpdateScreen periodically after moving the player forward in the trench, or anytime the XWing has been moved. Most of the execution time will be spent polling for keystrokes and burning clock cycles since otherwise the game would be far too fast to actually play.
  • ReadKey

    This method is used to check if the keyboard has received a key using INT16h.
  • ProcessKeystroke

    ProcessKeystroke will determine which key has been pressed. If it is one of the arrow keys, _XWINGPOS will be updated. If the user has pressed "q" then the game will exit. Otherwise, the key will be discarded.
  • calcPos

  • outputs: di, corresponding pixel
  • uses: xwingwidth and xwingheight
  • programmer: Brian Blankstein and Craige Thomas Determines the pixel of the upper right corner of the XWing from where it is in xwingpos. This is used to display it at the appropriate place by drawXwing.
    We also ended up using a ShowPCX routine, written by Brandon Long for startup, death, and victory screens.