标题:[原创]感觉弄这个比玩游戏爽
取消只看楼主
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
结帖率:74.19%
 问题点数:0 回复次数:7 
[原创]感觉弄这个比玩游戏爽

#include "stdio.h"
#include "conio.h"
#include "time.h"
#include "stdlib.h"
#include "graphics.h"
#include "math.h"

#define PI 3.14

main()
{
float i ,j ,k = -2;
int gd=DETECT ,gm;
int Mx ,My , xd = 1, yd = 1 ,kd = 1 ,cr = 1 ,cd = 1;
float x = 0 ,y = 0 ,xm = 0 ,ym = 0;

initgraph(&gd ,&gm ,"");

Mx = getmaxx()/2;
My = getmaxy()/2;

while(!kbhit())
{
for(i = 0;i < PI;i+=0.05)
{
for(j = 0;j < PI ;j+=0.05)
{
x = cos(i+k)*30*j+Mx+xm;
y = sin(j+k)*30*i+My+ym;

putpixel(x ,y ,cr);

}
}
xd = (xm > 200)? -1: xd;
xd = (xm < -200)? 1: xd;

yd = (ym > 250)? -1: yd;
yd = (ym < -250)? 1: yd;

kd = (k > PI*2)? -1: kd;
kd = (k < -PI*2)? 1: kd;

cd = (cr > 11)? -1: cd;
cd = (cr < 5)? 1: cd;

k += 0.1*kd;
xm += 2*xd;
ym += 2*yd;
cr += 4*cd;

delay(10000);
cleardevice();
}
getch();
}



写的有点乱

[此贴子已经被作者于2007-1-29 15:56:21编辑过]

搜索更多相关主题的帖子: include 游戏 float int 
2007-01-29 15:49
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
得分:0 

#include "stdio.h"
#include "conio.h"
#include "time.h"
#include "stdlib.h"
#include "graphics.h"
#include "math.h"

#define PI 3.14

main()
{
float i ,j ,k = -2;
int gd=DETECT ,gm;
int Mx ,My , xd = 1, yd = 1 ,kd = 1 ,cr = 2 ,cd = 1;
float x = 0 ,y = 0 ,xm = 0 ,ym = 0;

initgraph(&gd ,&gm ,"");

Mx = getmaxx()/2;
My = getmaxy()/2;

while(!kbhit())
{
for(i = 0;i < PI;i+=0.05)
{
for(j = 0;j < PI ;j+=0.05)
{
x = cos(2*i+k)*30*j+Mx+xm;
y = sin(2*j+k)*30*i+My+ym;

putpixel(x ,y ,cr);

}
}
xd = (xm > 200)? -1: xd;
xd = (xm < -200)? 1: xd;

yd = (ym > 250)? -1: yd;
yd = (ym < -250)? 1: yd;

kd = (k > PI*4)? -1: kd;
kd = (k < -PI*4)? 1: kd;
/*
cd = (cr > 11)? -1: cd;
cd = (cr < 5)? 1: cd;
*/
k += 0.1*kd;
xm += 2*xd;
ym += 2*yd;
/* cr += 4*cd; */

delay(10000);
cleardevice(); /* 感觉图片有点闪就把这个地方改为定点覆盖就行 */
}
getch();
}

[此贴子已经被作者于2007-2-1 18:22:27编辑过]

2007-02-01 18:18
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
得分:0 

for(j = 0;j < PI ;j+=0.05)
{
x = cos(3*i+k)*30*j+Mx+xm;
y = sin(3*j+k)*30*i+My+ym;

putpixel(x ,y ,cr);

}
}

把那个数改成其他的数有更好的效果

2007-02-01 18:24
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
得分:0 

for(j = 0;j < PI ;j+=0.05)
{
x = cos(k*i/2+k)*30*j+Mx+xm;
y = sin(k*j/2+k)*30*i+My+ym;

putpixel(x ,y ,cr);

}

这么改也挺有意思

2007-02-01 18:28
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
得分:0 
以下是引用田里兵蜂在2007-2-1 18:25:33的发言:

哇,我运行了下,第二个图真好看

终于有人理我拉

2007-02-01 18:29
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
得分:0 
这两个效果更好:

x = cos(2*i+k+j)*30*j+Mx+xm;
y = sin(2*j+k+i)*30*i+My+ym;


x = cos(2*i+k*j)*30*j+Mx+xm;
y = sin(2*j+k*i)*30*i+My+ym;
2007-02-02 17:10
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
得分:0 
x = cos(i*3+k*j)*30*j+Mx+xm;
y = sin(j*3+k*i)*30*i+My+ym;
2007-02-02 17:12
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
得分:0 

x = sin(j)*10+cos(i*3+k*j)*30*j+Mx+xm;
y = cos(i)*10+sin(j*3+k*i)*30*i+My+ym;

k=-3.3左右的时候好像很好看
明天再弄
2007-02-02 17:25



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-118722-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.066637 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved