-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrain.cpp
More file actions
80 lines (71 loc) · 1.3 KB
/
rain.cpp
File metadata and controls
80 lines (71 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include<bits/stdc++.h>
#include<Windows.h>
#include<time.h>
#include<thread>
#include<chrono>
#include "dohoa.h"
using std::this_thread::sleep_for;
using std::chrono::milliseconds;
//void gotoxy(int x,int y){
// HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
// COORD g = {(short)x,(short)y};
// SetConsoleCursorPosition(h,g);
//}
//void resizeConsole(int width, int height){
// HWND console = GetConsoleWindow();
// RECT r;
// GetWindowRect(console, &r);
// MoveWindow(console, r.left, r.top, width, height, TRUE);
//}
//void textcolor(int x){
// HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
// SetConsoleTextAttribute(h,x);
//}
class rain{
int x;
int y;
public:
rain();
void fall();
int getx();
int gety();
};
rain::rain(){
x = rand()%100 + 1;
y = rand()%20 + 1;
}
int rain::getx(){
return x;
}
int rain::gety(){
return y;
}
void rain::fall(){
if(y == 20){
x = rand()%100 + 1;
y = rand()%20 + 1;
}
else y++;
}
void runrain(){
int n = 50, time = 40, sl = 1;
resizeConsole(1000,600);
rain a[n];
Sleep(1000);
system("cls");
while(sl < 500){
for(int i=0; i<n; i++){
a[i].fall();
gotoxy(a[i].getx(), a[i].gety());
textcolor(3);printf("|");
}
Sleep(time);
for(int i=0; i<n; i++){
gotoxy(a[i].getx(), a[i].gety());
printf(" ");
}
sl++;
}
system("cls");
textcolor(3);
}