void MyWorld::Init() { World::Init(); TurnsLeft = 10; TurnsLeftChanged = true; Round = 1; RoundChanged = true; // Generate game grid RegenerateGameGrid(); // Create board Actor* board = new Actor(); board->Init(); board->setModel(g_pResources->Board); board->setTouchable(false); AddActor(board); // Create grid of cubes float offs = CUBE_SIZE / 2.0f; int *gg = GameGrid; for (int y = -GameGridHeight / 2; y < GameGridHeight / 2; y++) { for (int x = -GameGridWidth / 2; x < GameGridWidth / 2; x++) { // Create a game object MyActor* actor = new MyActor(); actor->Init(); // Set model and position actor->setModel(g_pResources->Cube); actor->setPosition(x * CUBE_SIZE + offs, CUBE_SIZE / 2.0f + 2.5f, y * CUBE_SIZE + offs); actor->setRotation(((float)*gg) * 90.0f, 90, 0); actor->setCollisionSphereRadius(CUBE_SIZE / 2.5f); actor->setGridPosition(x + GameGridWidth / 2, y + GameGridHeight / 2); actor->setID(0); // Add to world to be processed and rendered AddActor(actor); gg++; } } // Create turns left label text Label* label = new Label(); label->Init(); label->setColour(200, 200, 80, 255); label->setFont(g_pResources->Font); label->setText("TURNS LEFT"); AddActor(label); // Create turns left label to show how many turns are left TurnsLeftLabel = new Label(); TurnsLeftLabel->Init(); TurnsLeftLabel->setPosition(0, 30, 0); TurnsLeftLabel->setFont(g_pResources->Font); AddActor(TurnsLeftLabel); // Create current round label text label = new Label(); label->Init(); label->setColour(200, 200, 80, 255); label->setFont(g_pResources->Font); label->setText("ROUND"); label->setAligment(IW_GX_FONT_ALIGN_RIGHT, IW_GX_FONT_ALIGN_TOP); AddActor(label); // Create turns left label to show how many turns are left RoundLabel = new Label(); RoundLabel->Init(); RoundLabel->setPosition(0, 30, 0); RoundLabel->setAligment(IW_GX_FONT_ALIGN_RIGHT, IW_GX_FONT_ALIGN_TOP); RoundLabel->setFont(g_pResources->Font); AddActor(RoundLabel); // Create game over label text GameOverLabel = new Label(); GameOverLabel->Init(); GameOverLabel->setPosition(0, 0, 0); GameOverLabel->setScale(2.0f); GameOverLabel->setColour(255, 255, 255, 255); GameOverLabel->setAligment(IW_GX_FONT_ALIGN_CENTRE, IW_GX_FONT_ALIGN_MIDDLE); GameOverLabel->setFont(g_pResources->Font); GameOverLabel->setText("GAME OVER"); GameOverLabel->setVisible(false); AddActor(GameOverLabel); }
void MyWorld::Init() { World::Init(); TurnsLeft = 10; TurnsLeftChanged = true; Round = 1; RoundChanged = true; // Generate game grid //RegenerateGameGrid(); // Create board Actor* board = new Actor(); board->Init(); board->setModel(g_pResources->Board); board->setTouchable(false); board->setPosition(0, -10.f, 0); AddActor(board); // Create grid of cubes const float offs = CUBE_SIZE / 2.0f; for (int i = 0; i < MAX_CUSTOMERS; ++i) { // Create a game object MyActor* actor = new MyActor(); actor->Init(); // Set model and position actor->setModel(g_pResources->Cube); actor->setRotation(((float)(rand() % 4)) * 90.0f, 90, 0); actor->setCollisionSphereRadius(offs * 1.5f); actor->setID(0); actor->setVisible(false); actor->setPosition(0.f, 0.f, 90.f); // Add to world to be processed and rendered AddActor(actor); } for (int i = 0; i < 4; ++ i) { CustomerStore* actor = new CustomerStore(); actor->Init(); // Set model and position actor->setModel(g_pResources->Cube); actor->setRotation(((float)(i)) * 90.0f, 90, 0); actor->setScale(1.75f); actor->setPosition(-45.f + (i * CUBE_SIZE * actor->getScale() * 1.8f), 0.f, -40.f); actor->setCollisionSphereRadius(offs * actor->getScale() * 1.5f); actor->setID(0); // Add to world to be processed and rendered AddActor(actor); } SpawnCustomer(); // Create turns left label text Label* label = new Label(); label->Init(); label->setColour(200, 200, 80, 255); label->setFont(g_pResources->Font); label->setText("SCORE:"); AddActor(label); // Create turns left label to show how many turns are left TurnsLeftLabel = new Label(); TurnsLeftLabel->Init(); TurnsLeftLabel->setPosition(0, 30, 0); TurnsLeftLabel->setFont(g_pResources->Font); AddActor(TurnsLeftLabel); // Create current round label text label = new Label(); label->Init(); label->setColour(200, 200, 80, 255); label->setFont(g_pResources->Font); label->setText("ROUND"); label->setAligment(IW_GX_FONT_ALIGN_RIGHT, IW_GX_FONT_ALIGN_TOP); AddActor(label); // Create turns left label to show how many turns are left RoundLabel = new Label(); RoundLabel->Init(); RoundLabel->setPosition(0, 30, 0); RoundLabel->setAligment(IW_GX_FONT_ALIGN_RIGHT, IW_GX_FONT_ALIGN_TOP); RoundLabel->setFont(g_pResources->Font); AddActor(RoundLabel); // Create game over label text GameOverLabel = new Label(); GameOverLabel->Init(); GameOverLabel->setPosition(0, 0, 0); GameOverLabel->setScale(2.0f); GameOverLabel->setColour(255, 255, 255, 255); GameOverLabel->setAligment(IW_GX_FONT_ALIGN_CENTRE, IW_GX_FONT_ALIGN_MIDDLE); GameOverLabel->setFont(g_pResources->Font); GameOverLabel->setText("GAME OVER"); GameOverLabel->setVisible(false); AddActor(GameOverLabel); }