字母落下炸开
来源:互联网 发布:万能标签打印软件 编辑:程序博客网 时间:2024/04/27 16:13
#include <stdio.h>
#include <stdlib.h>
#include <curses.h>
#define DEEP 24
#define BALL 'O'
#define SPACE ' '
void drop();
void brusk(int,int,int);
void Init();
typedef struct{
char ch;
int new_x,new_y;
int old_x,old_y;
int acc;
int dis;
}Chars;
int main(){
Init();
drop(40,0);
move(15,40);
int i=3;
while(i--){
char buf[10];
move(15,40);
sprintf(buf,"quit. %d",i);
addstr(buf);
refresh();
sleep(1);
}
endwin();
return 0;
}
void Init(){
srand(time(0));
initscr();
noecho();
move(0,0);
int i;
for(i=0;i<79;i++)
addch('_');
move(DEEP-1,0);
for(i=0;i<79;i++)
addch('_');
refresh();
for(i=0;i<3;i++){
char str[2];
sprintf(str,"%d",3-i);
move(15,40); addstr(str);
refresh();
sleep(1);
}
mvaddch(15,40,SPACE);
refresh();
}
void drop(int x,int y){
int i=0;
mvaddch(y,x,BALL);
refresh();
sleep(1);
for(i=0;i<DEEP;i++){
mvaddch(i-1,x,SPACE);
mvaddch(i, x,BALL);
refresh();
int time = (DEEP-i)*(DEEP-i)*30;
usleep(time);
}
mvaddch(i-1,x,SPACE);
brusk(x,DEEP,rand()%5+5);
}
void brusk(int x,int y,int n){
int i,j;
Chars *Bs=(Chars*)calloc(sizeof(Chars),n);
// 初始化
for(i=0;i<n;i++){
Bs[i].ch = 'a'+rand()%24;
Bs[i].new_x=Bs[i].old_x=x;
Bs[i].new_y=Bs[i].old_y=y;
Bs[i].acc = rand()%10-5;
Bs[i].dis = rand()%10+2;
}
while(1){
int flag = 0;
for(i=0;i<n;i++){
Bs[i].new_x-=Bs[i].acc;
Bs[i].new_y--;
if(Bs[i].new_x<=0 || Bs[i].new_x>=80 || Bs[i].new_y<=0 || Bs[i].new_y>=24){
flag++;
continue;
}
mvaddch(Bs[i].old_y,Bs[i].old_x,SPACE);
mvaddch(Bs[i].new_y,Bs[i].new_x,Bs[i].ch);
refresh();
usleep(10000);
Bs[i].old_x=Bs[i].new_x;
Bs[i].old_y=Bs[i].new_y;
}
if(flag >= n) break;
}
}
#include <stdlib.h>
#include <curses.h>
#define DEEP 24
#define BALL 'O'
#define SPACE ' '
void drop();
void brusk(int,int,int);
void Init();
typedef struct{
char ch;
int new_x,new_y;
int old_x,old_y;
int acc;
int dis;
}Chars;
int main(){
Init();
drop(40,0);
move(15,40);
int i=3;
while(i--){
char buf[10];
move(15,40);
sprintf(buf,"quit. %d",i);
addstr(buf);
refresh();
sleep(1);
}
endwin();
return 0;
}
void Init(){
srand(time(0));
initscr();
noecho();
move(0,0);
int i;
for(i=0;i<79;i++)
addch('_');
move(DEEP-1,0);
for(i=0;i<79;i++)
addch('_');
refresh();
for(i=0;i<3;i++){
char str[2];
sprintf(str,"%d",3-i);
move(15,40); addstr(str);
refresh();
sleep(1);
}
mvaddch(15,40,SPACE);
refresh();
}
void drop(int x,int y){
int i=0;
mvaddch(y,x,BALL);
refresh();
sleep(1);
for(i=0;i<DEEP;i++){
mvaddch(i-1,x,SPACE);
mvaddch(i, x,BALL);
refresh();
int time = (DEEP-i)*(DEEP-i)*30;
usleep(time);
}
mvaddch(i-1,x,SPACE);
brusk(x,DEEP,rand()%5+5);
}
void brusk(int x,int y,int n){
int i,j;
Chars *Bs=(Chars*)calloc(sizeof(Chars),n);
// 初始化
for(i=0;i<n;i++){
Bs[i].ch = 'a'+rand()%24;
Bs[i].new_x=Bs[i].old_x=x;
Bs[i].new_y=Bs[i].old_y=y;
Bs[i].acc = rand()%10-5;
Bs[i].dis = rand()%10+2;
}
while(1){
int flag = 0;
for(i=0;i<n;i++){
Bs[i].new_x-=Bs[i].acc;
Bs[i].new_y--;
if(Bs[i].new_x<=0 || Bs[i].new_x>=80 || Bs[i].new_y<=0 || Bs[i].new_y>=24){
flag++;
continue;
}
mvaddch(Bs[i].old_y,Bs[i].old_x,SPACE);
mvaddch(Bs[i].new_y,Bs[i].new_x,Bs[i].ch);
refresh();
usleep(10000);
Bs[i].old_x=Bs[i].new_x;
Bs[i].old_y=Bs[i].new_y;
}
if(flag >= n) break;
}
}
0 0
- 字母落下炸开
- 运动不能落下!
- 别让灵魂落下
- JavaScript模拟小球落下
- 小球落下问题
- 小球落下,反弹问题
- 皮球落下反弹问题
- 字母
- 键盘抬起落下,输入框相应抬起落下
- 小球自由落下的问题
- 心上的石头终于落下了
- 一滴眼泪落下 需要多少时间
- 谷歌闹剧即将落下帷幕
- 小球从100米落下,反弹
- 掌声响起来,文胸落下来
- 这几天落下了很多学习。
- js小球碰撞模拟小球落下
- 随興8作者雨落下無痕
- oracle 12c rac dbca建库,提示无法访问+DATA磁盘组
- Error:(27, 42) 错误: <匿名com.jeff.networktest.MainActivity$1>不是抽象的, 并且未覆盖Handler中的抽象方法publish(LogRecord
- 222 Count Complete Tree Nodes
- Xcode升级到7以后网络请求失败的问题
- Web设计中打开新页面或页面跳转的方法
- 字母落下炸开
- C语言读入多组数并打印数值和
- 修改LinearLayout中子控件TextView点击颜色小结
- iOS 面试总结
- MFC中修改静态文本控件的颜色和大小
- maven工程如何添加lpom.xm lib下的Jar包文件
- js小技巧
- Android进阶之动态加载图片(runOnUiThread/handler)
- 形态学变换