// Initialize the GameScene
bool GameScene::init()
{
	CCLog("GameScene::init");
    bool bRet = false;
    do 
    {
        //////////////////////////////////////////////////////////////////////////
        // super init first
        //////////////////////////////////////////////////////////////////////////
        CC_BREAK_IF(! CCLayer::init());

		// Initialize the parent - gets the sprite sheet loaded, sets the background and inits the clouds
		MainScene::init();

		// Start off as game suspended
		gameSuspended = true;

		// Get the bird sprite
		CCSprite *bird = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bird.png"));
		this->addChild(bird, 4, kBird);

		// Initialize the platforms
		initPlatforms();

		// Create the bonus sprite
		CCSprite *bonus;

		// Load in the bonus images, 5, 10, 50, 100
		for(int i=0; i<kNumBonuses; i++) 
		{
			bonus = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(bonus_image[i]));
			this->addChild(bonus,4, kBonusStartTag+i);
			bonus->setVisible(false);
		}

		// Create the Score Label
		CCLabelBMFont* scoreLabel = CCLabelBMFont::create("0",  "Images/bitmapFont.fnt");
		this->addChild(scoreLabel, 5, kScoreLabel);

		// Center the label
		scoreLabel->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width/2,CCDirector::sharedDirector()->getWinSize().height - 50));

		// Start the GameScene stepping
		schedule(schedule_selector(GameScene::step));

		// Enable the touch events
		setTouchEnabled(true);
		// Enable accelerometer events
		setAccelerometerEnabled(true);

		// Start the game
		startGame();

        bRet = true;
    } while (0);

    return bRet;
}
Beispiel #2
0
void initGame(void)
{
	lcdMainOnTop();
	int oldv=getMemFree();
	NOGBA("mem free : %dko (%do)",getMemFree()/1024,getMemFree());
	NOGBA("initializing...");
	videoSetMode(MODE_5_3D | DISPLAY_BG3_ACTIVE);
	videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);
	
	glInit();
	
	vramSetPrimaryBanks(VRAM_A_TEXTURE,VRAM_B_TEXTURE,VRAM_C_LCD,VRAM_D_MAIN_BG_0x06000000);
	vramSetBankH(VRAM_H_SUB_BG);
	vramSetBankI(VRAM_I_SUB_BG_0x06208000);
	
	glEnable(GL_TEXTURE_2D);
	// glEnable(GL_ANTIALIAS);
	glDisable(GL_ANTIALIAS);
	glEnable(GL_BLEND);
	glEnable(GL_OUTLINE);
	
	glSetOutlineColor(0,RGB15(0,0,0)); //TEMP?
	glSetOutlineColor(1,RGB15(0,0,0)); //TEMP?
	glSetOutlineColor(7,RGB15(31,0,0)); //TEMP?
	glSetToonTableRange(0, 15, RGB15(8,8,8)); //TEMP?
	glSetToonTableRange(16, 31, RGB15(24,24,24)); //TEMP?
	
	glClearColor(31,31,0,31);
	glClearPolyID(63);
	glClearDepth(0x7FFF);

	glViewport(0,0,255,191);
	
	// initVramBanks(1);
	initVramBanks(2);
	initTextures();
	initSound();
	
	initCamera(NULL);
	
	initPlayer(NULL);
	
	initLights();
	initParticles();
	
	initMaterials();
	
	loadMaterialSlices("slices.ini");
	loadMaterials("materials.ini");
	loadControlConfiguration("config.ini");
	
	initElevators();
	initWallDoors();
	initTurrets();
	initBigButtons();
	initTimedButtons();
	initEnergyBalls();
	initPlatforms();
	initCubes();
	initEmancipation();
	initDoors();
	initSludge();
	initPause();

	initText();

	NOGBA("lalala");

	getPlayer()->currentRoom=&gameRoom;
	
	currentBuffer=false;
	
	getVramStatus();
	fadeIn();
	
	mainBG=bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0);
	bgSetPriority(mainBG, 0);
	REG_BG0CNT=BG_PRIORITY(3);
	
	#ifdef DEBUG_GAME
		consoleInit(&bottomScreen, 3, BgType_Text4bpp, BgSize_T_256x256, 16, 0, false, true);
		consoleSelect(&bottomScreen);
	#endif
	
	// glSetToonTableRange(0, 14, RGB15(16,16,16));
	// glSetToonTableRange(15, 31, RGB15(26,26,26));
	
	initPortals();
	
	//PHYSICS
	initPI9();

	strcpy(&mapFilePath[strlen(mapFilePath)-3], "map");
	newReadMap(mapFilePath, NULL, 255);
	
	transferRectangles(&gameRoom);
	makeGrid();
	generateRoomGrid(&gameRoom);
	gameRoom.displayList=generateRoomDisplayList(&gameRoom, vect(0,0,0), vect(0,0,0), false);
	
	getVramStatus();
	
	startPI();

	NOGBA("START mem free : %dko (%do)",getMemFree()/1024,getMemFree());
	NOGBA("vs mem free : %dko (%do)",oldv/1024,oldv);

	levelInfoCounter=60;
}
Beispiel #3
0
// Initialize the GameScene
bool GameScene::init()
{
//	CCLog("GameScene::init");
    bool bRet = false;
    do 
    {
        coin50Platform = 12;
        coin100Platform = 15;
        coinJumpPlatform = 25;
        CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic("GameFieldMusic.mp3", true);
        target_Score = 10000;
        //////////////////////////////////////////////////////////////////////////
        // super init first
        //////////////////////////////////////////////////////////////////////////
        CC_BREAK_IF(! CCLayer::init());

		// Initialize the parent - gets the sprite sheet loaded, sets the background and inits the clouds
		MainScene::init();

		// Start off as game suspended
		gameSuspended = true;

		// Get the jumper sprite
		jumper = CCSprite::create("jumper_0.png");
        this->addChild(jumper, 4, kjumper);
        CCArray * animArr = CCArray::create();
        for (int i = 0 ; i < 16; i++)
        {
            CCString * tempString  = CCString::createWithFormat("jumper_%d.png",i);
            CCSpriteFrame * tempFrame = CCSpriteFrame::create(tempString->getCString(),CCRectMake(jumper->getPosition().x, jumper->getPosition().y, jumper->getContentSize().width, jumper->getContentSize().height));
            animArr->addObject(tempFrame);
        }
        CCAnimation * jumpAnimation = CCAnimation::createWithSpriteFrames(animArr,0.1);
        jumpAnimate = CCAnimate::create(jumpAnimation);
        jumpAnimate->retain();

        coin50Anim = CCArray::create();
        coin100Anim = CCArray::create();
        coinJumpAnim = CCArray::create();
        
        CCSprite * coin1  = CCSprite::create("coin_1/coin50_1.png");
        for (int i = 1;i < 20 ; i++)
        {
            CCString * tempString  = CCString::createWithFormat("coin_1/coin50_%d.png",i);
            CCSpriteFrame * tempFrame = CCSpriteFrame::create(tempString->getCString(),CCRectMake(coin1->getPosition().x, coin1->getPosition().y, coin1->getContentSize().width, coin1->getContentSize().height));
            coin50Anim->addObject(tempFrame);
        }
        
        coin50Anim->retain();
        
        CCSprite * coin2  = CCSprite::create("coin_2/coin100_1.png");

        for (int i = 1;i < 20 ; i++)
        {
            CCString * tempString  = CCString::createWithFormat("coin_2/coin100_%d.png",i);
            CCSpriteFrame * tempFrame = CCSpriteFrame::create(tempString->getCString(),CCRectMake(coin2->getPosition().x, coin2->getPosition().y, coin2->getContentSize().width, coin2->getContentSize().height));
            coin100Anim->addObject(tempFrame);
        }
        coin100Anim->retain();
      

        
        
        CCSprite * coin3  = CCSprite::create("powerup/coinJump_1.png");
        for (int i = 1;i < 20 ; i++)
        {
            CCString * tempString  = CCString::createWithFormat("powerup/coinJump_%d.png",i);
            CCSpriteFrame * tempFrame = CCSpriteFrame::create(tempString->getCString(),CCRectMake(coin3->getPosition().x, coin3->getPosition().y, coin3->getContentSize().width, coin3->getContentSize().height));
            coinJumpAnim->addObject(tempFrame);
        }
        coinJumpAnim->retain();
        
        CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage("fx-leafe.png");
        particles = CCParticleFireworks::create();
        particles->setTexture( texture );
        particles->setLife(0.5);
        particles->setEmissionRate(100);
        particles->setPosVar(ccp(10,5));
        particles->setSpeed(60);
        particles->setPosition(0, 0);
        particles->setAngle(90);
        particles->setAngleVar(270);
        particles->setStartSize(10.0);
        particles->setStartSizeVar(5);
        particles->setStartColor( ccc4f(1.0,1.0,1.0,1.0) );
        particles->setEndColor(ccc4f(1.0,1.0,1.0,0.0) );
        particles->setStartSpin(-90);
        particles->setStartSpinVar(30);
        particles->setEndSpin(-90);
        particles->setEndSpinVar(30);
        particles->setSpeedVar(30);
        particles->setPositionType(	kCCPositionTypeGrouped );
        this->addChild(particles, 10);
        particles_counter = 1;
        
		// Initialize the platforms
       
        
        for(int i=0; i<kNumCoines; i++)
		{
            CCSprite *bonus = CCSprite::create("coin_1/coin50_1.png");
            this->addChild(bonus,4, kBonusStartTag+i);
            bonus->setScale(2.0);
            CCAnimation * coin50Animation = CCAnimation::createWithSpriteFrames(coin50Anim,0.03);
            CCAnimate * coin50Animate = CCAnimate::create(coin50Animation);
            
            bonus->runAction(CCRepeatForever::create(coin50Animate));
                bonus->setVisible(false);
            bonus = NULL;
		}
        for(int i=0; i<kNumCoines; i++)
		{
            CCSprite *bonus = CCSprite::create("coin_2/coin100_1.png");
            bonus->setScale(2.0);
            this->addChild(bonus,4, kBonusStartTag+i+30);
            CCAnimation * coin100Animation = CCAnimation::createWithSpriteFrames(coin100Anim,0.03);
             CCAnimate * coin100Animate = CCAnimate::create(coin100Animation);
             bonus->runAction(CCRepeatForever::create(coin100Animate));
            bonus->setVisible(false);
            bonus = NULL;
		}
        for(int i=0; i<kNumCoines; i++)
		{
            CCSprite *bonus = CCSprite::create("powerup/coinJump_1.png");
            this->addChild(bonus,4, kBonusStartTag+i+60);
            bonus->setScale(2.0);
            CCAnimation * coinJumpAnimation = CCAnimation::createWithSpriteFrames(coinJumpAnim,0.03);
            CCAnimate * coinJumpAnimate = CCAnimate::create(coinJumpAnimation);

             bonus->runAction(CCRepeatForever::create(coinJumpAnimate));
            bonus->setVisible(false);
            bonus = NULL;
		}
		initPlatforms();
        initTree();
		// Create the bonus sprite
		

		// Load in the bonus images, 5, 10, 50, 100
		

		// Create the Score Label
		CCLabelTTF* scoreLabel = CCLabelTTF::create("0",  "Arial", 15.0);
		this->addChild(scoreLabel, 5, kScoreLabel);

		// Center the label
		scoreLabel->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width/2,CCDirector::sharedDirector()->getWinSize().height - 50));

		// Start the GameScene stepping
		schedule(schedule_selector(GameScene::step));

		// Enable the touch events
		setTouchEnabled(true);
		// Enable accelerometer events
		setAccelerometerEnabled(true);

		// Start the game
		startGame();

        bRet = true;
    } while (0);

    return bRet;
}