SCC.150 Assembler Emulator
A compiler for a simple assembler language
 All Data Structures Files Functions
Data Structures | Macros | Typedefs | Functions | Variables
moonlander.h File Reference
#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
 

Macros

#define NONE   0
 
#define UP   1
 
#define RIGHT   2
 
#define DOWN   3
 
#define LEFT   4
 
#define LEFT_INCLINE   0
 
#define STRAIGHT_UP   1
 
#define STRAIGHT_DOWN   2
 
#define RIGHT_DECLINE   3
 
#define PLATEAU   4
 
#define NONE   0
 
#define CRASH   1
 
#define LAND   2
 
#define QUIT   3
 
#define STARTING_FUEL   900
 
#define CHANCE_OF_LANDING_PAD   3
 
#define TERMINAL_VELOCITY   0.9f
 

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
 

Detailed Description

Author
Ben Goldsworthy (rumps) bgold.nosp@m.swor.nosp@m.thy96.nosp@m.@gma.nosp@m.il.co.nosp@m.m
Version
1.0

LICENSE

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/.

DESCRIPTION

Header file for moonlander.c.

Function Documentation

void applyFriction ( SHIP ship)

Applies the equally relentless force of friction to the ship.

Parameters
shipthe ship in question
void applyGravity ( SHIP ship)

Applies the relentless march of gravity to the ship.

Parameters
shipthe 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.

Parameters
shipthe ship in question
dirthe thrust direction
void createShip ( SHIP ship)

Creates the ship in the game world.

Parameters
shipthe 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.

Parameters
shipthe ship in question
Returns
the score
void initialiseLandscape ( LANDSCAPE landscape)

Initialises the landscape's parameters.

Parameters
landscapethe 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.

Parameters
shipthe 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.

Parameters
shipthe ship in question
lASizethe length of useful data in landscapeArray
landscapeArraythe array of coordinates for the components of the landscape
sASizethe length of useful data in safeArray
safeArraythe array of coordinates for the components of the landing pad(s)