How the game does not require the user to control movement of props

// we are here to do an example with <bouncing ball> Code
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>

// This code is for the majority of white, where most of the data on global variables are used

char cChar; // ball
int Width, High; // range wall
int x, y; // ball coordinate
int Lx, Ly; // ball moving speed

void Forse (); // initialize the data
void show (); // display
void Move (); // ball movement

int main ()
{
Forse();
while(1)
{
system("cls");
show();
Move();
}
return 0;
}
void Forse()
{
cChar='a';
x=1; y=5;
Lx=1; Ly=1;
Width=High=15;
}
void show()
{
int i,j;
for(i=0;i<High;i++)
{
for(j=0;j<Width;j++)
{
if(i==y&&j==x)//此处坐标由个人理解定
printf("%c",cChar);
else if(i==0||i==High-1)
printf("-");
else if(j==0||j==Width-1)
printf("|");
else
printf(" ");
}
printf("\n");
}
}
void Move () // here I wrote a little rigid, you can go to change the speed according to different situations, to change the trajectory (trajectory otherwise very dead)
{
the X-the X-+ = Lx;
the y-+ = the y-Ly;
IF ( X> X || the Width-2 <. 1)
Lx of Lx of * = -1;
IF (Y> High-2 || Y <. 1)
Ly * Ly = -1;
}

Guess you like

Origin www.cnblogs.com/yylgoodjob/p/11872709.html
Recommended