-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathduck.c
More file actions
153 lines (130 loc) · 2.42 KB
/
duck.c
File metadata and controls
153 lines (130 loc) · 2.42 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
/**void duck_open_beak()
{
printf(" _\n");
printf("__\(\)<\n");
printf("\\___)\n");
}
void duck_normal_beak()
{
printf(" _\n");
printf("__\(\)=\n");
printf("\\___)\n");
}
void duck_close_beak()
{
printf(" _\n");
printf("__\(\)>\n");
printf("\\___)\n");
}
**/
void animated_duck_close(int space, int n)
{
for(int i = 0; i <= n; i++)
printf("\n");
for(int i = 0; i <= space; i++)
{
printf(" ");
}
printf(" _\n");
for(int i = 0; i <= space; i++)
{
printf(" ");
}
printf("__\(\)>\n");
for(int i = 0; i <= space; i++)
{
printf(" ");
}
printf("\\___)\n");
}
void animated_duck_normal(int space)
{
printf("\n");
for(int i = 0; i <= space; i++)
{
printf(" ");
}
printf(" _\n");
for(int i = 0; i <= space; i++)
{
printf(" ");
}
printf("__\(\)=\n");
for(int i = 0; i <= space; i++)
{
printf(" ");
}
printf("\\___)\n");
}
void animated_duck_open(int space, int n)
{
for(int i = 0; i <= n; i++)
printf("\n");
for(int i = 0; i <= space; i++)
{
printf(" ");
}
printf(" _\n");
for(int i = 0; i <= space; i++)
{
printf(" ");
}
printf("__\(\)<\n");
for(int i = 0; i <= space; i++)
{
printf(" ");
}
printf("\\___)\n");
}
void animation_open_close(int space)
{
int frames = 0;
int start = 0;
int k = 0;
int interval = 12;
while(k < 4)
{
for( int i = start; i < frames + interval; i++)
{
animated_duck_close(i,space);
usleep(80000);
system("clear");
}
frames = frames + interval;
for(int i = frames; i < frames + interval; i++)
{
animated_duck_open(i,space);
usleep(80000);
system("clear");
}
frames = frames + interval;
start = frames;
k++;
}
}
void animation()
{
int i = 0;
while(i < 100)
{
animated_duck_open(i,1);
usleep(100000);
system("clear");
i++;
}
}
void main()
{
int i = 0;
int j;
printf("\033[?25l"); // hide the cursor
for(j = 0; j < 5; j++)
{
animation_open_close(i);
i = i + 3;
}
printf("\033[?25h"); // show the cursor
}