四边形弹的小球

#include<stdio.h>
#include<stdlib.h>
int main()
{
	int i,j;
	int x=20;
	int y=0;
	int left=0;
	int right=30;
	int top=0;
	int bottom=30;
	int k=1;
	int velocity_x=1;
	int velocity_y=1;
	while(1)
	{
		x=x+velocity_x;
		y=y+velocity_y;
		system("cls");
		for(i=0;i<x;i++)
		    printf("\n");
		for(j=0;j<y;j++)
		    printf(" ");
		printf("o");
		printf("\n");
		if(x==top||x==bottom)
		{
			velocity_x=-(velocity_x);
			
		}
		if(y==left||y==right)
		{
			velocity_y=-(velocity_y);
		
		}
		
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_41404557/article/details/80100028
今日推荐