资源简介

实现彩虹,小船移动,星星闪烁和流星的小动画

资源截图

代码片段和文件信息

#include 
#include 
#include 
#include 
#include 
#include 
#include 

#pragma comment(lib“opengl32.lib“)
#pragma comment(lib“glu32.lib“)
#pragma comment(lib“glaux.lib“)

#define MAX 1000
int m[MAX][MAX]={0};

void InitGL(void){
auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);
//auxInitDisplayMode(AUX_DOUBLE|AUX_RGBA);

auxInitPosition(00640480);
auxInitWindow(“scenery“);
glClearColor(0.61.00.80);
glClear(GL_COLOR_BUFFER_BIT);
}

void Triangle(int x1int y1int x2int y2int x3int y3){
glLineWidth(1);
glBegin(GL_POLYGON);;
glVertex2s(x1y1);
glVertex2s(x2y2);
glVertex2s(x3y3);
glVertex2s(x1y1);
glEnd();
glFlush();

}

void Rectangle(int x1int y1int x2int y2){
glBegin(GL_POLYGON);;
glVertex2s(x1y1);
glVertex2s(x1y2);
glVertex2s(x2y2);
glVertex2s(x2y1);
glVertex2s(x1y1);
glEnd();
glFlush();
//auxSwapBuffers();
}

void Polygon(int x[]int y[]int n){
glBegin(GL_POLYGON);
int i;
for(i=0;i glVertex2s(x[i]y[i]);
}
glEnd();
glFlush();
}

void seed8(int xint y)
{
if(x>100&&x<150&&y>450-sqrt(625-pow((x-125)2))&&y<450+sqrt(625-pow((x-125)2))&&m[x][y]==0)
{
glColor3f(1.00.00.0);
glBegin(GL_POINTS);
glVertex2i(xy);
m[x][y]=1;
seed8(x+1y);
seed8(x+1y+1);
seed8(xy+1);
seed8(x-1y+1);
seed8(x-1y);
seed8(x-1y-1);
seed8(xy-1);
seed8(x+1y-1);
glEnd();
glFlush();}
}

void seed82(int xint y)
{
if(x>100&&x<150&&y>450-sqrt(625-pow((x-125)2))&&y<450+sqrt(625-pow((x-125)2))&&m[x][y]==1)
{
glColor3f(1.01.01.0);
glBegin(GL_POINTS);
glVertex2i(xy);
m[x][y]=0;
seed82(x+1y);
seed82(x+1y+1);
seed82(xy+1);
seed82(x-1y+1);
seed82(x-1y);
seed82(x-1y-1);
seed82(xy-1);
seed82(x+1y-1);
glEnd();
glFlush();}
}

void seed83(int xint y)
{
if(x>115&&x<165&&y>450-sqrt(625-pow((x-140)2))&&y<450+sqrt(625-pow((x-140)2))&&m[x][y]==0)
{
glColor3f(0.00.00.0);
glBegin(GL_POINTS);
glVertex2i(xy);
m[x][y]=1;
seed83(x+1y);
seed83(x+1y+1);
seed83(xy+1);
seed83(x-1y+1);
seed83(x-1y);
seed83(x-1y-1);
seed83(xy-1);
seed83(x+1y-1);
glEnd();
glFlush();}
}

void seed84(int xint y)
{
if(x>100&&x<150&&y>250-sqrt(625-(int)(pow((x-125)2)))&&y<250+sqrt(625-(int)(pow((x-125)2)))&&m[x][y]==0)
{
glColor3f(1.01.01.0);
glBegin(GL_POINTS);
glVertex2i(xy);
m[x][y]=1;
seed82(x+1y);
seed82(x+1y+1);
seed82(xy+1);
seed82(x-1y+1);
seed82(x-1y);
seed82(x-1y-1);
seed82(xy-1);
seed82(x+1y-1);
glEnd();
glFlush();}
}

void seed85(int xint y)
{
if(x>115&&x<165&&y>250-sqrt(625-pow((x-140)2))&&y<250+sqrt(625-pow((x-140)2))&&m[x][y]==1)
{
glColor3f(0.20.40.6);
glBegin(GL_POINTS);
glVertex2i(xy);
m[x][y]=0;
seed82(x+1y);
seed82(x+1y+1);
seed82(xy+1);
seed82(x-1y+1);

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-04-23 20:42  scene\
     目录           0  2014-04-23 18:47  scene\Debug\
     文件      258100  2014-04-23 12:11  scene\Debug\scene.exe
     文件      340580  2014-04-23 12:11  scene\Debug\scene.ilk
     文件       71342  2014-04-23 12:11  scene\Debug\scene.obj
     文件     3704412  2014-04-23 12:11  scene\Debug\scene.pch
     文件      648192  2014-04-23 12:11  scene\Debug\scene.pdb
     文件      246784  2014-04-23 20:25  scene\Debug\vc60.idb
     文件       77824  2014-04-23 12:11  scene\Debug\vc60.pdb
     文件       20698  2014-04-23 12:10  scene\scene.cpp
     文件        4272  2014-04-22 18:29  scene\scene.dsp
     文件         518  2014-04-22 17:27  scene\scene.dsw
     文件       58368  2014-04-23 20:26  scene\scene.ncb
     文件       48640  2014-04-23 20:26  scene\scene.opt
     文件       16190  2014-04-23 12:11  scene\scene.plg

评论

共有 条评论