In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the C language based on graphics.h how to achieve Christmas tree, the article is very detailed, has a certain reference value, interested friends must read it!
Header file icon.h:
# pragma once#ifndef _ ICON_H_#define _ ICON_H_# include#include#include#include#include#include#include#pragma comment (lib, "winmm.lib") using namespace std; void init () {initgraph (600,720); setbkcolor (RGB (255,255,255)); cleardevice ();} void drawTree () {IMAGE tree; setfillcolor (RGB (255,255,255)) Setbkcolor (RGB (255,255,255); loadimage (& tree, "tree.jpg", 600,580, true); putimage (0150, & tree);} void drawDelc () {IMAGE delc; setfillcolor (RGB (255,255,255)); setbkcolor (RGB (255,255,255)); loadimage (& delc, "delc.jpg", 150,150, true) Putimage (220,0, & delc);} void Star (int x drawing int y) {IMAGE star; setfillcolor (RGB (255,255,255)); setbkcolor (RGB (255,255,255)); loadimage (& star, "star.jpg", 50,50, true); putimage (x, y, & star);} void Shining (int x drawing int y) {setbkcolor (RGB (255,255,255)) Clearrectangle (x400); Star (x, y);} void music () {mciSendString (TEXT ("open Christmas.wav alias bgm"), NULL, 0, NULL); mciSendString (TEXT ("play bgm"), NULL, 0, NULL);} void close () {getchar (); closegraph ();} # endif / /! _ ICON_H_
If the music function plays Christmas.wav music in the same directory, you need to import the music into the same directory and modify the music file directory in the function as appropriate, otherwise there will be no sound.
Image materials also need to be imported on their own.
Cpp file Christmas tree. Cpp:
# include#include#include#include#include#include "icon.h" using namespace std; int main () {init (); drawTree (); drawDelc (); Star (60,360); Star (490,360); Star (150,180); Star (400,180); music (); while (1) {music () Shining (60,360); Shining (490,360); Shining (150,180); Shining (400,180);} close (); return 0;}
Effect picture:
The above is all the content of the article "how to realize Christmas Tree based on graphics.h in C language". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.