EchoesOfFate
A game for our COMP315 Project
 
Loading...
Searching...
No Matches
SceneClass Class Reference

#include <SceneClass.h>

Public Member Functions

 SceneClass (float speed=0.05f)
 tracks what scene is being displayed from the textfile vector
 
 SceneClass (std::string imageFile, std::string musicFile)
 
void update ()
 
void handleInput (Event event)
 
void draw (RenderWindow &window)
 
void draw (RenderWindow &window, bool bg)
 
void playMusic ()
 
void stopMusic ()
 
bool isSceneDone ()
 
std::string formatText (std::string currentText)
 
void updateBackground (std::string newBackground)
 
void updateChracter (std::string newCharacter)
 
void updateDisplayText (std::string newText)
 
void updateMusic (std::string newMusic)
 
std::vector< SceneParameters * > getScenes ()
 
void textFileReader (std::string fileName)
 Takes in a file name of a file in the assets folder(file extention not needed in file name)(HELPER)
 
std::vector< std::string > split (std::string line, char delimiter)
 reads text files and stores it in a scenes vector
 
int getCurrentScene ()
 splits string with a delimiter
 
void updateSceneTracker ()
 gets the current scene from textfile vector
 

Constructor & Destructor Documentation

◆ SceneClass() [1/2]

SceneClass::SceneClass ( float speed = 0.05f)

tracks what scene is being displayed from the textfile vector

Load font and setup text(adds
as well)

Load font var with our font we downloaded (note this font is ugly and we will change it when we download a better one)

set our text with the font

set text colour

Empty string initially

font size

Set the typewritting speed

◆ SceneClass() [2/2]

SceneClass::SceneClass ( std::string imageFile,
std::string musicFile )

Set the sprite var to contain our image loaded in texture1 (this is because background is of type sprite with useful functions to call)

This reduces the sprite image we downloaded to 20% of its size because gpt generates the image too big

Member Function Documentation

◆ draw() [1/2]

void SceneClass::draw ( RenderWindow & window)

Scale background to match window size

Scale character to be 20% of original image size

Position character on the bottom left side of the screen

Scale character to be 50% of original image size

Position character on the bottom left side of the screen

Full width, 150px height (creates the textbox)

Semi-transparent black

Position at bottom of screen

Position inside the textbox border

Set the text string to the current displayed text (this gets updated letter by letter)

Draw the background

Draw the sprite

Draw the textbox

Draw the text

◆ draw() [2/2]

void SceneClass::draw ( RenderWindow & window,
bool bg )

Scale background to match window size

Draw the background

◆ formatText()

std::string SceneClass::formatText ( std::string currentText)

set padding and create a string builder

add a space at the end of text so it gets the last word

set our text with the font

font size

set text to empty

build string with words until it reaches max padding then go to new line

get word

skip redundant spaces

if it is the first word of the text just add it

check if adding this word exceeds the max width

add new line and have the start of the new line exceeded max width

set new line just before word

We are now on a new line with 1 word

reset word

get last words

◆ getCurrentScene()

int SceneClass::getCurrentScene ( )

splits string with a delimiter

◆ getScenes()

std::vector< SceneParameters * > SceneClass::getScenes ( )

◆ handleInput()

void SceneClass::handleInput ( Event event)

Auto-complete the text

std::cout << "Auto-completing text" << std::endl;

◆ isSceneDone()

bool SceneClass::isSceneDone ( )

◆ playMusic()

void SceneClass::playMusic ( )

Fetching the music text file

Playing the music

◆ split()

std::vector< std::string > SceneClass::split ( std::string line,
char delimiter )

reads text files and stores it in a scenes vector

Splits a string according to a delimiter and stores the results in a vector(HELPER)

Build string if a delimiter is not found, else reset string

add last element

◆ stopMusic()

void SceneClass::stopMusic ( )

Playing the music

◆ textFileReader()

void SceneClass::textFileReader ( std::string fileName)

Takes in a file name of a file in the assets folder(file extention not needed in file name)(HELPER)

stores a line of the text file

reads from the textfile

store each line

if an empty line is found do not add it to the list of scenes

if incorrect number of values are given(this handles it) set all values to deauflt values

set it to default values

needs to be destroyed at the end(in deconstructor)

default values

needs to be destroyed at the end(in deconstructor)

closes file

◆ update()

void SceneClass::update ( )

Add one more character to the displayed text at the typing speed

Only add the next character after the typing speed delay

Restart the clock for the next letter

if you do not press enter and the text finishes

Update text to display the current displayedText

◆ updateBackground()

void SceneClass::updateBackground ( std::string newBackground)

◆ updateChracter()

void SceneClass::updateChracter ( std::string newCharacter)

◆ updateDisplayText()

void SceneClass::updateDisplayText ( std::string newText)

reset text effect

◆ updateMusic()

void SceneClass::updateMusic ( std::string newMusic)

stops music

change music

play new song

◆ updateSceneTracker()

void SceneClass::updateSceneTracker ( )

gets the current scene from textfile vector


The documentation for this class was generated from the following files: