Space Type 1.0
A retro typing trainer, test and game set in space
Loading...
Searching...
No Matches
spacetype_game.c File Reference

Word Shooter Game for Spacetype. More...

Include dependency graph for spacetype_game.c:
This graph shows which files directly or indirectly include this file:

Functions

void text_mover (Vector2 *wordPos, Rectangle playerPos, Vector2 gap, float time)
 Moves the word toward the player.
 
void game ()
 main function for game mode
 

Variables

Main gameplay variables

These variables handle different aspects related to the main gameplay.

char * words []
 List of words to choose from for the game.
 
char word [20]
 word which is presented to type
 
char wordStored [20]
 stores the presented word to later compare with fastestword and slowestword
 
int sizeOfArray = sizeof(words) / sizeof(words[0])
 for calculating total number of words*‍/
 
Vector2 gap = {}
 Shortest distance between word and spaceship*‍/.
 
Vector2 wordPos
 position of word as it falls down
 
const int fontSize = 25
 Fonsize declaration for uniformity of fontsize.
 
float angle = 0
 Angle of word to have it fall towards player.
 
float prevAngle = 0
 Angle of the spaceship.
 
float movingPlanets = 0
 Denotes which planet will be on screen.
 
float movingDown = 0
 Parameters which makes space texture scroll infinitely*‍/.
 
bool GAME_OVER = false
 boolean to check game over condition
 
Bullet related variables

These variables handle different aspects related to bullet which destroys the word when it is finished being typed.

Sound shoot
 Audio played when bullet is used.
 
Rectangle bulletPos
 Bullet Position.
 
bool bullet = false
 indicates whether bullet needs to be shoot or not
 
float bulletAngle
 Determine angle at which bullet needs to be thrown depending word position.
 
float bulletMover = 0
 To indicate speed of the bullet.
 
Extern variables from main

different variables initialized before needed for this portion

Music music
 background music
 
int screenWidth
 screen width for graphical operations
 
int screenHeight
 screen height for graphical operations
 
Font retroFont
 

Detailed Description

Word Shooter Game for Spacetype.

Author
Praharsha Adhikari 078bc.nosp@m.t061.nosp@m..prah.nosp@m.arsh.nosp@m.a@pca.nosp@m.mpus.nosp@m..edu..nosp@m.np
Bug:
No known bug

Function Documentation

◆ game()

void game ( )

main function for game mode

Handles everything regarding spaceship shoot game. Resets variables specific to the game and general by calling reset_counter. Draws the graphics regarding spaceship falling words and bullets. Handles the gameplay mechanics and shows a gameover screen when required.

Resetting in case of new game from menu

Initialize variables and textures

Here is the call graph for this function:

◆ text_mover()

void text_mover ( Vector2 *  wordPos,
Rectangle  playerPos,
Vector2  gap,
float  time 
)

Moves the word toward the player.

Parameters
wordPosPosition of generated word
playerPosPosition of spaceship
gapShortest distance between word and spaceship
timeSet time for the word to hit the player

Variable Documentation

◆ words

char* words[]
Initial value:
=
{
"apple", "ant", "airplane", "banana", "book", "boat", "cat", "cow", "car", "dog", "desk", "dolphin", "elephant", "egg", "earth", "fish", "flamingo", "frog", "giraffe", "goat", "grapes", "hat", "horse", "house", "igloo", "icecream", "insect", "jacket", "jaguar", "juice", "kangaroo", "kite", "key", "lion", "leopard", "lamp", "monkey", "mouse", "mango", "night", "nest", "napkin", "octopus", "ostrich", "onion", "pear", "panda", "pig", "queen", "quail", "question", "rabbit", "rhinoceros", "ring", "snake", "snail", "sock", "tiger", "taco", "table", "unicorn", "umbrella", "vase", "vegetable", "whale", "wolf", "watermelon", "xray", "xylophone", "yak", "yoyo", "zipper", "zoo"
}

List of words to choose from for the game.