I think the title pretty much sums my issue up. I'm trying to learn tier 2 as I want to create a OO program, (And I have to use c++ instead of Java which I know) and I just can't seem to figure out how to create a new object.
Using the example template, I created a new class called Screen, the constructor sets up some default values, and I just want to display them in the app::loop section.
Here's Screen.h
#pragma once
#define UI_STATE_INACTIVE 0
#define UI_STATE_TRANSIN 1
#define UI_STATE_ACTIVE 2
#define UI_STATE_TRANSOUT 4
class Screen
{
private:
char *chrName;
float fCurrentXPos, fCurrentYPos, fCurrentAlpha; // All values will be percentages.
float fDestinationXPos, fDestinationYPos, fDestinationAlpha; // All values will be percentages.
unsigned int uintCurrentState;
struct Transitions
{
bool bTransCut;
bool bTransFade;
bool bTransSlideFromBottom;
bool bTransSlideFromTop;
bool bTransSlideFromRight;
bool bTransSlideFromLeft;
};
struct Transitions transitions;
public:
Screen(char *chrNewName); // Constructor
~Screen();// Destructor
void show();
void hide();
void update();
float getCurrentAlpha();
};
Here's an extract of the cpp file:
// Includes
#include "Screen.h"
#include "template.h"
// Namespace
using namespace AGK;
Screen::Screen(char *chrNewName)
{
chrName = chrNewName;
fCurrentXPos = 0.0f;
fCurrentYPos = 0.0f;
fCurrentAlpha = 0.0f;
fDestinationXPos = 0.0f;
fDestinationYPos = 0.0f;
fDestinationAlpha = 0.0f;
uintCurrentState = UI_STATE_INACTIVE;
transitions.bTransCut = true;
transitions.bTransFade = false;
transitions.bTransSlideFromBottom = false;
transitions.bTransSlideFromTop = false;
transitions.bTransSlideFromRight = false;
transitions.bTransSlideFromLeft = false;
}
Screen::~Screen()
{
delete[] chrName;
}
float Screen::getCurrentAlpha() {
return fCurrentAlpha;
}
And here's the main part.
// Includes
#include "Screen.h"
#include "template.h"
// Namespace
using namespace AGK;
app App;
void app::Begin(void)
{
agk::SetVirtualResolution ( 100, 100 );
agk::SetClearColor( 0, 0, 0 ); // light blue
agk::SetSyncRate( 0, 0 );
agk::SetScissor( 0, 0, 0, 0 );
Screen screen( "Test" );
}
void app::Loop (void)
{
agk::Print( screen.getCurrentAlpha() );
agk::Sync();
}
void app::End (void)
{
}
Any ideas what I'm doing wrong because for the life of me I can't figure it out..