• Display

    Download the display program (do not use the copy of display from previous lab, this lab references a newer version of display) and make sure you can compile and run display.c

    You can download the display program with any of the following methods:

      Using GIT (recommended):
    • cd into your lab folder
    • issue these command at the command prompt:
      • git clone https://github.com/zhaol/game_scaffold.git
      • cd game_scaffold
      • git checkout tags/v1.1.1
      Manually copying and pasting the files:
    • all the necessary files are listed here: https://github.com/zhaol/game_scaffold/tree/v1.1.1
    • when copying and pasting the file content, be sure you are copying and pasting the contents of the files for version 1.1.1 (you should see "tag: v1.1.1" in the top left area)

    No matter which method you choose, be sure the version.txt file says:

    v1.1.1
    
    Lab 08:
    Contrain token to inside boundaries
    Add items for token to "pick up"
  • Display with Boundaries and Items

    At the end of this problem you should submit to Laulima (please zip these files to work around the 5 file limit):

    • a file named UHusername_display_boundaries_items.c
    • a file named UHusername_display_boundaries_items.h
    • a file named UHusername_display_boundaries_items_constants.h
    • a file named UHusername_display_boundaries_items_helpers.c
    • a file named UHusername_display_boundaries_items_helpers.h
    • a file named UHusername_display_boundaries_items_setup.h

      example:

      • zhaol_display_boundaries_items.c
      • zhaol_display_boundaries_items.h
      • zhaol_display_boundaries_items_constants.h
      • zhaol_display_boundaries_items_helpers.c
      • zhaol_display_boundaries_items_helpers.h
      • zhaol_display_boundaries_items_setup.h
    • Update the display program

      Understand how the display program works (the program has changed slightly from the previous lab) and make the following modifications:

      1. Add boundaries to the program:

        • update the update_y_position and the update_x_position functions (in display_helpers.c) so the token can never go outside the screen
      2. Add items to the program:

        • update the program so an item is randomly placed somewhere on the screen at the beginning of the program
        • whenever the token moves "on top" of the item, the item dissappears and a new item appears randomly somewhere else on the screen
      3. Hints (feel free to not use them):

        • use rand() to generate a random number
        • you will most likely need to track another set of x and y positions
        • you will most likely need to have a function that compares the x and y positions of the token and the item
        • you will need to update the redraw_screen() function in display_helpers.c to display the item