+ 1
Cpp
Please i need help i want to write a code in cpp how do i make a ball move up and then go back down? And can i write if and switch together?
4 Respostas
0
No i didn't
0
Show us the code first?
0
#include <iostream>
#include <conio.h>
#include <windows.h>
#include <ctime>
#include <cstdlib>
using namespace std;
class ping{
int wide;
int high;
int ballx;
int bally;
int tablex;
int tabley;
char dir;
int speed;
enum direction{lift=0,rieght};
public:
void setup(){
wide=40;
high=20;
tabley=wide/2;
tablex=high-0;
bally=wide/2;
ballx=high/2;
}
void drow(){
system("cls");
for(int i=0;i<=high;i++){
for(int u=0;u<=wide;u++){
if(i==0||u==0||u==wide)
cout<<"*";
else if(i==tablex&&u==tabley||i==tablex&&u==tabley+1||i==tablex&&u==tabley+2||i==tablex&&u==tabley+3)
cout<<"#";
else if(i==ballx&&u==bally)
cout<<"O";
else if(ballz==ballx&&bally==bally)
cout<<"O";
else
cout<<" ";
}
cout<<"\n";
}
}
void wave(){
if(ballx<=10&&ballx>2){
ballx--;
}
else if(!(ballx<=10&&ballx>2))
ballx;
Sleep(50);
}
void input(){
if(kbhit()){
char c=getch();
switch(c){
case 'a':
dir=lif