lunes, 13 de marzo de 2017

Avance

Reporte Primer Avance (Super Snake)

Creación del espacio donde se realizará el juego. En este caso se creo un tablero con un tamaño inicial de 40 X 40.


Inicio de la animación de la serpiente, se trabajo con un solo bloque.


lunes, 6 de marzo de 2017

Textura

Textura
por: Juan Angel Ortiz Contreras

Convertí mi imagen a RAW pero no carga por el tamaña de la imagen, lo intenté con varios tamaños pero no logré que se viera.




martes, 21 de febrero de 2017

Practica 2

PRACTICA 2
1.- Dibuja un cuadro rojo sólido
FUENTE




2.- Abrir una ventana que contenga
FUENTE

3 Dibujo a mano





lunes, 20 de febrero de 2017

Ajedrez Google



//GERMAN INIESTA SANCHEZ
//GRAFICACION
//AJEDREZ GOOGLE

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>

#define LONG_LADO 10 //longitud del lado del cuadrado
#define TRANS_X 2.5
#define TRANS_Y 7.5
#define TRANS_Z 0.0
#define SCALA_G 0.05


float radio = 1, a1, a2;
float nx, ny, r, g, b, dx, dy, pi = 3.141592653;
float trasX = TRANS_X, trasY = TRANS_Y, trasZ = TRANS_Z;
int puntos = 0, an = 500, al = 500, tam_px = 1;
int rot = 0, tx = 0, ty = 0;
void circulo(float cx, float cy, float radio, float r, float g, float b, float a1, float a2){
 glBegin(GL_POLYGON);
 glColor3f(r, g, b);
 glVertex2f(cx, cy);
 for (float i = a1; i<a2; i += 0.01)
 {
  dx = radio*cos(i) + cx;
  dy = radio*sin(i) + cy;
  glVertex2f(dx, dy);
 }
 glEnd();
}
//CREANDO EL TABLERO DE AJEDREZ
void tablero(){
 for (int colum = 0; colum < 10; colum++){
  for (int fila = 0; fila < 10; fila++){
   bool edo = true;
   if ((colum > 0 && colum < 9) && (fila > 0 && fila < 9)){
    if (colum % 2 != 0){//x impar                   
     if (fila % 2 != 0){//x impar
      glColor3f(0, 0, 0);//negro
     }
     else{//x par
      glColor3f(1, 1, 1);//blanco       
     }
    }
    else{//x par
     if (fila % 2 != 0){//x impar
      glColor3f(1, 1, 1);//blanco       
     }
     else{//x par
      glColor3f(0, 0, 0);//negro
     }
    }
   }
   else{
    glColor3f(1, 0.4, 0);
   }
   glBegin(GL_QUADS);
   glVertex2i(colum, fila);
   glVertex2i(colum, fila + 1);
   glVertex2i(colum + 1, fila + 1);
   glVertex2i(colum + 1, fila);
   glEnd();
  }
 }
}
//DIBUJANDO LA G DE GOOGLE
void dibujarG(){
 int cx = 0; int cy = 0;
 circulo(cx, cy, 5, 0.858, 0.196, 0.211, 0.7854, 2.7);
 circulo(cx, cy, 5, 0.956, 0.76, 0.05, 2.65, 3.65);
 circulo(cx, cy, 5, 0.235, 0.73, 0.33, 3.65, 5.49);
 circulo(cx, cy, 5, 0.282, 0.52, 0.93, 5.48, 2 * 3.22);
 circulo(cx, cy, 3, 1, 1, 1, 0, 2 * 3.1416);
 glColor3f(0.282, 0.52, 0.93);
 glBegin(GL_TRIANGLE_FAN);
 glVertex2f(0 + cx, 0.8 + cy); glVertex2f(4.98 + cx, 0.8 + cy);
 glVertex2f(4.93 + cx, -1 + cy); glVertex2f(0 + cx, -1 + cy);
 glEnd();
}
void display(void){
 glClear(GL_COLOR_BUFFER_BIT);
 glPushMatrix();
 tablero();
 glPopMatrix();
 glPushMatrix();
 glTranslatef(trasX, trasY, trasZ);//x,y,z
 glScalef(SCALA_G, SCALA_G, SCALA_G);
 dibujarG();
 glPopMatrix();
 glFlush();
}

// MOVIMIENTOS CON TECLADO
void key(unsigned char c, int x, int y)
{
 switch (c){
 case 27: //ESC
  exit(0);
  break;
 case 'w'://Arriba
  if (trasY < 8){
   trasY += 1;
  }
  break;
 case 's'://Abajo
  if (trasY > 2){
   trasY -= 1;
  }
  break;
 case 'a'://izquierda
  if (trasX > 2){
   trasX -= 1;
  }
  break;
 case 'd'://derecha
  if (trasX < 8){
   trasX += 1;
  }
  break;
 case 'r'://reset
  trasX = TRANS_X;
  trasY = TRANS_Y;
  trasZ = TRANS_Z;
  break;
 }
 display();
}
void Init()
{
 glClearColor(1.0, 1.0, 1.0, 0);
 gluOrtho2D(0, 10, 0, 10);
 glPointSize(tam_px);
 glEnable(GL_POINT_SMOOTH);
}
int main(int argc, char **argv)
{
 glutInit(&argc, argv);
 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
 glutInitWindowPosition(600, 200);
 glutInitWindowSize(an, al);
 glutCreateWindow("Ajedrez Google");
 Init();
 glutDisplayFunc(display);
 glutKeyboardFunc(key);
 glutMainLoop();
 return 0;
}

Tablero de ajedrez

Tablero de Ajedrez

Ricardo Alvarez Hernandez



Código

#include <windows.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <C:\GLUT\include\GL\glut.h>
#include <stdlib.h>

float radio=1,a1,a2;
float nx,ny,r,g,b,dx,dy,pi=3.141592653;
float trasX = 1.5, trasY = 1.5, trasZ = 0,escala=0.05;

int puntos=0, ancho=500,alto=500,tam_px=1;
int rot = 0,tx=0,ty=0;

void circulo(float cx,float cy,float radio,float r,float g,float b,float a1,float a2){

    glBegin(GL_POLYGON);
    glColor3f(r,g,b);
    glVertex2f(cx, cy);
    for (float i=a1; i<a2; i+=0.01)
    {
        dx=radio*cos(i)+cx;
        dy=radio*sin(i)+cy;
        glVertex2f(dx, dy);
    }
    glEnd();
}

void tablero(){
    for(int colum = 1; colum < 9; colum++){
        for(int fila = 1; fila < 9; fila++){
            bool edo = true;
            if((colum > 0 && colum < 9) && (fila > 0 && fila < 9)){
                if(colum%2 != 0){//x impar
                    if(fila%2 != 0){//x impar
                        glColor3f(0,0,0);//negro
                    }else{//x par
                        glColor3f(1,1,1);//blanco
                    }
                }else{//x par
                    if(fila%2 != 0){//x impar
                        glColor3f(1,1,1);//blanco
                    }else{//x par
                        glColor3f(0,0,0);//negro
                    }
                }
            }else{
                glColor3f(1,0,0);
            }
            glBegin(GL_QUADS);
                glVertex2i(colum, fila);
                glVertex2i(colum, fila + 1);
                glVertex2i(colum + 1,fila + 1);
                glVertex2i(colum + 1,fila);
            glEnd();
            glBegin(GL_LINE_STRIP);
                glVertex2i(1,1);
                glVertex2i(9,1);
                glVertex2i(9,9);
                glVertex2i(1,9);
                glVertex2i(1,1);
            glEnd();
        }
    }
}

void Google(){
    int cx=0;int cy=0;
    circulo(cx,cy,5,0.858,0.196,0.211,0.7854,2.7);
    circulo(cx,cy,5,0.956,0.76,0.05,2.65,3.65);
    circulo(cx,cy,5,0.235,0.73,0.33,3.65,5.49);
    circulo(cx,cy,5,0.282,0.52,0.93,5.48,2*3.22);
    circulo(cx,cy,3,1,1,1,0,2*3.1416);
    glColor3f(0.282,0.52,0.93);
    glBegin(GL_TRIANGLE_FAN);
        glVertex2f(0+cx,0.8+cy);glVertex2f(4.98+cx,0.8+cy);
        glVertex2f(4.93+cx,-1+cy);glVertex2f(0+cx,-1+cy);
    glEnd();
}

void display(void){
    glClear(GL_COLOR_BUFFER_BIT);

    glPushMatrix();
        tablero();
    glPopMatrix();

    glPushMatrix();
        glTranslatef(trasX, trasY, trasZ);//x,y,z
        glScalef(escala, escala, escala);
        Google();
    glPopMatrix();

    glFlush();

}

void key(unsigned char c, int x, int y)
{
    switch(c){
        case 27: //ESC
            exit(0);
            break;
        case 'w'://mover a la Arriba
            if(trasY < 8){
                trasY += 1;
            }
            break;
        case 's'://mover a la Abajo
            if(trasY > 2){
                trasY -= 1;
            }
            break;
        case 'a'://mover a la izquierda
            if(trasX > 2){
                trasX -= 1;
            }
            break;
        case 'd'://mover a la derecha
            if(trasX < 8){
                trasX += 1;
            }
            break;
        case 'r'://reset
            trasX = 1.5;
            trasY = 1.5;
            trasZ = 0;
            break;
    }
    display();
}

void Init()
{   glClearColor(1.0,1.0,1.0,0);
    gluOrtho2D(0,10,0,10);
    glPointSize(tam_px);
    glEnable(GL_POINT_SMOOTH);

}

int main(int argc, char **argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowPosition(100,100);
    glutInitWindowSize(ancho,alto);
    glutCreateWindow("Tablero de Ajedrez");

    Init();

    glutDisplayFunc(display);
    glutKeyboardFunc(key);

    glutMainLoop();
    return 0;
}




Tablero de Ajedrez


Tablero de Ajedrez