예제 #1
0
int32 ResetSprite(void *systemData, void *userData)
{
    GameManager *mgr;

    if(systemData != NULL)
    {
        Sprite *spritePtr = (Sprite *)systemData;

        mgr = spritePtr->GetManager();
        mgr->RemoveGameObject(spritePtr);
        delete spritePtr;
    }
    else
    {
        mgr = (GameManager*)userData;
    }

    Sprite *tmp = new Sprite(mgr);
    tmp->SetImage(mgr->GetResourceManager()->GetImage(ARROW_HANDLE));
    tmp->SetBaseLocation(CIwVec2(mgr->GetSurfaceWidth() / 2, mgr->GetSurfaceHeight() / 2));
    tmp->AddTransformation(new AnchorTransformation());
    OrbitTransformation *orbiter = new OrbitTransformation(150, 5000, 0, Clockwise);
    tmp->AddTransformation(orbiter);
    mgr->RegisterGameObject(tmp);

    tmp->SetLifespan(++resetCount * 500);
    tmp->SetCompletionCallback(ResetSprite, NULL);

    return 0;
}
예제 #2
0
S3E_MAIN_DECL void IwMain()
{
    srand(time(NULL));

    GameManager *mgr;
    mgr = new GameManager();

    mgr->SetRequestedFPS(100);

    mgr->GetResourceManager()->RegisterResourceGroup("images.group");

    BUG_HANDLE = mgr->GetResourceManager()->RegisterImage("bug");
    SPLAT_HANDLE = mgr->GetResourceManager()->RegisterImage("splat");
    LEAVES_HANDLE = mgr->GetResourceManager()->RegisterImage("leaves");
    ARROW_HANDLE = mgr->GetResourceManager()->RegisterImage("right_arrow");
    FIRE_HANDLE = mgr->GetResourceManager()->RegisterImage("FireBlast");

    TREB_FONT_HANDLE = mgr->GetResourceManager()->RegisterFont("trebuchet16pt");
    COOPER_FONT_HANDLE = mgr->GetResourceManager()->RegisterFont("cooper_24pt");

    GameManager::SetDebugFont(mgr->GetResourceManager()->GetFont(TREB_FONT_HANDLE));

    Iw2DSetFont(mgr->GetResourceManager()->GetFont(TREB_FONT_HANDLE));

    Sprite *background = new Sprite(mgr);
    background->SetImage(mgr->GetResourceManager()->GetImage(LEAVES_HANDLE));
    background->SetBaseLocation(CIwVec2(0, 0));
    background->SetZIndex(-999);
    mgr->RegisterGameObject(background);

    int width = mgr->GetSurfaceWidth();
    int height = mgr->GetSurfaceHeight();

#define SIMPLE_TEST 0
#define MANY_SHIP_TEST 1
#define ORBITER_TEST 2
#define ANIMATION_TEST 3
#define LABELED_SPRITE 4
#define PATH_TEST 5

    int test_selection = SIMPLE_TEST;

    switch(test_selection)
    {
    case SIMPLE_TEST:
        DoSimpleTest(mgr, ARROW_HANDLE, width, height);
        break;

    case MANY_SHIP_TEST:
        DoManyShipTest(mgr, 10, 10, width, height, ARROW_HANDLE);
        break;

    case ORBITER_TEST:
        MakeOrbiters(mgr, width / 2, height / 2, ARROW_HANDLE);
        break;

    case ANIMATION_TEST:
        AnimationTest(mgr, 0, width, height);
        break;

    case LABELED_SPRITE:
        LabeledSprite(mgr, 0, width, height);
        break;

    case PATH_TEST:
        PathTest(mgr, ARROW_HANDLE, width, height);
        break;
    }

    mgr->MainLoop();

    delete mgr;
}