<> start

Mainly , before , The teacher shouts to write c Language homework , There is such a request , use c Language writes a starry sky .
tell the truth , use c# It's easy to implement . But it still works easyx Go Play City Sports .

because easyx The effect is particularly good , The artists are very good .

<> background

That's it .

<> design sketch

From time to time there are meteors across the night sky , I suggest you go with it bgm.

<> code
#include<iostream> #include<graphics.h> #include<time.h> #include<process.h>
using namespace std; int windowwid = 920; int windowhig; struct STAR { int x;
int y; }; STAR star[100]; void meteor()// Demonstrate the image of a meteor , Designed to produce meteors after delay { int a = rand() %
windowwid; int b = rand() % windowhig; int tempA, tempB; tempA = a; tempB = b;
for (int i = 0; i < 40; i++) { setcolor(WHITE); setlinestyle(PS_SOLID, 1);
circle(a, b, 1); Sleep(10); a = a - 2; b = b + 1; } for (int m = 0; m < 40; m++)
{ setcolor(BLACK); setlinestyle(PS_SOLID, 1); circle(tempA, tempB, 1); Sleep(10)
; tempA = tempA - 2; tempB = tempB + 1; } } void startup()// Initialization for star coordinate data { for (
int i = 0; i < 20; i++) { star[i].x = rand() % 920; star[i].y = rand() % 593; }
} void paintstar()// adopt putpixel Print out pixels on the screen , It's like a star { for (int i = 0; i < 20; i++) {
putpixel(star[i].x, star[i].y, WHITE); } } void hidestar()// Cover the stars after the right time { for (
int i = 0; i < 20; i++) { putpixel(star[i].x, star[i].y, BLACK); } } void moon()
{ setcolor(WHITE); setfillcolor(WHITE); fillcircle(180, 100, 60); circle(180,
100, 60); int a1 = 210;// Adjustable int a2 = 80; setcolor(BLACK); setfillcolor(BLACK);
fillcircle(a1, a2, 60); circle(a1, a2, 50); } int main() { int x2; int y2;
windowhig= windowwid * 0.618; initgraph(windowwid, windowhig); moon(); for(int m
=1;m>0;m++) { startup(); paintstar(); if (m % 3 == 0) { meteor(); } Sleep(1500);
hidestar(); } system("pause"); closegraph(); }

Technology
©2019-2020 Toolsou All rights reserved,
Huawei 2021 session Hardware Engineer Logical post (FPGA) Super detailed surface !!!Vue-element-admin upgrade ui edition virtual machine VMware Download and install the most detailed tutorial !C++ Move constructor and copy constructor sound of dripping water java Backstage interview pygame Realize full screen mode and adjustable window size mysql Database setting character set configuration modification my.ini file (windows)30 What's the experience of being a junior programmer at the age of 20 C++ Multithreading programming ( Summary of common functions and parameters )python_ cherry tree