Hey.
I have my main template.cpp file and loading_class.h + loading_class.cpp files, which define loadingbar class.
Here's the whole loading_class.h:
class loadingbar
{
public:
int max_val, val;
int x,y;
int max_width,width,height;
int r1,g1,b1;
int r2,g2,b2;
int bkg, main, lighten;
int depth;
public:
loadingbar(int max_val_, int val_);
void SetColorBkg(int r_, int g_, int b_);
void SetColorMain(int r_, int g_, int b_);
void SetPosition(int x_, int y_);
void SetSize(int width_, int height_);
void SetValue(int val_);
};
Here's a part of loading_class.cpp:
#include "loading_class.h"
#include "agk.h"
using namespace AGK;
loadingbar::loadingbar(int max_val_, int val_)
{
depth = 10;
max_val = max_val_;
val = val_;
x=0; y=0;
width=100;
height=20;
max_width = width;
r1=0;
g1=0;
b1=0;
r2=0;
g2=0;
b2=0;
bkg = agk::CreateSprite(0);
agk::SetSpriteSize(bkg,width,height);
agk::SetSpritePosition(bkg,x,y);
main = agk::CreateSprite(0);
agk::SetSpriteSize(main,(val/max_val)*width-2,height-2);
agk::SetSpritePosition(main,x+1,y+1);
lighten = agk::CreateSprite(0);
agk::SetSpriteSize(lighten,(val/max_val)*width-2,height-2/1.3);
agk::SetSpritePosition(lighten,x+1,y+1);
agk::SetSpriteColor(lighten,r2+40,g2+40,b2+40,255);
agk::SetSpriteDepth(bkg,depth);
agk::SetSpriteDepth(main,depth);
agk::SetSpriteDepth(lighten,depth);
}
And here's main template.cpp:
// Includes, namespace and prototypes
#include "template.h"
#include "loading_class.h"
using namespace AGK;
app App;
int loading_image;
int loading_sprite;
int black;
int map_bkg[50][50];
int map_obj[50][50];
int map_col[50][50];
int map_img[480];
int map_sheet;
int nmb, nmb2, layer;
loadingbar load(100,1); //Making loadbar from class
// Begin app, called once at the start
void app::Begin( void )
{
agk::SetVirtualResolution(800,480);
agk::SetOrientationAllowed(0,0,1,0);
black = agk::CreateSprite(0);
agk::SetSpriteSize(black,800,480);
agk::SetSpriteDepth(black,1);
agk::SetSpriteColor(black,0,0,0,255);
nmb = 0;
nmb2 = 0;
layer = 0;
load.SetColorBkg(255,255,255);
load.SetColorMain(110,200,110);
load.SetPosition(100,100);
}
// Main loop, called every frame
void app::Loop ( void )
{
load.SetValue(load.val+5);
agk::Sync();
agk::Sleep(10);
}
// Close app
void app::End ( void )
{
}
Though, app opens and immediately exits, without any error.
Is this possible that I cannot create sprites from classes?