-
C语言课程设计 利用页面制作动画效果 - [学]
2009-10-13
今天开始是课程实践周,每天昏天暗地地的一直坐在电脑旁……

看着源代码……= =发狂了……我改的面目全非……变成了有点像彩色铅笔屏保一样的东西……不过,C语言是无所不能的……这点我倒是体会到了。从画图到音乐甚至是3D,只要你够强,都没有问题。数学要好哦!
因为之前学习的和现在要做的几乎完全无关……= =所以很是痛苦的自学。我的电脑一运行win-TC就会蓝屏。泪奔。
分享一个打砖块游戏的原代码。
这是一个同学download下来的,不过原来游戏的打的速度非常之快,该同学优化的一下。
/*===========================Program Description==========================*/
/*程序名称:game.c */
/*程序目的:打砖块游戏演示 */
/*written by :董大钿 */
/*========================================================================*/#include "graphics.h"
#include "stdio.h"
#include "conio.h" /*所需的头文件*/int on; /*声明具有开关作用的全局变量*/
static int score; /*声明静态的记分器变量*/
/* 定义开始界面函数*/
int open()
{
setviewport(100,100,500,380,1); /*设置图形窗口区域*/
setcolor(RED); /*设置作图色*/
rectangle(0,0,399,279); /*以矩形填充所设的图形窗口区域*/
setfillstyle(SOLID_FILL,7); /*设置填充方式*/
floodfill(50,50,4); /*设置填充范围*/
setcolor(8);
settextstyle(0,0,9); /*文本字体设置*/
outtextxy(90,80,"MAN?"); /*输出文本内容*/
settextstyle(0,0,1);
outtextxy(100,180,"by lcx");
settextstyle(0,0,1);
outtextxy(120,240,"Press any key to continue......");
}/*定义退出界面函数*/
int quitwindow()
{
char s[100]; /*声明用于存放字符串的数组*/
setviewport(100,150,540,420,1);
setcolor(YELLOW);
rectangle(0,0,439,279);
setfillstyle(SOLID_FILL,7);
floodfill(50,50,14);
setcolor(12);
settextstyle(0,0,8);
outtextxy(120,80,"End");
settextstyle(0,0,2);
outtextxy(120,200,"quit? Y/N");
sprintf(s,"Your score is:%d",score);/*格式化输出记分器的值*/
outtextxy(120,180,s);
on=1; /*初始化开关变量*/
}/*主函数*/
main()
{
int gdriver,gmode;
gdriver=DETECT; /*设置图形适配器*/
gmode=VGA; /*设置图形模式*/
registerbgidriver(EGAVGA_driver); /*建立独立图形运行程序*/
initgraph(&gdriver,&gmode,""); /*图形系统初试化*/
setbkcolor(14);
open(); /*调用开始界面函数*/
getch(); /*暂停*/while(1) /*此大循环体控制游戏的反复重新进行*/
{
int driver,mode,l=320,t=400,r,a,b,dl=5,n,x=240,y=400,r1=10,dx=-2,dy=-2;/*初始化小球相关参数*/
int left[100],top[100],right[100],bottom[100],i,j,k,off=1,m,num[100][100];/*方砖阵列相关参数*/
static int pp;
static int phrase; /*一系列起开关作用的变量*/
int oop=1;
pp=1;
score=0;
driver=DETECT;
mode=VGA;
registerbgidriver(EGAVGA_driver);
initgraph(&driver,&mode,"");
setbkcolor(10);
cleardevice(); /*图形状态下清屏*/
clearviewport(); /*清除现行图形窗口内容*/
b=t+6;
r=l+60;
setcolor(1);
rectangle(0,0,639,479);
setcolor(4);
rectangle(l,t,r,b);
setfillstyle(SOLID_FILL,1);
floodfill(l+2,t+2,4);for(i=0,k=0;i<=6;i++) /*此循环绘制方砖阵列*/
{
top[i]=k;
bottom[i]=top[i]+20;
k=k+21;
oop--;
for(j=0,m=0;j<=7;j++)
{
left[j]=m;
right[j]=left[j]+80;
m=m+81;
setcolor(4);
rectangle(left[j],top[i],right[j],bottom[i]);
setfillstyle(SOLID_FILL,j+oop);
floodfill(left[j]+1,top[i]+1,4);
num[i][j]=pp++;
}
}
while(1) /*此循环控制整个动画*/
{
while(!kbhit())
{
x=x+dx; /*小球运动的圆心变量控制*/
y=y+dy;
if(x+r1>r||x+r1<r)
{ phrase=0;}
if((x-r1<=r||x+r1<=r)&&x+r1>=l)
{
if(y<t)
phrase=1;
if(y+r1>=t&&phrase==1)
{dy=-dy;y=t-1-r1;}
}
if(off==0)
continue;for(i=0;i<=6;i++) /*此循环用于判断、控制方砖阵列的撞击、擦除*/
for(j=0;j<=7;j++)
{
if((x+r1<=right[j]&&x+r1>=left[j])||(x-r1<=right[j]&&x-r1>=left[j]))
{
if(( y-r1>top[i]&&y-r1<=bottom[i])||(y+r1>=top[i]&&y+r1<=bottom[i] ))
{
if(num[i][j]==0)
{continue; }
setcolor(10);
rectangle(left[j],top[i],right[j],bottom[i]);
setfillstyle(SOLID_FILL,10);
floodfill(left[j]+1,top[i]+1,10);
dy=-dy;
num[i][j]=0;
score=score+10;
printf("%d\b\b\b",score);
}
}
if((y+r1>=top[i]&&y+r1<=bottom[i])||(y-r1>=top[i]&&y-r1<=bottom[i]))
{
if((x+r1>=left[j]&&x+r1<right[j])||(x-r1<=right[j]&&x-r1>left[j]))
{
if(num[i][j]==0)
{ continue;}
setcolor(10);
rectangle(left[j],top[i],right[j],bottom[i]);
setfillstyle(SOLID_FILL,10);
floodfill(left[j]+1,top[i]+1,10);
dx=-dx;
num[i][j]=0;
score=score+10;
printf("%d\b\b\b",score);
}
}
}if(x+r1>639) /*控制小球的弹射范围*/
{dx=-dx;x=638-r1;}
if(x<=r1)
{dx=-dx;x=r1+1;}
if(y+r1>=479)
{off=0;quitwindow();break;}
if(y<=r1)
{dy=-dy;y=r1+1;}
if(score==560)
{off=0;quitwindow();break;}
setcolor(6);
circle(x,y,r1);
setfillstyle(SOLID_FILL,14);
floodfill(x,y,6);
delay(6000);
setcolor(10);
circle(x,y,r1);
setfillstyle(SOLID_FILL,10);
floodfill(x,y,10);
}a=getch();
setcolor(10);
rectangle(l,t,r,b);
setfillstyle(SOLID_FILL,10);
floodfill(l+5,t+5,10);
if(a==77&&l<=565) /*键盘控制设定*/
{dl=20;l=l+dl;}
if(a==75&&l>=15)
{dl=-20;l=l+dl;}
if(a=='y'&&on==1)
break;
if(a=='n'&&on==1)
break;
if(a==27)
{quitwindow();off=0;}
r=l+60;
setcolor(4);
rectangle(l,t,r,b);
setfillstyle(SOLID_FILL,1);
floodfill(l+5,t+5,4);
delay(100);
}
if(a=='y'&&on==1) /*是否退出游戏*/
{break;}
if(a=='n'&&on==1)
{ continue;}
}
closegraph();}
-
vampire
2009-10-08
我最近喜欢的21guns居然在变/形/金/刚/2里出现了……
听到的瞬间崩了……
那种不知道是插曲还是一半片尾曲的样子到底是要干什么……反正我就是看完了也不知道是插曲还是一半的片尾曲。明明片尾曲是林/肯/公/园/的.
昨天看了烂在C盘里的吸/血/鬼/日/记。最近的吸血鬼故事总是这样的,有个不肯吸人血的男吸血鬼,有个什么都不知道的人类女孩,再加上一个反正是跟前面那个男的有仇或者是企图改变前面那个男的生活方式的嗜血的吸血鬼……= =……两种结局。要么是那个女的变成吸血鬼了然后死了。要么是嗜血的吸血鬼暂时被打败了,男的和女的幸福的生活在一起……误……
= =但是人们就是爱看……包括我……看了那么多吸血鬼电影还是夜探吸血鬼比较好……不那个啥啥暮光之城好多了……
看了很多吸血鬼电影之后才知道vampire怎么说……哈哈……这算是收获?
-
= =我来更新了
2009-10-07
看到有成都的朋友到访我就在想是不是我们家那个在爬峨眉山的老头子来看我了……
= =……十一在上海过得……竭斯底里的……= =不对……大脑空白的……于是我决定还是早点回来?恩换个地方无聊一下。
恭贺A老板博... -
21guns
2009-09-07
= =起初我觉得这首歌很适合米英的……因为是裸听的……后来看了歌词才知道。= =guns是枪响的意思。
不过还是很喜欢这首green days的21guns
Green Day - 21 Guns / 绿日 - 二十一响
Do you know what's worth fighting for / 你可明白它并不值得你献出生命
When it's not worth dying for? / 你为何还要为它拼命?
Does it take your breath away / 它有没有夺走你的呼吸
And you feel yourself suffocating? / 让你感觉到自己行将窒息?
Does the pain weigh out the pride? / 痛苦与荣耀可是一个重量?
And you look for a place to hide? / 你可是在找藏身的地方?
Did someone break your heart inside? / 有没有人刺穿了你的胸膛?
You're in ruins / 你只剩残骸
One, 21 guns / 鸣炮,21响
[Lay down your arms / 放下你的武器
[Give up the fight / 停止你的厮杀
One, 21 guns / 鸣炮,21响
Throw up your arms into the sky / 把你的武器抛向天空
You and I / 你与我
When you're at the end of the road / 等你走到无路可走
And you lost all sense of control / 等你变成行尸走肉
And your thoughts have taken their toll / 等你思想的丧钟都已敲响
When your mind breaks the spirit of your soul / 等你的心智磨灭了你灵魂的锋芒
Your faith walks on broken glass / 你的信仰将血流成河
And the hangover doesn't pass / 你的遗物会流离失所
Nothing's ever built to last / 天长地久又何曾有过
You're in ruins / 你只剩残骸Did you try to live on your own / 你可曾努力养活自己
When you burned down the house and home? / 在你烧光自己的房屋与家园之后?
Did you stand too close to the fire? / 你可曾玩火玩到自焚?
Like a liar looking for forgiveness from a stone / 就像那骗子想痛改前非,却去求石头
When it's time to live and let die / 等你走到可生可死的路口
And you can't get another try / 在何去何从的紧要关头
Something inside this heart has died / 这颗心里有个东西已化为乌有
You're in ruins / 你只剩残骸
One, 21 guns / 鸣炮,21响
Lay down your arms / 放下你的武器
Give up the fight / 停止你的厮杀
One, 21 guns / 鸣炮,21响
Throw up your arms into the sky / 把你的武器抛向天空
You and I / 你与我 -
安全到达杭州!
2009-08-31
= =……杭州现在好凉快&
杭州你好可爱
我真担心过几天如果热起来怎么办
……学校的网速好快












