900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > Dev-C++游戏创作之金山打字通(附带音乐)

Dev-C++游戏创作之金山打字通(附带音乐)

时间:2020-09-19 10:32:14

相关推荐

Dev-C++游戏创作之金山打字通(附带音乐)

Hi!大家好!我是你们的编程小王子

最近一直拖着没更新,因为实在是没什么游戏思路。但是终于搞出来一个

金山打字通相信很多小伙伴们都认识,所以东西我就不多介绍,今天主要讲解音乐的播放(超级简单的)!

//这里提醒大家一下,这一个音乐播放函数,只限于.wav文件//是因为C++最基础的音乐只支持Windows自带的wav格式播放//有需要的话可以下载一个音乐格式转换器,吧mp3转换一下DWORD WINAPI FunctionName(LPVOID lpParamte) {DWORD OBJ;sndPlaySound(TEXT("MusicName.wav"), SND_FILENAME|SND_ASYNC);return 0;}

然后还要一个调用的公式

HANDLE MFUN;MFUN= CreateThread(NULL, 0, FunctionName, NULL, 0, NULL);

这样就能播放音乐啦

这个我相信大家都理解了,接下来上代码

#include<bits/stdc++.h>#include<windows.h>#include<unistd.h>#include<conio.h>using namespace std;unsigned long long wrong;DWORD WINAPI Type(LPVOID lpParamte) {DWORD OBJ;sndPlaySound(TEXT("Type.wav"), SND_FILENAME|SND_ASYNC);return 0;}DWORD WINAPI Error(LPVOID lpParamte) {DWORD OBJ;sndPlaySound(TEXT("error.wav"), SND_FILENAME|SND_ASYNC);return 0;}void SetPos(int x,int y) {HANDLE Handle;COORD pos= {y,x};Handle=GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleCursorPosition(Handle,pos);}void HideCursor() {CONSOLE_CURSOR_INFO cursor_info= {1,0};SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);}void arti(string article) {system("cls");SetPos(15,105);cout<<"结束后输入Enter"<<endl;SetPos(0,0);article+="\n";cout<<article<<endl;HANDLE MFUN;for(int i=0; i<article.size(); i++) {char g=getch();HideCursor();if(i==article.size()-1) break;while(g!=article[i]) {if(i==article.size()-1) break;MFUN= CreateThread(NULL, 0, Error, NULL, 0, NULL);++wrong;g=getch();}MFUN= CreateThread(NULL, 0, Type, NULL, 0, NULL);cout<<g;if(i==article.size()-1) break;}system("cls");cout<<endl<<endl;cout<<"Wrong times: "<<wrong<<endl;cout<<"congratulations!You finished another article!"<<endl;}int main() {char select;cout<<"金 山打 字 通 "<<endl;cout<<" 英文 模式"<<endl;cout<<"1. The cat and mice"<<endl;cout<<" 2.make the finishing point"<<endl;cout<<" 3. help others "<<endl;cout<<" 4. find your own skills "<<endl;cout<<" 5. The fox and the cock "<<endl;cout<<" 6. 切换模式"<<endl;select=getch();if(select=='1') {arti("Long ago, there was a big cat in the house. He caught many mice while they were stealing food.One day the mice had a meeting to talk about the way to deal with their common enemy. Some said this, and some said that. At last a young mouse got up, and said that he had a good idea.'We could tie a bell around the neck of the cat. Then when he comes near, we can hear the sound of the bell, and run away.'Everyone approved of this proposal, but an old wise mouse got up and said, 'That is all very well, but who will tie the bell to the cat?' The mice looked at each other, but nobody spoke.");return 0;} else if(select=='2') {arti("Mr. Li is a good painter. One day he draws a beautiful dragon without eyes.Mr. Zhou looks at the picture and says, 'The dragon has no eyes. It isn't a good picture.'But Mr. Li smiles and says, 'If I add eyes to the dragon, it will fly away.'Mr. Zhou shakes his head and says, 'You are boasting. I don't believe you.'Mr. Li isn't angry. He holds the paintbrush and adds eyes to the dragon. Wow! The dragon really flies.");return 0;} else if(select=='3') {arti("One day, a poor man is taking a bag of rice to a town. The rice is on the back of his horse but it falls down. The rice is too heavy to lift and he doesn’t know what to do. He only hopes someone can give him some help.After a while, a man riding a horse comes. But he is a rich man living nearby. The poor man hopes another farmer will come. But the rich man sees him and says to him, 'You need my help, right?' And he helps the poor man lift the rice onto the horse’s back.'Sir, how can I repay you?' the poor man says.'It’s easy, when you see anyone else in trouble, do the same for him.'");return 0;} else if(select=='4') {arti("On the third day after he was born, Little Elephant went with his mother to the banks of a stream, and there he saw a bird in the sky flying here and there. Little Elephant said: 'If I could fly, I could see even more things, it would be great!'In order to learn to fly, Little Elephant climbed a tree and, with a yelp of 'Ouch!'. fell heavily to the ground.Seeing this, the snake said: 'Little elephant, we all have our own abilities. I can't fly, but I can sleep in a tree.'Lion said: 'I also can't fly, but I can jump across a wide river.'Tiger said, 'I can't fly, but I can swim!'Little Elephant's father and mother said to him, 'We elephants have great strength, incomparably greater than little birds.'Little Elephant understood. He used his long nose as a hook and moved a large branch.");return 0;} else if(select=='5') {arti("One morning a fox sees a cock.He thinks,This is my breakfast.He comes up to the cock and says, 'know you can sing very well.Can you sing for me?'The cock is glad.He closes his eyes and begins to sing.'he fox sees that and caches him in his mouth and carries him away. The people in the field see the fox.They cry,'Look,look!The fox is carrying the cock away.'The cock says to the fox,'Mr Fox,do you understand?The people say you are carrying their cock away.Tell them it is yours.Not theirs.' The fox opens his mouth ang says,'The cock is mine,not yours.'Just then the cock runs away from the fox and flies into the tree.");return 0;} else if(select=='6') {system("cls");cout<<"金 山打 字 通 "<<endl;cout<<" 中文 模式"<<endl;cout<<" 1. 故事与星星 "<<endl;cout<<" 2. 快乐的秋天 "<<endl;cout<<" 3. 下雪啦 "<<endl;cout<<" 4. 登华山 "<<endl;select=getch();if(select=='1') {arti("故事就像天上的星星,数也数不清。故事有长有短;星星有大有小。故事有平淡的,精彩的,更精彩的;星星有暗的,亮的,更亮的,故事是永恒的,星星也是永恒的。星星印在孩子的眼里,故事留在孩子心里。星星会滑落吗?不,它永远挂在天空;故事会消失吗?不,它永远留在人心中。即使夜色多浓,星星依然保持着内心的明亮。即使世界更精彩,故事依然照亮孩子的心灵。");return 0;} else if(select=='2') {arti("秋天,如果你来到森林公园,你就能看到一片片落叶,如果你有机会来到田野,就能看到一片丰收的景象,小伙伴们!让我们行动起来吧,去寻找秋天的快乐。来到公园,小伙伴们有的在摘果实,有的在收集各种各样的树叶,落叶像一封封邮件,寄啊寄啊,寄走了夏天的告别,秋天的到来。小喜鹊叼来了树枝造房子,小青蛙在加紧挖洞,准备过冬,小松鼠找来松果当粮食,松柏穿上了厚厚的衣服。来到田野,是一个丰收的景象,高粱像一个个喝醉的大汉,稻谷就像害羞的小姑娘。秋天,是一个丰收的季节,我喜欢秋天。");return 0;} else if(select=='3') {arti("清晨,我来到窗前,透过玻璃向外望去,展此刻眼前的是一个银色的世界,啊!下雪啦!雪花落在了玻璃上融化了的图案,有的像一朵朵小花,有的像高高的宝塔,有的像栩栩如生的小雪人。我迫不及待地地跑下楼,投入了雪花的怀抱,哇!多美妙的雪的世界呀!雪花落在了楼顶上,像是给房屋换上了一件漂亮的新衣;雪花落在了小树上,像是给小树穿上了圣洁美丽的裙纱;雪花落在了小路上,像是给小路铺上了一层柔软而洁白的地毯。小朋友们也来到了户外,在雪地上快乐地游戏着,有的在滚雪球,有的在打雪仗,有的在推雪人,我最喜爱大家堆朔的小白兔,长长的耳朵,红红的眼睛,胖乎乎的可爱极了,在这雪的家园小朋友们玩的真快乐啊!我爱这洁白的雪花,我爱这雪花的世界!");return 0;} else if(select=='4') {arti("五岳的西岳--华山,是我爬过最高的山,海拔约2160米。那里山势险峻,四周都是悬崖峭壁,一棵树也没有,百鸟不息。在山上,太阳好像离你很近,白云好像很低,果然是只有天在上,更无山与齐。举头红日近,回首白去低。一路上,华山的奇峰、怪石、云海、鸣泉、飞瀑、古迹遍布,三面临空的鹞子翻身,以及在峭壁绝崖上凿出的千尺幢、老君梨沟、上天梯、苍龙岭等到都是上山的绝险要路,几乎让我放下征服这些险上加险的险境。但是,随着一颗不想放下的心飞上了山顶,我最后还是战胜了难关,登上山顶。感受奇峰峭壁、险径危石的险,品味鬼斧神工的美,华山游多么令我难忘。");return 0;}} else if(select=='7') {arti("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");return 0;} else if(select=='8') {arti("123");return 0;}return 0;}

这个文章是我网上收集的,大家也可以自己多去收集一下

大佬们可以尝试把英文模式和中文模式做成可以随意切换的那种

这些音乐的链接如下

第一个:Dev-C++游戏创作之金山打字通-其他文档类资源-CSDN下载

第二个:Dev-C++游戏创作之金山打字通-其他文档类资源-CSDN下载

OK!我会尽快更新的,希望大家能支持我一下

你们懂的,点个赞呗,拜拜ヾ( ̄▽ ̄)Bye~Bye~

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。