Skip to content
Snippets Groups Projects
Commit a2cb6ec3 authored by Oliver Dimes's avatar Oliver Dimes
Browse files

Adding Text Loading Animation

parent c5422e05
No related merge requests found
......@@ -29,4 +29,5 @@ void XMLreader::process(string filename) {
lines.popTag(); //Popping tag for speech
}
lines.popTag(); //Popping for trump
}
\ No newline at end of file
}
......@@ -35,6 +35,11 @@ void enemy::enemyDefend()
}
void enemy::mousePressedInteractions()
{
}
enemy::~enemy()
{
......
......@@ -23,6 +23,7 @@ public:
void enemyAttack(float damage);
void enemyDefend(); //The first variable is the playerHealth, the second is the damage the NPC will do!
;
~enemy();
protected: //Variables that can only be accessed with inhertiance
float xPos;
......
......@@ -10,7 +10,9 @@ farage::farage(float x, float y) : enemy(20,100,0,0,0) { //The values of the ene
}
void farage::setup() {
lines.readLine("trump.txt");
XMLlines.process("farage.xml"); //This is the line that processes
}
void farage::draw() {
//Put visual code here
......
......@@ -12,6 +12,7 @@ class farage : public enemy {
void setup();
linereader lines; //Declaring a line reader file, each file is diffirent
float mapped;
vector <string> linesXML;
private:
ofMaterial material;
};
......
......@@ -15,7 +15,7 @@ void ofApp::setup(){
winWidth = ofGetWidth();
winHeight = ofGetHeight();
//XML Reading Stuff
}
//--------------------------------------------------------------
......@@ -74,9 +74,7 @@ void ofApp::draw(){
//Enemy Appearence
TrumpEnemy.imageDraw(ofGetWidth() / 2 - 250 + enemyMoveX, ofGetHeight() / 2 - 250 + enemyMoveY); //Position for the character head
TrumpEnemy.draw();
TrumpEnemy.enemyDefend();
//HUD RELATED FUNCTIONS
......@@ -108,13 +106,6 @@ void ofApp::draw(){
ofDrawBitmapString("Player HP : " + ofToString(playerValues.health), 500, 10);
ofDrawBitmapString("Player SP : " + ofToString(playerValues.skill), 500, 30);
////Enemy Headline
//ofSetColor(0);
//ofRect(0, ofGetHeight() * 0.70, ofGetWidth(), ofGetHeight() * 0.09);
//ofSetColor(255);
//lineText.drawString("Trump : " + TrumpEnemy.lines.getLine(lineChanger), winWidth*0.1, winHeight*0.76);
}
//--------------------------------------------------------------
......@@ -140,22 +131,12 @@ void ofApp::mouseDragged(int x, int y, int button){
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
if (mouseX > 0 && mouseX < winWidth*0.33 && mouseY > winHeight*0.75)
{
std::cout << "this works " << std::endl;
TrumpEnemy.enemyAttack(1);
if (lineChanger < TrumpEnemy.lines.phrases.size())
{
lineChanger += 1;
}
}
TrumpEnemy.enemyAttack(1);
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
playerValues.playerLoseHealth(2);
}
//--------------------------------------------------------------
......
......@@ -4,9 +4,7 @@
trump::trump(float x, float y) : enemy(10,100,0,0,0) { //The values of the enemy
xPos = x;
yPos = y;
mapped = health;
yPos = y;;
}
void trump::setup() {
......@@ -15,6 +13,12 @@ void trump::setup() {
}
void trump::draw() {
//This variable simply handles the method to make the text loading effect
timeMeasure += ofGetFrameNum(); //Set to 500 to turn off the strobe effect
//Health Bar Calculation (SCALE NOT PERFECT)
mapped = ofMap(health, 0, 10, 0, ofGetWidth() - 70);
//Put visual code here
ofDrawBitmapString("Health : " + ofToString(health), 10, 10);
ofDrawBitmapString("Skill : " + ofToString(skillLevel), 10, 30);
......@@ -27,24 +31,29 @@ void trump::draw() {
ofRect(0, ofGetHeight() * 0.82, ofGetWidth(), ofGetHeight() * 0.08);
ofRect(0, ofGetHeight() * 0.90, ofGetWidth(), ofGetHeight() * 0.08);
ofSetColor(0);
ofRect(30, 10, ofGetWidth() - 60, ofGetHeight() * 0.075);
ofSetColor(0,255,0);
ofRect(35, 15, mapped, ofGetHeight() * 0.06);
for (int i = 0; i < 1; i++)
{
ofSetColor(255);
lineText.drawString("Trump : " + XMLlines.text[i], ofGetWidth()*0.1, ofGetHeight()*0.71); // Question
ofSetColor(0);
lineText.drawString("1. " + XMLlines.answer[i], ofGetWidth()*0.1, ofGetHeight()*0.80);
lineText.drawString("2. " + XMLlines.wrongAnswer1[i], ofGetWidth()*0.1, ofGetHeight()*0.88);
lineText.drawString("3. " + XMLlines.wrongAnswer2[i], ofGetWidth()*0.1, ofGetHeight()*0.96);
if (timeMeasure > 300 && loopCheck < XMLlines.text[2].size()) //This if statement allows for the loading animation in the program
{
loopCheck = loopCheck + 1;
timeMeasure = 0;
}
lineText.drawString("Trump : " + XMLlines.text[2].substr(0,loopCheck), ofGetWidth()*0.1, ofGetHeight()*0.71); // Question
//ofNoFill();
if (loopCheck == XMLlines.text[2].size())
{
ofSetColor(0);
lineText.drawString("1. " + XMLlines.answer[2], ofGetWidth()*0.1, ofGetHeight()*0.80);
lineText.drawString("2. " + XMLlines.wrongAnswer1[2], ofGetWidth()*0.1, ofGetHeight()*0.88);
lineText.drawString("3. " + XMLlines.wrongAnswer2[2], ofGetWidth()*0.1, ofGetHeight()*0.96);
}
}
......
......@@ -8,7 +8,7 @@
class trump : public enemy {
public:
trump(float x, float y);
trump(float x, float y);
void draw();
void setup();
linereader lines; //Declaring a line reader file, each file is diffirent
......@@ -17,7 +17,10 @@ class trump : public enemy {
private:
ofMaterial material;
float timeMeasure;
string result;
int loopCheck;
};
#endif
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment