Bad news, it still crashes.
Maybe more code will help?
Full class:
event.h
#ifndef EVENT_H
#define EVENT_H
#include "agk.h"
using namespace AGK;
class Event{
private:
int x, y;
UINT imgid;
UINT cycle_image[12];
int moving;
int dist;
public:
UINT sprite_id;
Event(int img_id, int pnumber, int x1, int y1);
~Event();
};
#endif
event.cpp
#include "event.h"
#include "template.h"
Event::Event(int img_id, int pnumber, int x1, int y1)
{
x = x1;
y = y1;
imgid = img_id;
int n = 0;
switch(pnumber)
{
case 1:
n = 0;
break;
case 2:
n = 3;
break;
case 3:
n = 6;
break;
case 4:
n = 9;
break;
case 5:
n = 48;
break;
case 6:
n = 51;
break;
case 7:
n = 54;
break;
case 8:
n = 57;
break;
}
int m = 0;
for(int y2=0; y2<4; y2++)
{
for(int x2=0; x2<3; x2++)
{
cycle_image[m] = agk::LoadSubImage(imgid,agk::Str(n+1));
n++;
m++;
}
n+=9;
}
moving = 0;
dist = 0;
sprite_id = agk::CreateSprite(cycle_image[7]);
agk::SetSpriteDepth(sprite_id,8);
agk::SetSpritePosition(sprite_id,x*16-4,y*16-16);
agk::SetSpriteSnap(sprite_id,1);
for(int n=0; n<12; n++)
{
agk::AddSpriteAnimationFrame(sprite_id,cycle_image[n]);
if(n == 2 || n == 5 || n == 8 || n == 11)
agk::AddSpriteAnimationFrame(sprite_id,cycle_image[n-1]);
}
agk::SetSpriteFrame(sprite_id,7);
}
Event::~Event()
{
agk::DeleteSprite(sprite_id);
agk::DeleteImage(imgid);
for(int n=0; n<12; n++)
agk::DeleteImage(cycle_image[n]);
}
inside template.h
std::vector<Event*> map_event;
Inside void CreateEntities called by template.cpp
agk::OpenToRead(1, first_name);
agk::ReadLine(1);
int x1 = agk::Val(agk::ReadLine(1));
agk::ReadLine(1);
int y1 = agk::Val(agk::ReadLine(1));
agk::ReadLine(1);
char file_to_open[512];
for(int n=0; n<512; n++)
file_to_open[n] = NULL;
sprintf(file_to_open,"%s",agk::ReadLine(1));
agk::ReadLine(1);
int pnumber = agk::Val(agk::ReadLine(1));
char* cr_dir = agk::GetCurrentDir();
agk::SetCurrentDir("");
agk::SetCurrentDir("media/charset");
int imgnmb = agk::LoadImage(file_to_open);
App.map_event.push_back(new Event(imgnmb,pnumber,x1,y1));
agk::SetCurrentDir("");
agk::SetCurrentDir(cr_dir);
agk::CloseFile(1);
As you can see, there's App.map_event.push_back.
I'll add that I have another class, almost the same as event.cpp and it doesn't crash, so it's 100% that it's something wrong with the vector.