void renderScene() {



    // Set the colour behind our skybox
    if (disco) {
        // Every 10 ticks
        if (lastTickCount%10==0) glClearColor((float)1000/rand(),(float)1000/rand(),(float)1000/rand(),1.0);
    } else {
        glClearColor(0.0,0.0,0.0,1.0);
    }
    glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
    // Clear framebuffer & depth buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);



    // Reset Modelview matrix
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();


    skybox();
    drawText();

    if (thirdPerson) character();
    keyboardMovement();
    if (intro) {
        drawIntro();
    } else {
        camera();
    }
    drawEnemies();
    if (fire) fireBullets();

    // Draw textured tetrahedron
    glEnable(GL_TEXTURE_2D);
    glColor3f(1.0,1.0,1.0);
    glBindTexture(GL_TEXTURE_2D,textureId);

    // Draw Dungarvan
    glPushMatrix();

    dungarvan->draw();

    glDisable(GL_TEXTURE_2D);
    glPopMatrix();



    // Swap double buffer for flicker-free animation
    glutSwapBuffers();

}
//--------------------------------------------------------------
void testApp::draw(){
    /* //testing the real screen size
    ofSetColor(255, 0, 0);
    ofRect(50, 35, 950, 700);
                      */
    ofPushMatrix();
    ofTranslate(50, 35);
    ofSetColor(0);
    //draw title of upcoming thing for 5 secs
    if (loadingResponseDone) {
        ofEnableAlphaBlending();
        counterDrawInfo++;
        if (counterDrawInfo<FRAME_RATE*1){
            blendInfo+=5;
            ofSetColor(255, 255, 255, blendInfo);
        } else if(counterDrawInfo> FRAME_RATE*(introLength-1)){
            blendInfo-=5;
            ofSetColor(255, 255, 255, blendInfo);
        } else{
            ofSetColor(255, 255, 255, 255);
        }
        drawIntro();
        ofDisableAlphaBlending();
    }
    if (counterDrawInfo>FRAME_RATE*introLength) {
        loading=false;
        loadingResponseDone=false;
        //reset the counters
        counterDrawInfo=0;
        blendInfo=0;
    }
    
    //the actual screens
    if(loading==false){
        if(currentURL==recentPostcards){
            drawPostcards();
        }else if (currentURL==recentLetters){
            drawLetters();
        } else if(currentURL==currentAlphabet){
            drawAlphabet();
        } else if(currentURL==info){
            about.draw();
        }
    }
    ofPopMatrix();
}
//--------------------------------------------------------------
void testApp::draw(){
    ofSetColor(0);
    //draw title of upcoming thing for 5 secs
    if (loadingResponseDone) {
        ofEnableAlphaBlending();
        counterDrawInfo++;
        if (counterDrawInfo<FRAME_RATE*1){
            blendInfo+=5;
            ofSetColor(255, 255, 255, blendInfo);
        } else if(counterDrawInfo> FRAME_RATE*(introLength-1)){
            blendInfo-=5;
            ofSetColor(255, 255, 255, blendInfo);
        } else{
            ofSetColor(255, 255, 255, 255);
        }
        drawIntro();
        ofDisableAlphaBlending();
    }
    if (counterDrawInfo>FRAME_RATE*introLength) {
        loading=false;
        loadingResponseDone=false;
        //reset the counters
        counterDrawInfo=0;
        blendInfo=0;
    }
    
    //the actual screens
    if(loading==false){
        if(currentURL==recentPostcards){
            drawPostcards();
        }else if (currentURL==recentLetters){
            drawLetters();
        } else if(currentURL==currentAlphabet){
            drawAlphabet();
        } else if(currentURL==info){
            about.draw();
        }
    }
    
    //upper and lower bar
    /*ofSetColor(200,200,200);
    ofRect(0, 0, ofGetWidth(), barHeight);
    ofRect(0, ofGetHeight()-barHeight, ofGetWidth(), barHeight);
    ofSetColor(0);*/
}
Exemple #4
0
void		GameEngine::intro()
{
  _context.updateClock(_clock);
  _menuTheme.play();
  _menuTheme.setLoop(true);
  for (int i = 0; i < mode::intro::UNKNOWN; i++)
    {
      _context.updateInputs(_input);
      if (_input.getKey(SDLK_RETURN))
	{
	  usleep(100000);
	  return;
	}
      _intro.setAff(i);
      drawIntro();
      usleep(50000);
    }
}
Exemple #5
0
/**
 * \brief The main game loop. This just cycles endlessly, it uses the game's 'state' to determine which screen to show and what to do.
 */
int main(){
	//looping back and forth forever (cards against humanity reference)
	while(1)
	{
		//some basic prep work performed once before our custom intro
		if(game_state == INTRO)
		{
			initialSetup();
			initIntro();
		}
		//perform custom intro
		while(game_state == INTRO)
		{
			//wait until the next frame
			WaitVsync(1);
			drawIntro();
			processIntro();
		}
		//prep the main menu
		if(game_state == MAIN_MENU)
		{
			FadeOut(0,true);
			ClearVram();
			SetTileTable(title_tiles);
			SetFontTilesIndex(TITLE_TILES_SIZE);
			drawMainMenu();
			FadeIn(0,false);
		}
		//draw menu and handle input
		while(game_state == MAIN_MENU)
		{
			WaitVsync(1);
			drawMenuCursor();
			processMainMenu();
		}
		if(game_state== GAME)
		{
			//run our setup for the main game
			ClearVram();
			FadeOut(0,true);
			gameSetup();
			FadeIn(0,false);
		}
		//when we're in the gameplay portion, draw and accept input for the game
		while(game_state == GAME)
		{
			WaitVsync(1);
			processScrollSpeed(); //scrolls screen as appropriate
			updateCity(); //offsets city for parallax
			processControls(); //accepts and processes controller input
			processPlayerMotion(); //update player position
			processSprites(); //updates and moves player image to player position
		}
		if(game_state == HIGH_SCORES)
		{
			FadeOut(0,true);
			SetTileTable(title_tiles);
			SetFontTilesIndex(TITLE_TILES_SIZE);
			drawLocalHighScoreMenu(); //draw up the high score screen
			FadeIn(0,false);
			deathclock=120; //reset death timer to 2 seconds
			if(score > topscores[9])
			{
			    LoadScore(0, 9); //load top 10 saved high scores
			    SaveScore(score); //save our current score if it's high enough
			    drawLocalHighScoreMenu(); //draw up the high score screen
			}
		}
		//draw and accepts input for the local high score screen
		while(game_state == HIGH_SCORES)
		{
			WaitVsync(1);
			processHighScoreMenu();
		}
    }
}
Exemple #6
0
void OEMFMain :: run(void)
{
	unsigned int menuIndex = 0;
	unsigned int frames = 0;
	unsigned int timepassed;
	
	if (musicPlayer->isPlayingSong())
		musicPlayer->stopSong();
	string songfile = PREPATH "boiling.mp3";
	musicPlayer->playSongAtPath(songfile.c_str());
	
	drawIntro();
	
	SDL_Event event;
	int done = 0;
	while ( !done) {
		timepassed = SDL_GetTicks();
	
		OEMF_LOCKSCREEN;
		clearWithColor(0xFF000000, false);
		OEMF_UNLOCKSCREEN;
		blitImage(images[IMG_INTRO], 0, 0);
		for (unsigned int i = 0; i < m_menuCount; i++)
			fonts[FNT_MENU]->blitText(this, m_menuOptions[i].c_str(), 160, 240 + i * 32, 480, false);
		blitImage(images[IMG_OEMFOE], 128, (unsigned int) (240 + menuIndex * 32 + sin(frames / 2.0) * 8));
		SDL_UpdateRect(m_screen, 128, 232, 512, 248);
		
		/* Check for events */
		while (SDL_PollEvent(&event))
		{
			switch (event.type)
			{
				case SDL_MOUSEMOTION:
					break;
				case SDL_MOUSEBUTTONDOWN:
					break;
				case SDL_KEYDOWN:
					if (event.key.keysym.sym == SDLK_ESCAPE)
					{	
						done = 1;
					} 
					else if (event.key.keysym.sym == SDLK_UP)
					{
						menuIndex = (menuIndex - 1 + m_menuCount) % m_menuCount;
						musicPlayer->playSound(sounds[SND_TOK]);
					}
					else if (event.key.keysym.sym == SDLK_DOWN)
					{
						menuIndex = (menuIndex + 1) % m_menuCount;
						musicPlayer->playSound(sounds[SND_TOK]);
					}
					else if (event.key.keysym.sym == SDLK_p)
					{
						SDL_SaveBMP(m_screen, "screenshot.bmp");
					}
					else if (event.key.keysym.sym == SDLK_RETURN)
					{
						musicPlayer->playSound(sounds[SND_TIK]);
						if (menuIndex == 4)
						{
							fadeOut();
							done = 1;
						}
						else if (menuIndex == 0) // new game
						{
							fadeOut();
							OEMFGame * game = new OEMFGame(m_screen, m_execPath, m_screenWidth, m_screenHeight, m_screenBpp);
							game->run();
							delete game;
							drawIntro();
						}
						else if (menuIndex == 3) // level editor
						{
							fadeOut();
							OEMFLevelEdit * leveledit = new OEMFLevelEdit(m_screen, m_execPath, m_screenWidth, m_screenHeight, m_screenBpp);
							leveledit->run();
							delete leveledit;
							drawIntro();
						}
						else if (menuIndex == 2) // options
						{
							unsigned int choice = 0;
							string * options = new string[2];
							while (choice != 2) // not exit
							{
								if (musicEnabled)
									options[0] = "Turn Music Off";
								else
									options[0] = "Turn Music On";
								options[1] = "Toggle Fullscreen";
								drawIntro();
								choice = chooseList(2 /* exit */, "Options", options, 2);
								if (choice == 0)
								{
									musicEnabled = !musicEnabled;
									if (!musicEnabled)
									{
										if (musicPlayer->isPlayingSong())
											musicPlayer->stopSong();
									}
									else
									{
										musicPlayer->playSongAtPath(songfile.c_str());
									}
								}
								else if (choice == 1)
								{
									if (fullscreenMode)
									{
										m_screen = SDL_SetVideoMode(m_screenWidth, m_screenHeight, m_screenBpp, SDL_SWSURFACE);
										m_fb = (Uint32 *) m_screen->pixels;
										m_pitch = (Uint32) m_screen->pitch / 4;
										fullscreenMode = false;
									}
									else
									{
										m_screen = SDL_SetVideoMode(m_screenWidth, m_screenHeight, m_screenBpp, SDL_SWSURFACE | SDL_FULLSCREEN);
										m_fb = (Uint32 *) m_screen->pixels;
										m_pitch = (Uint32) m_screen->pitch / 4;
										fullscreenMode = true;
									}
									choice = 2;
								}
							}
							drawIntro();
						}
						else
						{
							fadeOut();
							fonts[FNT_MENU]->blitCenterText(this, "NOT AVAILABLE YET", 240, m_screenWidth);
							SDL_UpdateRect(m_screen, 0, 0, m_screenWidth, m_screenHeight);
							SDL_Delay(2000);
							string test = fonts[FNT_MENU]->inputText(this, "default", 32, 32, 10);
							drawIntro();
						}
					}
					break;
				case SDL_QUIT:
					done = 1;
					break;
				default:
					break;
			}
		}
		frames++;
		
		// 30 FPS
		timepassed = SDL_GetTicks() - timepassed;
		if (timepassed <= 33)
			SDL_Delay(33 - timepassed);
	}
}
Exemple #7
0
void Wish::update(){
    NotTooPublic::update();

    if(currentState == STATE_INTRO){
        stateLogicIntro();
    }
    else if(currentState == STATE_BLANK){
        stateLogicBlank();
    }
    else if(currentState == STATE_SPERM) {
        if(currentDistance <= 0.0){
            currentDistance = 0;
            lastStateChangeMillis = nowMillis;
            currentState = STATE_PAUSE;
        }
        else{
            currentDistance -= 1.0;
        }
    }
    else if(currentState == STATE_PAUSE) {
        if(nowMillis - lastStateChangeMillis > 2000){
            currentDistance = 0;
            lastStateChangeMillis = nowMillis;
            currentState = STATE_LINES;
        }
        else{
            //
        }
    }
    else if(currentState == STATE_LINES) {
        if(currentDistance > originalDistance){
            currentDistance = 0;
            lastStateChangeMillis = nowMillis;
            currentState = STATE_CLEAR;
        }
        else{
            currentDistance += 4.0f;
        }
    }
    else if(currentState == STATE_CLEAR) {
        if(currentDistance > originalDistance){
            currentDistance = originalDistance;
            lastStateChangeMillis = nowMillis;
            currentState = STATE_BLANK;
        }
        else{
            currentDistance += 4.0f;
        }
    }
    else if(currentState == STATE_OUTRO){
        stateLogicOutro();
    }

    ///// actual drawings
    if(currentState == STATE_INTRO){
        drawIntro();
    }

    if(currentState == STATE_OUTRO){
        drawCredits();
    }

    if(currentState == STATE_SPERM){
        fboCanvas.begin();
        ofEnableAlphaBlending();
        ofFill();
        // SPERM: ofSetColor(0, 24);
        ofSetColor(0, 64);
        ofRect(0,0, fboCanvas.getWidth(), fboCanvas.getHeight());
        ofPushMatrix();
        ofScale(currentMessageScaling, currentMessageScaling);
        ofTranslate((fboCanvas.getWidth()/currentMessageScaling-myFont.stringWidth(currentMessage))/2,
                    (fboCanvas.getHeight()/currentMessageScaling-myFont.stringHeight(currentMessage))/2+myFont.stringHeight("Tell"));

        ofFill();
        for(int i=0; i<currentMessagePath.size(); i++){
            ofVec3f center = currentMessagePath.at(i).getTessellation().getCentroid();
            for(int j=0; j<currentMessagePath.at(i).getOutline().size(); j++){
                for(int k=0; k<currentMessagePath.at(i).getOutline().at(j).size(); k++){
                    ofPoint tp = currentMessagePath.at(i).getOutline().at(j).getVertices().at(k);
                    ofVec3f direction = (tp-center).normalize();
                    tp += direction*max(0.0f,currentDistance);
                    if(!(k%(int)ceil(currentMessagePoints/1000.0f))){
                        // SPERM: int complexity = 24;
                        int complexity = 4;
                        float magnitude = 8.0f;
                        float dx = ofNoise(complexity*tp.x/fboCanvas.getWidth()+PI,
                                           complexity*tp.y/fboCanvas.getHeight()+PI,
                                           (float)(ofGetFrameNum())/120.0f+PI);
                        float dy = ofNoise(complexity*tp.x/fboCanvas.getWidth()-PI,
                                           complexity*tp.y/fboCanvas.getHeight()-PI,
                                           (float)(ofGetFrameNum())/130.0f-PI);
                        float a = magnitude*ofNoise(dy,dx,(float)(ofGetFrameNum())/100.0f);
                        ofSetColor(255);
                        ofCircle(tp.x-a+2*a*dx, tp.y-a+2*a*dy, 1.0);
                    }
                }
            }
        }
        ofPopMatrix();
        ofDisableAlphaBlending();
        fboCanvas.end();
    }

    if(currentState == STATE_PAUSE){
        fboCanvas.begin();
        ofEnableAlphaBlending();
        ofPushMatrix();
        ofScale(currentMessageScaling, currentMessageScaling);
        ofTranslate((fboCanvas.getWidth()/currentMessageScaling-myFont.stringWidth(currentMessage))/2,
                    (fboCanvas.getHeight()/currentMessageScaling-myFont.stringHeight(currentMessage))/2+myFont.stringHeight("Tell"));

        ofFill();
        ofSetColor(0,8);
        myFont.drawString(currentMessage, 0, 0);

        ofNoFill();
        ofSetColor(255,8);
        ofSetLineWidth(2);
        for(int i=0; i<currentMessagePath.size(); i++){
            ofBeginShape();
            ofVec3f center = currentMessagePath.at(i).getTessellation().getCentroid();
            for(int j=0; j<currentMessagePath.at(i).getOutline().size(); j++){
                ofNextContour();
                for(int k=0; k<currentMessagePath.at(i).getOutline().at(j).size(); k++){
                    ofPoint tp = currentMessagePath.at(i).getOutline().at(j).getVertices().at(k);
                    ofVertex(tp.x, tp.y);
                }
            }
            ofEndShape(true);
        }
        ofPopMatrix();
        ofDisableAlphaBlending();
        fboCanvas.end();
    }

    if(currentState == STATE_LINES){
        fboCanvas.begin();
        ofEnableAlphaBlending();
        ofFill();
        ofSetColor(0, 32);
        ofRect(0,0, fboCanvas.getWidth(), fboCanvas.getHeight());
        ofPushMatrix();
        ofScale(currentMessageScaling, currentMessageScaling);
        ofTranslate((fboCanvas.getWidth()/currentMessageScaling-myFont.stringWidth(currentMessage))/2,
                    (fboCanvas.getHeight()/currentMessageScaling-myFont.stringHeight(currentMessage))/2+myFont.stringHeight("Tell"));

        ofNoFill();
        ofSetLineWidth(1.5);
        for(int i=0; i<currentMessagePath.size(); i++){
            ofVec3f center = currentMessagePath.at(i).getTessellation().getCentroid();
            for(int j=0; j<currentMessagePath.at(i).getOutline().size(); j++){
                for(int k=0; k<currentMessagePath.at(i).getOutline().at(j).size(); k++){
                    ofPoint tp = currentMessagePath.at(i).getOutline().at(j).getVertices().at(k);
                    ofVec3f direction = (tp-center).normalize();
                    tp += direction*max(0.0f,currentDistance);
                    if(!(k%(int)ceil(currentMessagePoints/1000.0f))){
                        ofSetColor(255,128);
                        ofLine(center, tp);
                    }
                }
            }
        }
        ofSetColor(0);
        myFont.drawString(currentMessage, 0, 0);
        ofPopMatrix();
        ofDisableAlphaBlending();
        fboCanvas.end();
    }

    if(currentState == STATE_CLEAR){
        fboCanvas.begin();
        ofEnableAlphaBlending();
        ofFill();
        ofSetColor(0, 32);
        ofRect(0,0, fboCanvas.getWidth(), fboCanvas.getHeight());
        ofPushMatrix();
        ofScale(currentMessageScaling, currentMessageScaling);
        ofTranslate((fboCanvas.getWidth()/currentMessageScaling-myFont.stringWidth(currentMessage))/2,
                    (fboCanvas.getHeight()/currentMessageScaling-myFont.stringHeight(currentMessage))/2+myFont.stringHeight("Tell"));

        ofNoFill();
        ofSetLineWidth(1.5);
        for(int i=0; i<currentMessagePath.size(); i++){
            ofVec3f center = currentMessagePath.at(i).getTessellation().getCentroid();
            for(int j=0; j<currentMessagePath.at(i).getOutline().size(); j++){
                for(int k=0; k<currentMessagePath.at(i).getOutline().at(j).size(); k++){
                    ofPoint tp = currentMessagePath.at(i).getOutline().at(j).getVertices().at(k);
                    ofVec3f direction = (tp-center).normalize();
                    tp += direction*max(0.0f,currentDistance);
                    ofPoint maxDistance = tp+direction*originalDistance;
                    if(!(k%(int)ceil(currentMessagePoints/1000.0f))){
                        ofSetColor(255,128);
                        ofLine(maxDistance, tp);
                    }
                }
            }
        }
        ofSetColor(0);
        myFont.drawString(currentMessage, 0, 0);
        ofPopMatrix();
        ofDisableAlphaBlending();
        fboCanvas.end();
    }
}