SCC.150 Assembler Emulator
A compiler for a simple assembler language
|
#include "moonlander.h"
Functions | |
int | main () |
void | initialisencurses () |
void | initialiseShip (SHIP *ship) |
void | initialiseLandscape (LANDSCAPE *landscape) |
void | createShip (SHIP *ship) |
bool | createLandscape (LANDSCAPE *landscape, unsigned int landscapeArray[], unsigned int safeArray[]) |
void | applyJet (SHIP *ship, unsigned int dir) |
void | applyGravity (SHIP *ship) |
void | applyFriction (SHIP *ship) |
void | moveShip (SHIP *ship, size_t lASize, unsigned int landscapeArray[], size_t sASize, unsigned int safeArray[]) |
void | displayIntro () |
double | getScore (SHIP *ship, unsigned int time) |
This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
This program attempts to emulate the 1979 Atari arcade classic 'Lunar Lander' in the *nix Terminal, using the ncurses library https://www.gnu.org/software/ncurses/ncurses.html. This can seemingly only be because Joe Finney is sadistic.
Implemented features so far are:
Features to implement by TOMORROW are:
void applyFriction | ( | SHIP * | ship | ) |
Applies the equally relentless force of friction to the ship.
ship | the ship in question |
void applyGravity | ( | SHIP * | ship | ) |
Applies the relentless march of gravity to the ship.
ship | the ship in question |
void applyJet | ( | SHIP * | ship, |
unsigned int | dir | ||
) |
Applies the thrust of the jet to the ship.
If the ship is out of fuel, the jets won't fire.
ship | the ship in question |
dir | the thrust direction |
bool createLandscape | ( | LANDSCAPE * | landscape, |
unsigned int | landscapeArray[], | ||
unsigned int | safeArray[] | ||
) |
Creates the landscape in the game world.
landscape | the landscape in question |
landscapeArray[] | the array of all the coordinates of the landscape components |
safeArray[] | the array of all the coordinates of the landing pad components |
void createShip | ( | SHIP * | ship | ) |
Creates the ship in the game world.
ship | the ship in question |
void displayIntro | ( | ) |
Displays the lovely ASCII lunar lander I nicked.
double getScore | ( | SHIP * | ship, |
unsigned int | time | ||
) |
Works out the player's score upon successful landing.
The specification states "score is calculated using some heuristic based on time used and fuel remaining." Heuristic sounds fancy, and so is the method of working out the score.
ship | the ship in question |
void initialiseLandscape | ( | LANDSCAPE * | landscape | ) |
Initialises the landscape's parameters.
landscape | the landscape in question |
void initialisencurses | ( | ) |
Initialises ncurses.
I couldn't decide whether it should be initialisencurses()
, initialiseNCURSES()
or initialiseNcurses()
. In the end I plumped for initialisencurses()
because, whilst it does break the camelCase rule I've used throughout for variables and functions, ncurses is one of those trendy uncapitalised names.
void initialiseShip | ( | SHIP * | ship | ) |
Initialises the ship's parameters.
ship | the ship in question |
int main | ( | ) |
The main function of the program.
Sets everything up initially, and then contains the game loop.
void moveShip | ( | SHIP * | ship, |
size_t | lASize, | ||
unsigned int | landscapeArray[], | ||
size_t | sASize, | ||
unsigned int | safeArray[] | ||
) |
Moves the ship within the game world.
ship | the ship in question |
lASize | the length of useful data in landscapeArray |
landscapeArray | the array of coordinates for the components of the landscape |
sASize | the length of useful data in safeArray |
safeArray | the array of coordinates for the components of the landing pad(s) |