Juego [C] V2

Iniciado por OSI, Junio 25, 2010, 10:23:32 AM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Junio 25, 2010, 10:23:32 AM Ultima modificación: Febrero 08, 2014, 06:12:24 PM por Expermicid
A Game Terect (?)
  • Usando Botones del Ratón ;)[/b]
    • Mejoras en el código ;)[/b]
      Código: c
      // Grets : p0fk - ksha - yoya - S[e]C - Antrax - champloo - OzX - [t]err0r - Cervantes_xD - 

      #include <stdio.h>
      #include <GL/glut.h>
      #include <stdlib.h>
      double p0fk = 0.5;
      double ksha = 0.5;
      double mierda = 0.10;

      void trolear ()
      {

      glClear(GL_COLOR_BUFFER_BIT);
      glMatrixMode(GL_MODELVIEW);
      glPushMatrix();
      glColor3d(0,1,1);
      p0fk += 0.3;
      glTranslated(0.5,0.10,1);
      glRotated(p0fk,2,2,2);
      glutWireTeapot(0.30);
      glPopMatrix();

      glPushMatrix();
      glColor3d(0,0,2);
      ksha += 0.6;
      glTranslated(-0.5,0.10,1);
      glRotated(ksha,4,4,4);
      glutWireCone(0.2,20,20,0.21);
      glPopMatrix();

      glPushMatrix();
      glColor3d(3,3,1);
      mierda += 0.7;
      glTranslated(0.20,0.70,1);
      glRotated(mierda,1,1,1);
      glutWireCube(0.20);
      glPopMatrix();
      glutSwapBuffers();
      }
              void dibuja ()
              {
              glMatrixMode(GL_MODELVIEW);
              glPushMatrix();
              glColor3d(3,3,1);
              mierda += 0.3;
              glTranslated(-0.5,0.10,1);
              glRotated(mierda,3,3,3);
              glutWireTeapot(0.30);
              glPopMatrix();
              }

      void des ()
      {
      glutPostRedisplay(); // repintar
      }
      void salir(unsigned char teclado)
      {
      if (teclado == 27)
      {
      exit(EXIT_SUCCESS);
      printf (";)");
      }
      if (teclado == 98)
      {
      ksha +=0.7;
      glTranslated(-0.5,0.10,1);
      glRotated(ksha,4,4,1);
      glutWireTorus(0.3,20,20,0.21);
      glPopMatrix();
      glutSwapBuffers();
      }
      if (teclado == 97)
      {
      p0fk +=0.6;
      glTranslated(+0.50,0.60,1);
      glRotated(p0fk,2,2,1);
      glutWireTeapot(0.20);
      glPopMatrix();
      glutSwapBuffers();
      }

      }
      void movimiento (int boton, int estado , int x, int y)
      {
      if ((estado == GLUT_DOWN) && (boton == GLUT_LEFT_BUTTON))
      {
              glutDisplayFunc(dibuja);
      }
              if ((estado == GLUT_UP) && (boton == GLUT_RIGHT_BUTTON))
              {
              glutDisplayFunc(trolear);
              }
      }
      int main (int argc, char* argv[])
      {

      glutInit(&argc, argv);
      glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
      glutInitWindowSize(600,300);
      glutInitWindowPosition(500,500);
      glutCreateWindow("The Game");
      glutFullScreen ();


      glClearColor(0,0,0,0);
      glutDisplayFunc(trolear);
      glutMouseFunc(movimiento);
      glutIdleFunc(des);
      glutKeyboardFunc(salir);
      glutMainLoop();

      return 0;
      }
      [/sub][/sub]

      Pronto haré un video extrenando the game