George Sykes ELEC2645 project

Dependencies:   mbed

https://os.mbed.com/media/uploads/el18gs/pixil-frame-0.png

GHOST HUNTER

In a world of ghostly horrors there is much money to be made in underground ghost fighting rings. You've managed to get hold of a Ghostbuster, a special piece of equipment that allows you to catch, train and fight ghosts.

Instructions

Below you will find the instructions for the game. Please note that due to COVID-19 a large part of the game (fighting ghosts) could not be added as it would have required access to a second gamepad which i could not acquire.

Welcome screen

When first started you will be presented with a welcome screen

  • Pot 1 to adjust the contrast on the screen
  • Press A to continue.

Main menu

You have three options, catch ghosts (add ghosts to your inventory), inventory (sell ghosts) or settings(adjust the games settings).

  • Press X and B to move the selection up and down respectively
  • Press A to enter the selected submenu

Catch Ghost

Will now be presented with two challenges. In the first you need to find a ghost, in the second you catch it. Theses stages will start automatically.

Find ghost

Rotate the gamepad on its roll and pitch axis until all the LED's turn on. The ones on the left indicate roll and the right pitch.

  • Rotate the gamepad on it roll and pitch to light up the LED's

Catch ghost

Return the gamepad to a comfortable position and use the joystick to move the crosshairs onto the ghost sprite. When ready press the A button to catch the ghost. You will be told what kind of ghost you have captured and it will be added to your inventory.

  • Press A to catch the ghost
  • Move the joystick to move the crosshairs

Inventory

The inventory allows you to view your ghosts and sell them.

  • Use Pot 1 to scroll through the ghosts
  • Pot 2 to scroll up and down the details of the individual ghosts
  • Press X to prepare to sell a ghost and press again to confirm, if you don't press again the sale screen will disappear after 5 seconds
  • Press Start to return to the main menu

Settings

This menu allows you to adjust some of the settings of the game.

  • Press X to go up one option
  • Press B to go down one option
  • Press A to enter the selected submenu
  • Press Start to return to the main menu

Contrast

Set the contrast of the LCD screen, the contrast will adjust on this screen so you can see the effect (contrast is bounded between 0.4 and 0.6).

  • Pot 1 to increase or decrease the contrast
  • Press A to set the contrast

Button Delay

Set the minimum time between button presses; if this is too low the game will detect two button presses when there was only one, too high and the buttons will seem unresponsive. So as to ensure these issues do not occur while changing the setting button X temporarily operates on the new delay but none of the others will until A is pressed.

  • Pot 1 to increase or decrease the delay
  • Press X to test the new delay, this will toggle the small circle to be filled in or unfilled
  • Press A to save the setting
Committer:
el18gs
Date:
Sat Feb 08 13:13:34 2020 +0000
Revision:
1:8d14be858ca0
initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el18gs 1:8d14be858ca0 1 #include "Bitmap.h"
el18gs 1:8d14be858ca0 2
el18gs 1:8d14be858ca0 3 #include <iostream>
el18gs 1:8d14be858ca0 4
el18gs 1:8d14be858ca0 5 #include "N5110.h"
el18gs 1:8d14be858ca0 6
el18gs 1:8d14be858ca0 7 Bitmap::Bitmap(int const *contents,
el18gs 1:8d14be858ca0 8 unsigned int const height,
el18gs 1:8d14be858ca0 9 unsigned int const width)
el18gs 1:8d14be858ca0 10 :
el18gs 1:8d14be858ca0 11 _contents(std::vector<int>(height*width)),
el18gs 1:8d14be858ca0 12 _height(height),
el18gs 1:8d14be858ca0 13 _width(width)
el18gs 1:8d14be858ca0 14 {
el18gs 1:8d14be858ca0 15 // Perform a quick sanity check of the dimensions
el18gs 1:8d14be858ca0 16 if (_contents.size() != height * width) {
el18gs 1:8d14be858ca0 17 std::cerr << "Contents of bitmap has size " << _contents.size()
el18gs 1:8d14be858ca0 18 << " pixels, but its dimensions were specified as "
el18gs 1:8d14be858ca0 19 << width << " * " << height << " = " << width * height << std::endl;
el18gs 1:8d14be858ca0 20 }
el18gs 1:8d14be858ca0 21
el18gs 1:8d14be858ca0 22 for(unsigned int i = 0; i < height*width; ++i) _contents[i] = contents[i];
el18gs 1:8d14be858ca0 23 }
el18gs 1:8d14be858ca0 24
el18gs 1:8d14be858ca0 25 /**
el18gs 1:8d14be858ca0 26 * @returns the value of the pixel at the given position
el18gs 1:8d14be858ca0 27 */
el18gs 1:8d14be858ca0 28 int Bitmap::get_pixel(unsigned int const row,
el18gs 1:8d14be858ca0 29 unsigned int const column) const
el18gs 1:8d14be858ca0 30 {
el18gs 1:8d14be858ca0 31 // First check that row and column indices are within bounds
el18gs 1:8d14be858ca0 32 if(column >= _width || row >= _height)
el18gs 1:8d14be858ca0 33 {
el18gs 1:8d14be858ca0 34 std::cerr << "The requested pixel with index " << row << "," << column
el18gs 1:8d14be858ca0 35 << "is outside the bitmap dimensions: " << _width << ","
el18gs 1:8d14be858ca0 36 << _height << std::endl;
el18gs 1:8d14be858ca0 37 }
el18gs 1:8d14be858ca0 38
el18gs 1:8d14be858ca0 39 // Now return the pixel value, using row-major indexing
el18gs 1:8d14be858ca0 40 return _contents[row * _width + column];
el18gs 1:8d14be858ca0 41 }
el18gs 1:8d14be858ca0 42
el18gs 1:8d14be858ca0 43 /**
el18gs 1:8d14be858ca0 44 * @brief Prints the contents of the bitmap to the terminal
el18gs 1:8d14be858ca0 45 */
el18gs 1:8d14be858ca0 46 void Bitmap::print() const
el18gs 1:8d14be858ca0 47 {
el18gs 1:8d14be858ca0 48 for (unsigned int row = 0; row < _height; ++row)
el18gs 1:8d14be858ca0 49 {
el18gs 1:8d14be858ca0 50 // Print each element of the row
el18gs 1:8d14be858ca0 51 for (unsigned int column = 0; column < _width; ++column)
el18gs 1:8d14be858ca0 52 {
el18gs 1:8d14be858ca0 53 int pixel = get_pixel(row, column);
el18gs 1:8d14be858ca0 54 std::cout << pixel;
el18gs 1:8d14be858ca0 55 }
el18gs 1:8d14be858ca0 56
el18gs 1:8d14be858ca0 57 // And then terminate with a new-line character
el18gs 1:8d14be858ca0 58 std::cout << std::endl;
el18gs 1:8d14be858ca0 59 }
el18gs 1:8d14be858ca0 60 }
el18gs 1:8d14be858ca0 61
el18gs 1:8d14be858ca0 62 /**
el18gs 1:8d14be858ca0 63 * @brief Renders the contents of the bitmap onto an N5110 screen
el18gs 1:8d14be858ca0 64 *
el18gs 1:8d14be858ca0 65 * @param[in] lcd The screen to use for rendering
el18gs 1:8d14be858ca0 66 * @param[in] x0 The horizontal position in pixels at which to render the bitmap
el18gs 1:8d14be858ca0 67 * @param[in] y0 The vertical position in pixels at which to render the bitmap
el18gs 1:8d14be858ca0 68 *
el18gs 1:8d14be858ca0 69 * @details Note that x0, y0 gives the location of the top-left of the bitmap on
el18gs 1:8d14be858ca0 70 * the screen.
el18gs 1:8d14be858ca0 71 * This function only updates the buffer on the screen. You still need
el18gs 1:8d14be858ca0 72 * to refresh the screen in order to actually see the bitmap.
el18gs 1:8d14be858ca0 73 */
el18gs 1:8d14be858ca0 74 void Bitmap::render(N5110 &lcd,
el18gs 1:8d14be858ca0 75 unsigned int const x0,
el18gs 1:8d14be858ca0 76 unsigned int const y0) const
el18gs 1:8d14be858ca0 77 {
el18gs 1:8d14be858ca0 78 // Loop through each row of the bitmap image
el18gs 1:8d14be858ca0 79 for (unsigned int bitmap_row = 0; bitmap_row < _height; ++bitmap_row)
el18gs 1:8d14be858ca0 80 {
el18gs 1:8d14be858ca0 81 // Row index on the screen for rendering the row of pixels
el18gs 1:8d14be858ca0 82 unsigned int screen_row = y0 + bitmap_row;
el18gs 1:8d14be858ca0 83
el18gs 1:8d14be858ca0 84 // Render each pixel in the row
el18gs 1:8d14be858ca0 85 for (unsigned int bitmap_col = 0; bitmap_col < _width; ++bitmap_col)
el18gs 1:8d14be858ca0 86 {
el18gs 1:8d14be858ca0 87 // Column index on the screen for rendering this pixel
el18gs 1:8d14be858ca0 88 int screen_col = x0 + bitmap_col;
el18gs 1:8d14be858ca0 89
el18gs 1:8d14be858ca0 90 // Find the required value of the pixel at the given location within
el18gs 1:8d14be858ca0 91 // the bitmap data and then write it to the LCD screen
el18gs 1:8d14be858ca0 92 int pixel = get_pixel(bitmap_row, bitmap_col);
el18gs 1:8d14be858ca0 93 lcd.setPixel(screen_col, screen_row, pixel);
el18gs 1:8d14be858ca0 94 }
el18gs 1:8d14be858ca0 95 }
el18gs 1:8d14be858ca0 96 }