コード例 #1
0
void TheGooniesApp::titleanimation_draw(void)
{
    glClearColor(0, 0, 0, 1);
    glClear(GL_COLOR_BUFFER_BIT);

	m_titleanimation_shift -= m_titleanimation_speed;
	m_titleanimation_shift += 40;
	m_titleanimation_shift = (m_titleanimation_shift%40)-40;
	if ((m_state_cycle%8)==0) {
		if (m_titleanimation_state==0 || m_titleanimation_state==1) {
			if (m_titleanimation_speed<4) m_titleanimation_speed++;
		} else {
			if (m_titleanimation_speed>0) m_titleanimation_speed--;
		}
	} 

    m_GLTM->get
    ("bg_copyright")->draw(0, 0, 0, 0, 1);
    m_GLTM->get_smooth("title_logo")->draw(46, 17, 0, 0, 1);

    switch (m_titleanimation_state) {
        case 0: {
                float f = float(m_state_cycle) / 50;

                glColor4f(0, 0, 0, f);
#ifndef HAVE_GLES
                glBegin(GL_QUADS);
                glVertex3f(0, 256, 0);
                glVertex3f(0, 400, 0);
                glVertex3f(640, 400, 0);
                glVertex3f(640, 256, 0);
                glEnd();
#else
		GLfloat vtx1[] = {
		0, 256, 0,
		0, 400, 0,
		640, 400, 0,
		640, 256, 0
		};

      glEnableClientState(GL_VERTEX_ARRAY);
 
      glVertexPointer(3, GL_FLOAT, 0, vtx1);
      glDrawArrays(GL_TRIANGLE_FAN,0,4);
 
      glDisableClientState(GL_VERTEX_ARRAY);
#endif

				// film strip
				{
					GLTile *strip = m_GLTM->get("intro-film-strip");
					for (int x = m_titleanimation_shift; x < 640; x+= 40)
					{
						strip->draw(1, 1, 1, f, float(x), 236, 0, 0, 1);
						strip->draw(1, 1, 1, f, float(x), 400, 0, 0, 1);
					}
				}
            }
            break;
        case 1:
        case 2: {
                float f = 1;
                bool scissor_state = (glIsEnabled(GL_SCISSOR_TEST) ? true : false);
                int scissor_window[4];

                if (m_titleanimation_state == 1)
                    f = 1;
                if (m_titleanimation_state == 2)
                    f = float(50 - m_state_cycle) / 50;
                glEnable(GL_SCISSOR_TEST);
                if (scissor_state)
                    glGetIntegerv(GL_SCISSOR_BOX, scissor_window);
                glScissor(screen_x(0), screen_y(60), screen_x(640), screen_y(184));

                glColor4f(0, 0, 0, f);
#ifndef HAVE_GLES
                glBegin(GL_QUADS);
                glVertex3f(0, 0, 0);
                glVertex3f(0, 480, 0);
                glVertex3f(640, 480, 0);
                glVertex3f(640, 0, 0);
                glEnd();
#else
		GLfloat vtx2[] = {
		0, 0, 0,
		0, 480, 0,
		640, 480, 0,
		640, 0, 0
		};

      glEnableClientState(GL_VERTEX_ARRAY);
 
      glVertexPointer(3, GL_FLOAT, 0, vtx2);
      glDrawArrays(GL_TRIANGLE_FAN,0,4);
 
      glDisableClientState(GL_VERTEX_ARRAY);
#endif

				// film strip
				{
//					int shift = -(m_titleanimation_cycle % 20) * 2;
					GLTile *strip = m_GLTM->get("intro-film-strip");
					for (int x = m_titleanimation_shift; x < 640; x+= 40)
					{
						strip->draw(1, 1, 1, f, float(x), 236, 0, 0, 1);
						strip->draw(1, 1, 1, f, float(x), 400, 0, 0, 1);
					}
				}

                // character:
                if (m_titleanimation_cycle > 50 &&
                        m_titleanimation_cycle <= 300) {
                    // running right:
                    int sp = (m_titleanimation_cycle / 8) % 4;
                    if (sp == 0)
                        m_GLTM->get
                        ("intro-character-r1")->draw(1, 1, 1, f, 512 - (300 - m_titleanimation_cycle)*2.5f, 296, 0, 0, 1);
                    if (sp == 1)
                        m_GLTM->get
                        ("intro-character-r2")->draw(1, 1, 1, f, 512 - (300 - m_titleanimation_cycle)*2.5f, 296, 0, 0, 1);
                    if (sp == 2)
                        m_GLTM->get
                        ("intro-character-r1")->draw(1, 1, 1, f, 512 - (300 - m_titleanimation_cycle)*2.5f, 296, 0, 0, 1);
                    if (sp == 3)
                        m_GLTM->get
                        ("intro-character-r3")->draw(1, 1, 1, f, 512 - (300 - m_titleanimation_cycle)*2.5f, 296, 0, 0, 1);
                } // if
				if (m_titleanimation_cycle > 300 &&
						m_titleanimation_cycle <= 312) {
					// turning:
					int sp = (m_titleanimation_cycle - 301) / 4;
					if (sp == 0)
						m_GLTM->get ("intro-character-turning_rl_1")->draw(1, 1, 1, f, 512, 296, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get ("intro-character-turning_rl_2")->draw(1, 1, 1, f, 512, 296, 0, 0, 1);
					if (sp == 2)
						m_GLTM->get ("intro-character-turning_rl_3")->draw(1, 1, 1, f, 512, 296, 0, 0, 1);
				}
                if (m_titleanimation_cycle > 312 &&
                        m_titleanimation_cycle <= 1500) {
                    // standing left:
					int sp = (m_titleanimation_cycle / 8) % 4;
					if (sp == 0)
						m_GLTM->get
						("intro-character-standing-l1")->draw(1, 1, 1, f, 512, 296, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get
						("intro-character-standing-l2")->draw(1, 1, 1, f, 512, 296, 0, 0, 1);
					if (sp == 2)
						m_GLTM->get
						("intro-character-standing-l3")->draw(1, 1, 1, f, 512, 296, 0, 0, 1);
					if (sp == 3)
						m_GLTM->get
						("intro-character-standing-l2")->draw(1, 1, 1, f, 512, 296, 0, 0, 1);
                } // if
                if (m_titleanimation_cycle > 1500 &&
                        m_titleanimation_cycle <= 1850) {
                    int sp = (m_titleanimation_cycle / 8) % 2;
					int s2 = (m_titleanimation_cycle / 5) % 3;
                    // knocked:
					if (s2 == 0) m_GLTM->get("intro-character-stars1")->draw(1, 1, 1, f, 532, 334, 0, 0, 1);
					if (s2 == 1) m_GLTM->get("intro-character-stars2")->draw(1, 1, 1, f, 532, 334, 0, 0, 1);
					if (s2 == 2) m_GLTM->get("intro-character-stars3")->draw(1, 1, 1, f, 532, 334, 0, 0, 1);

                    if (sp == 0)
                        m_GLTM->get
                        ("intro-character-knocked1")->draw(1, 1, 1, f, 512, 296, 0, 0, 1);
                    if (sp == 1)
                        m_GLTM->get
                        ("intro-character-knocked2")->draw(1, 1, 1, f, 512, 296, 0, 0, 1);

                } // if
                if (m_titleanimation_cycle > 1850 &&
                        m_titleanimation_cycle <= 1900) {
                    // standing left:
					int sp = (m_titleanimation_cycle / 8) % 4;
					if (sp == 0)
						m_GLTM->get
						("intro-character-standing-l1")->draw(1, 1, 1, f, 512, 296, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get
						("intro-character-standing-l2")->draw(1, 1, 1, f, 512, 296, 0, 0, 1);
					if (sp == 2)
						m_GLTM->get
						("intro-character-standing-l3")->draw(1, 1, 1, f, 512, 296, 0, 0, 1);
					if (sp == 3)
						m_GLTM->get
						("intro-character-standing-l2")->draw(1, 1, 1, f, 512, 296, 0, 0, 1);
                } // if
                if (m_titleanimation_cycle > 1900 &&
                        m_titleanimation_cycle <= 2200) {
                    // running right:
                    int sp = (m_titleanimation_cycle / 8) % 4;
                    if (sp == 0)
                        m_GLTM->get
                        ("intro-character-l1")->draw(1, 1, 1, f, 512 - (m_titleanimation_cycle - 1900)*2.5f, 296, 0, 0, 1);
                    if (sp == 1)
                        m_GLTM->get
                        ("intro-character-l2")->draw(1, 1, 1, f, 512 - (m_titleanimation_cycle - 1900)*2.5f, 296, 0, 0, 1);
                    if (sp == 2)
                        m_GLTM->get
                        ("intro-character-l1")->draw(1, 1, 1, f, 512 - (m_titleanimation_cycle - 1900)*2.5f, 296, 0, 0, 1);
                    if (sp == 3)
                        m_GLTM->get
                        ("intro-character-l3")->draw(1, 1, 1, f, 512 - (m_titleanimation_cycle - 1900)*2.5f, 296, 0, 0, 1);
                } // if

                // Mike
				if (m_titleanimation_cycle > 300 + 0*150 &&
						m_titleanimation_cycle <= 500 + 0*150) {
					// running right:
					int sp = (m_titleanimation_cycle / 8) % 4;
					if (sp == 0)
						m_GLTM->get
							("intro-mike-r1")->draw(1, 1, 1, f, (464 - 0*60) - (500 + 0*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get
							("intro-mike-r2")->draw(1, 1, 1, f, (464 - 0*60) - (500 + 0*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 2)
						m_GLTM->get
							("intro-mike-r3")->draw(1, 1, 1, f, (464 - 0*60) - (500 + 0*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 3)
						m_GLTM->get
							("intro-mike-r2")->draw(1, 1, 1, f, (464 - 0*60) - (500 + 0*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
				}
				if (m_titleanimation_cycle > 500 + 0*150 &&
						m_titleanimation_cycle <= 1624 + 0*24) {
					// standing:
					int sp = (m_titleanimation_cycle / 16) % 2;
					if (sp == 0)
						m_GLTM->get
							("intro-mike-standing1")->draw(1, 1, 1, f, float(464 - 0*60), 312, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get
							("intro-mike-standing2")->draw(1, 1, 1, f, float(464 - 0*60), 312, 0, 0, 1);
				}

				// Mouth
				if (m_titleanimation_cycle > 300 + 1*150 &&
						m_titleanimation_cycle <= 500 + 1*150) {
					// running right:
					int sp = (m_titleanimation_cycle / 8) % 4;
					if (sp == 0)
						m_GLTM->get
							("intro-mouth-r1")->draw(1, 1, 1, f, (464 - 1*60) - (500 + 1*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get
							("intro-mouth-r2")->draw(1, 1, 1, f, (464 - 1*60) - (500 + 1*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 2)
						m_GLTM->get
							("intro-mouth-r3")->draw(1, 1, 1, f, (464 - 1*60) - (500 + 1*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 3)
						m_GLTM->get
							("intro-mouth-r2")->draw(1, 1, 1, f, (464 - 1*60) - (500 + 1*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
				}
				if (m_titleanimation_cycle > 500 + 1*150 &&
						m_titleanimation_cycle <= 1624 + 1*24) {
					// standing:
					int sp = (m_titleanimation_cycle / 16) % 2;
					if (sp == 0)
						m_GLTM->get
							("intro-mouth-standing1")->draw(1, 1, 1, f, float(464 - 1*60), 312, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get
							("intro-mouth-standing2")->draw(1, 1, 1, f, float(464 - 1*60), 312, 0, 0, 1);
				}

				//
				// Data
				//
				//		Added some variables to look for best values in the rope effect. Enjoy ^o^.
				//		Should be replaced by constants or something once we feel happy with the values.
				//		Ps: yes, I know Bresenham's algorithm to draw lines. But mee too lazy, too tired, too late :-).
				//
				float wave_amplitude = 1.0;		// Wave amplitude when launching the rope
				float wave_lenght = 120.0;		// Wave lenght when launching the rope
				int rope_cycles = 100;			// Cycles to reach the other side of the screen
				float rope_y = 260;				// Y coordinate for the left side of the rope
				float rope_y_delta = 10;		// Hight delta between left and right sides
				float data_weight = 10;			// "weight" of Data using the rope
				float data_shift = -30;			// Data shift to adjust Data graphic to the rope :-P

				int rope_start_cycle = 500 + 1*150 - rope_cycles;
				GLTile *rope = m_GLTM->get("intro-data-rope");

				// Throwing rope
				if (m_titleanimation_cycle > rope_start_cycle &&
						m_titleanimation_cycle <= rope_start_cycle + rope_cycles) {
					int fragments = (m_titleanimation_cycle - rope_start_cycle)*64 / rope_cycles;
					for (int i = 0; i < fragments; ++i)
						rope->draw(1, 1, 1, f, float(i * 10), float(rope_y + i*10*rope_y_delta/640 + wave_amplitude * sin(i*10 * 2*M_PI/wave_lenght)), 0, 0, 1);
				}

				// Data descending
				if (m_titleanimation_cycle > 300 + 2*150 &&
						m_titleanimation_cycle <= 500 + 2*150) {
					float x = (464 - 2*60) - (500 + 2*150 - m_titleanimation_cycle)*2.5f;
					float y = rope_y + data_weight + x*rope_y_delta/640.0f;

					// The Rope
					if (x >= 0 && x < 640) {
						int i;
						float fst_y_delta = data_weight + x*rope_y_delta/640;
						float snd_y_delta = rope_y_delta - fst_y_delta;

						for (i = 0; i < x; i+=10)
							rope->draw(1, 1, 1, f, float(i), rope_y + (i)*fst_y_delta/x, 0, 0, 1);

						for (i = 0; i < (640 - x); i+=10)
							rope->draw(1, 1, 1, f, float(i+x), rope_y + fst_y_delta + (i)*snd_y_delta/(640-x), 0, 0, 1);
					}
					else if (m_titleanimation_cycle > rope_start_cycle + rope_cycles) {
						int i;
						for (i = 0; i < 640; i+=10)
							rope->draw(1, 1, 1, f, float(i), rope_y + i*rope_y_delta/640, 0, 0, 1);
					}

					// The kiddo
					int sp = (m_titleanimation_cycle / 8) % 4;
					if (sp == 0)
						m_GLTM->get
							("intro-data-hang1")->draw(1, 1, 1, f, x+data_shift, y, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get
							("intro-data-hang2")->draw(1, 1, 1, f, x+data_shift, y, 0, 0, 1);
					if (sp == 2)
						m_GLTM->get
							("intro-data-hang3")->draw(1, 1, 1, f, x+data_shift, y, 0, 0, 1);
					if (sp == 3)
						m_GLTM->get
							("intro-data-hang2")->draw(1, 1, 1, f, x+data_shift, y, 0, 0, 1);
				}
				else if (m_titleanimation_cycle > rope_start_cycle + rope_cycles) {
					// Rope dissapearing
					float rf;
					if (m_titleanimation_cycle < 900)
						rf = 1.0;
					else if (m_titleanimation_cycle > 1000)
						rf = 0.0;
					else
						rf = (1000 - m_titleanimation_cycle) / 100.0f;

					for (int i = 0; i < 640; i+=10)
						rope->draw(1, 1, 1, rf, float(i), rope_y + i*rope_y_delta/640, 0, 0, 1);
				}

				if (m_titleanimation_cycle > 500 + 2*150 &&
						m_titleanimation_cycle <= 1624 + 2*24) {
					// standing:
					int sp = (m_titleanimation_cycle / 16) % 2;
					if (sp == 0)
						m_GLTM->get
							("intro-data-standing1")->draw(1, 1, 1, f, float(464 - 2*60), 312, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get
							("intro-data-standing2")->draw(1, 1, 1, f, float(464 - 2*60), 312, 0, 0, 1);
				}

				// Chunk
				if (m_titleanimation_cycle > 300 + 3*150 &&
						m_titleanimation_cycle <= 500 + 3*150) {
					// running right:
					int sp = (m_titleanimation_cycle / 8) % 4;
					if (sp == 0)
						m_GLTM->get
							("intro-chunk-r1")->draw(1, 1, 1, f, (464 - 3*60) - (500 + 3*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get
							("intro-chunk-r2")->draw(1, 1, 1, f, (464 - 3*60) - (500 + 3*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 2)
						m_GLTM->get
							("intro-chunk-r3")->draw(1, 1, 1, f, (464 - 3*60) - (500 + 3*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 3)
						m_GLTM->get
							("intro-chunk-r2")->draw(1, 1, 1, f, (464 - 3*60) - (500 + 3*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
				}
				if (m_titleanimation_cycle > 500 + 3*150 &&
						m_titleanimation_cycle <= 1624 + 3*24) {
					// standing:
					int sp = (m_titleanimation_cycle / 16) % 2;
					if (sp == 0)
						m_GLTM->get
							("intro-chunk-standing1")->draw(1, 1, 1, f, float(464 - 3*60), 312, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get
							("intro-chunk-standing2")->draw(1, 1, 1, f, float(464 - 3*60), 312, 0, 0, 1);
				}

				// Brand
				if (m_titleanimation_cycle > 300 + 4*150 &&
						m_titleanimation_cycle <= 500 + 4*150) {
					// running right:
					int sp = (m_titleanimation_cycle / 8) % 4;
					if (sp == 0)
						m_GLTM->get
							("intro-brand-r1")->draw(1, 1, 1, f, (464 - 4*60) - (500 + 4*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get
							("intro-brand-r2")->draw(1, 1, 1, f, (464 - 4*60) - (500 + 4*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 2)
						m_GLTM->get
							("intro-brand-r3")->draw(1, 1, 1, f, (464 - 4*60) - (500 + 4*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 3)
						m_GLTM->get
							("intro-brand-r2")->draw(1, 1, 1, f, (464 - 4*60) - (500 + 4*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
				}
				if (m_titleanimation_cycle > 500 + 4*150 &&
						m_titleanimation_cycle <= 1624 + 4*24) {
					// standing:
					int sp = (m_titleanimation_cycle / 16) % 2;
					if (sp == 0)
						m_GLTM->get
							("intro-brand-standing1")->draw(1, 1, 1, f, float(464 - 4*60), 312, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get
							("intro-brand-standing2")->draw(1, 1, 1, f, float(464 - 4*60), 312, 0, 0, 1);
				}

				// Andy
				if (m_titleanimation_cycle > 300 + 5*150 &&
						m_titleanimation_cycle <= 500 + 5*150) {
					// running right:
					int sp = (m_titleanimation_cycle / 8) % 4;
					if (sp == 0)
						m_GLTM->get
							("intro-andy-r1")->draw(1, 1, 1, f, (464 - 5*60) - (500 + 5*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get
							("intro-andy-r2")->draw(1, 1, 1, f, (464 - 5*60) - (500 + 5*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 2)
						m_GLTM->get
							("intro-andy-r3")->draw(1, 1, 1, f, (464 - 5*60) - (500 + 5*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 3)
						m_GLTM->get
							("intro-andy-r2")->draw(1, 1, 1, f, (464 - 5*60) - (500 + 5*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
				}
				if (m_titleanimation_cycle > 500 + 5*150 &&
						m_titleanimation_cycle <= 1624 + 5*24) {
					// standing:
					int sp = (m_titleanimation_cycle / 16) % 2;
					if (sp == 0)
						m_GLTM->get
							("intro-andy-standing1")->draw(1, 1, 1, f, float(464 - 5*60), 312, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get
							("intro-andy-standing2")->draw(1, 1, 1, f, float(464 - 5*60), 312, 0, 0, 1);
				}

				// Steff
				if (m_titleanimation_cycle > 300 + 6*150 &&
						m_titleanimation_cycle <= 500 + 6*150) {
					// running right:
					int sp = (m_titleanimation_cycle / 8) % 4;
					if (sp == 0)
						m_GLTM->get
							("intro-steff-r1")->draw(1, 1, 1, f, (464 - 6*60) - (500 + 6*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get
							("intro-steff-r2")->draw(1, 1, 1, f, (464 - 6*60) - (500 + 6*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 2)
						m_GLTM->get
							("intro-steff-r3")->draw(1, 1, 1, f, (464 - 6*60) - (500 + 6*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
					if (sp == 3)
						m_GLTM->get
							("intro-steff-r2")->draw(1, 1, 1, f, (464 - 6*60) - (500 + 6*150 - m_titleanimation_cycle)*2.5f, 312, 0, 0, 1);
				}
				if (m_titleanimation_cycle > 500 + 6*150 &&
						m_titleanimation_cycle <= 1624 + 6*24) {
					// standing:
					int sp = (m_titleanimation_cycle / 16) % 2;
					if (sp == 0)
						m_GLTM->get
							("intro-steff-standing1")->draw(1, 1, 1, f, float(464 - 6*60), 312, 0, 0, 1);
					if (sp == 1)
						m_GLTM->get
							("intro-steff-standing2")->draw(1, 1, 1, f, float(464 - 6*60), 312, 0, 0, 1);
				}

                // Fratelli:
                if (m_titleanimation_cycle > 1400 &&
                        m_titleanimation_cycle <= 1500) {
                    // wlking left:
                    int sp = (m_titleanimation_cycle / 8) % 2;
                    if (sp == 0)
                        m_GLTM->get
                        ("intro-fratelli-l1")->draw(1, 1, 1, f, 544 + (1500 - m_titleanimation_cycle)*2.5f, 296, 0, 0, 1);
                    if (sp == 1)
                        m_GLTM->get
                        ("intro-fratelli-l2")->draw(1, 1, 1, f, 544 + (1500 - m_titleanimation_cycle)*2.5f, 296, 0, 0, 1);
                } // if
                if (m_titleanimation_cycle > 1500 &&
                        m_titleanimation_cycle <= 1600) {
                    // standing left:
                    m_GLTM->get
                    ("intro-fratelli-l1")->draw(1, 1, 1, f, 544, 296, 0, 0, 1);
                } // if
                if (m_titleanimation_cycle > 1600 &&
                        m_titleanimation_cycle <= 1780) {
                    // wlking left:
                    int sp = (m_titleanimation_cycle / 8) % 2;
                    if (sp == 0)
                        m_GLTM->get
                        ("intro-fratelli-l1")->draw(1, 1, 1, f, 544 - (m_titleanimation_cycle - 1600)*2.5f, 296, 0, 0, 1);
                    if (sp == 1)
                        m_GLTM->get
                        ("intro-fratelli-l2")->draw(1, 1, 1, f, 544 - (m_titleanimation_cycle - 1600)*2.5f, 296, 0, 0, 1);
                } // if
                if (m_titleanimation_cycle > 1780 &&
                        m_titleanimation_cycle <= 1900) {
                    // laughting:
                    int sp = (m_titleanimation_cycle / 8) % 2;
                    if (sp == 0) m_GLTM->get("intro-fratelli-laught-r1")->draw(1, 1, 1, f, 94, 296, 0, 0, 1);
                    if (sp == 1) m_GLTM->get("intro-fratelli-laught-r2")->draw(1, 1, 1, f, 94, 296, 0, 0, 1);
                } // if
                if (m_titleanimation_cycle > 1900 &&
                        m_titleanimation_cycle <= 2000) {
                    // wlking left:
                    int sp = (m_titleanimation_cycle / 8) % 2;
                    if (sp == 0)
                        m_GLTM->get
                        ("intro-fratelli-l1")->draw(1, 1, 1, f, 94 - (m_titleanimation_cycle - 1900)*2.5f, 296, 0, 0, 1);
                    if (sp == 1)
                        m_GLTM->get
                        ("intro-fratelli-l2")->draw(1, 1, 1, f, 94 - (m_titleanimation_cycle - 1900)*2.5f, 296, 0, 0, 1);
                } // if

                if (!scissor_state)
                    glDisable(GL_SCISSOR_TEST);
                if (scissor_state)
                    glScissor(scissor_window[0], scissor_window[1], scissor_window[2], scissor_window[3]);

            }
            break;
    } // switch

} /* TheGooniesApp::titleanimation_draw */
コード例 #2
0
void TGLapp::levelpackscreen_draw(void)
{
	char buffer[256];
	float replay_full_factor=0;

	glClearColor(0,0,0,1);
    glClear(GL_COLOR_BUFFER_BIT);

	TGLinterface::draw();

	// Draw scores:
	sprintf(buffer,"Total Points: %i",m_player_profile->get_points());
	TGLinterface::print_left(buffer,m_font16,230,40);
	sprintf(buffer,"Level Pack Points: %i",m_player_profile->get_points(m_current_levelpack->m_id));
	TGLinterface::print_left(buffer,m_font16,230,60);

	
	// Draw Selected ship:
	{
		int i,s;
		GLTile *t;

		for(i=-1;i<2;i++) {
			s= indexOf<int>(m_player_profile->m_ships, m_selected_ship)+i;
			if (s>=0 && s<m_player_profile->m_ships.size()) {
				t=m_GLTM->get(TGL::ship_tiles[getAt<int>(m_player_profile->m_ships, s)]);

				if (i==0) {
					t->draw(495,160,0,0,1);
				} else {
					t->draw(1,1,1,0.33f,float(495+i*48),160,0,0,0.66f);
				} // if 

			} // if
		} // for

		TGLinterface::print_center(TGL::ship_names[m_selected_ship],m_font32,495,220);
	}

	switch(m_lp_replay_mode) {
	case 0:
			replay_full_factor=0;
			break;
	case 1:
			{
				float f=0;
				f=abs(m_lp_replay_timmer)/25.0F;
				fade_in_alpha(f);
				replay_full_factor=f;
			}
			break;
	case 2: fade_in_alpha(1);
			replay_full_factor=1;
			break;
	case 3:
			{
				float f=0;
				f=abs(25-m_lp_replay_timmer)/25.0F;
				fade_in_alpha(f);
				replay_full_factor=f;
			}
			break;
	} // switch

	// Draw tutorial:
	{
		if (m_lp_tutorial_game!=0) {
			int old[4];

			glGetIntegerv(GL_VIEWPORT,old);
			glViewport(int(380*(1-replay_full_factor)),int(80*(1-replay_full_factor)), 
					   int(SCREEN_X*replay_full_factor+230*(1-replay_full_factor)),int(SCREEN_Y*replay_full_factor+172*(1-replay_full_factor)));
            glScissor(int(380*(1-replay_full_factor)),int(80*(1-replay_full_factor)),
                      int(SCREEN_X*replay_full_factor+230*(1-replay_full_factor)),int(SCREEN_Y*replay_full_factor+172*(1-replay_full_factor)));
            glEnable(GL_SCISSOR_TEST);
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
			m_lp_tutorial_game->draw(1.0, m_GLTM);
            glDisable(GL_SCISSOR_TEST);
			glViewport(old[0],old[1],old[2],old[3]);
            
			{
				float f=0.6f+0.4f*float(sin(m_state_cycle*0.1));

				if (m_lp_replay_mode==0 || m_lp_replay_mode==1) TGLinterface::print_center("Press F to maximize",m_font16,320*replay_full_factor+495*(1-replay_full_factor),20*replay_full_factor+250*(1-replay_full_factor),1,1,1,f);
				if (m_lp_replay_mode==2 || m_lp_replay_mode==3) TGLinterface::print_center("Press F to minimize",m_font16,320*replay_full_factor+495*(1-replay_full_factor),20*replay_full_factor+250*(1-replay_full_factor),1,1,1,f);
			}

			{
				int i,j;
				float y;
				char buffer[128];
				char *tmp=0;

				/* Text messages in replays */ 
				{
                    for(TextNode *n:m_lp_tutorial_replay_text) {
						if (n->m_time<m_lp_tutorial_game->get_cycle()) tmp = n->m_text;
					} // while 
				}

				if (tmp!=0) {
					i=0;
					y=445*replay_full_factor+425*(1-replay_full_factor);
					while(tmp[i]!=0) {
						for(j=0;tmp[i]!=0 && tmp[i]!='/';i++,j++) buffer[j]=tmp[i];
						buffer[j]=0;
						if (tmp[i]=='/') i++;
						TGLinterface::print_center(buffer,m_font16,320*replay_full_factor+495*(1-replay_full_factor),y);
						y+=20;
					} // while

				} // if 
			} 
		} else {
			TGLinterface::print_center("No tutorial available",m_font16,320*replay_full_factor+495*(1-replay_full_factor),240*replay_full_factor+300*(1-replay_full_factor));
		} // if 
	} 

	switch(m_state_fading) {
	case 0:	
			{
				float f=0;
				f=abs(int(25-m_state_fading_cycle))/25.0F;

				fade_in_alpha(f);
			}
			break;
	case 1:
			break;
	case 2:
			{
				float f=0;
				f=abs(int(m_state_fading_cycle))/25.0F;

				fade_in_alpha(f);
			}
			break;
	} // switch
} /* TGLapp::levelpackscreen_draw */ 
コード例 #3
0
void F1SpiritApp::gameoptions_draw(void)
{
	GLTile *menu;
	SDL_Surface *sfc1 = 0, *sfc2 = 0;
	int w1, w2, wt;
	float sel_factor, enter_factor = 1.0F;
	int menu_y = 160;

	glClearColor(1, 1, 1, 1);
	glClear(GL_COLOR_BUFFER_BIT);

	if (menu_state < MENU_CONSTANT)
		enter_factor = menu_state / float(MENU_CONSTANT);

	if (menu_state == MENU_CONSTANT)
		enter_factor = 1.0F;

	if (menu_state > MENU_CONSTANT)
		enter_factor = ((MENU_CONSTANT * 2) - menu_state) / float(MENU_CONSTANT);

	race_game->draw(true);

	{
		if (menu_fading != 0) {
			float f = 0;
			f = abs(menu_fading_ctnt) / float(MENU_CONSTANT);
			glColor4f(0, 0, 0, (1 - f) / 2);
		} else {
			glColor4f(0, 0, 0, 0.5F);
		} 

		glNormal3f(0.0, 0.0, 1.0);

		{
			GLfloat vtx[] = {MINX, MINY, -4, 
							 MINX, MAXY, -4, 
							 MAXX, MAXY, -4,
							 MAXX, MINY, -4 };
			glEnableClientState(GL_VERTEX_ARRAY);
			glVertexPointer(3, GL_FLOAT, 0, vtx);
			glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
			glDisableClientState(GL_VERTEX_ARRAY);
		}
	}


	if (menu_options[0] != 0) {
		sel_factor = float(0.6F - 0.4F * sin(menu_selected_timmer[0] / 10.0F));

		if (menu_prev_nmenus == 2 &&
		        (menu_current_menu != 3 || menu_selected[1] != 0)
		        && menu_current_menu != 4) {
			sfc1 = draw_menu(11, menu_title[0], menu_options[0], menu_option_type[0], menu_selected[0], sel_factor, 1, font, &(menu_first_option[0]));
		} else {
			if ((menu_option_type[0][menu_selected[0]] == 11 && menu_state > MENU_CONSTANT) ||
			        (menu_state < MENU_CONSTANT && menu_options[1] != 0)) {
				sfc1 = draw_menu(11, menu_title[0], menu_options[0], menu_option_type[0], menu_selected[0], sel_factor, 1, font, &(menu_first_option[0]));
			} else {
				sfc1 = draw_menu(11, menu_title[0], menu_options[0], menu_option_type[0], menu_selected[0], sel_factor, enter_factor, font, &(menu_first_option[0]));
			} 
		} 
	} 

	if (menu_options[1] != 0) {
		sel_factor = float(0.6F - 0.4F * sin(menu_selected_timmer[1] / 10.0F));

		if (menu_redefining_key)
			sel_factor = 0;

		sfc2 = draw_menu(11, menu_title[1], menu_options[1], menu_option_type[1], menu_selected[1], sel_factor, enter_factor, font, &(menu_first_option[1]));
	} 

	w1 = w2 = wt = 0;

	if (sfc1 != 0) {
		wt += sfc1->w;
		w1 = sfc1->w;
	} 

	if (sfc2 != 0) {
		wt += sfc2->w;
		w2 = sfc2->w;
	} 

	if (sfc1 != 0 && sfc2 != 0)
		wt += 16;

	if (menu_current_menu == 23)
		menu_y = 400;

	if (sfc1 != 0) {
		menu = new GLTile(sfc1);
		menu->set_hotspot(0, 0);

		if ((menu_prev_nmenus == 2 && (menu_current_menu != 3 || menu_selected[1] != 0) && menu_current_menu != 4) ||
		        (menu_state < MENU_CONSTANT && menu_options[1] != 0)) {
			float f = float(sqrt(enter_factor));
			menu->draw((320 - wt / 2)*(f) + (menu_x[0])*(1 - f), float(menu_y), 0, 0, 1);

			if (enter_factor == 1.0)
				menu_x[0] = 320 - wt / 2;
		} else {
			if (menu_option_type[0][menu_selected[0]] == 11 && menu_state > MENU_CONSTANT) {
				float f = float(sqrt(enter_factor));

				menu->draw((320 - wt / 2)*(f) + (320 - (wt*3) / 4)*(1 - f), float(menu_y), 0, 0, 1);
				menu_x[0] = int((320 - wt / 2) * (f) + (320 - (wt * 3) / 4) * (1 - f));
			} else {
				menu->draw(float(320 - wt / 2), float(menu_y), 0, 0, 1);
				menu_x[0] = 320 - wt / 2;
			} 
		} 

		delete menu;

		//  SDL_FreeSurface(sfc1);
	} 

	if (sfc2 != 0) {
		menu = new GLTile(sfc2);
		menu->set_hotspot(sfc2->w, 0);
		menu->draw(float(320 + wt / 2), float(menu_y), 0, 0, 1);
		delete menu;
		//  SDL_FreeSurface(sfc2);
	} 

}