SCC.150 Assembler Emulator
A compiler for a simple assembler language
|
#include <stdbool.h>
#include <ncurses.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
Go to the source code of this file.
Data Structures | |
struct | _win_landscape_struct |
struct | _WIN_landscape_struct |
struct | _win_ship_struct |
struct | _WIN_ship_struct |
struct | timespec_t |
Typedefs | |
typedef struct _win_landscape_struct | WIN_LANDSCAPE |
typedef struct _WIN_landscape_struct | LANDSCAPE |
typedef struct _win_ship_struct | WIN_SHIP |
typedef struct _WIN_ship_struct | SHIP |
Functions | |
void | initialisencurses () |
void | initialiseShip (SHIP *ship) |
void | initialiseLandscape (LANDSCAPE *landscape) |
void | createShip (SHIP *ship) |
bool | createLandscape () |
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) |
Variables | |
bool | end = false |
unsigned int | endType = NONE |
struct timespec_t | s |
bool | invincible = false |
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/.
Header file for moonlander.c
.
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 |
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 |
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) |