跪求C++大神,只需要写一个小游戏源代码,事成有现金酬谢。

作者&投稿:赫泽 (若有异议请与网页底部的电邮联系)
跪求C++小游戏的源代码,在线等!!!~

这是什么游戏啊???

像素射击:int anim abc_fade_in 0x7f010001
int anim abc_fade_out 0x7f010002
int anim abc_grow_fade_in_from_bottom 0x7f010003
int anim abc_popup_enter 0x7f010004
int anim abc_popup_exit 0x7f010005
int anim abc_shrink_fade_out_from_bottom 0x7f010006
int anim abc_slide_in_bottom 0x7f010007
int anim abc_slide_in_top 0x7f010008
int anim abc_slide_out_bottom 0x7f010009
int anim abc_slide_out_top 0x7f01000a
int anim abc_tooltip_enter 0x7f01000b
int anim abc_tooltip_exit 0x7f01000c
int attr actionBarDivider 0x7f040001
int attr actionBarItemBackground 0x7f040002
int attr actionBarPopupTheme 0x7f040003
int attr actionBarSize 0x7f040004
int attr actionBarSplitStyle 0x7f040005
int attr actionBarStyle 0x7f040006
int attr actionBarTabBarStyle 0x7f040007
int attr actionBarTabStyle 0x7f040008
int attr actionBarTabTextStyle 0x7f040009
int attr actionBarTheme 0x7f04000a
int attr actionBarWidgetTheme 0x7f04000b
int attr actionButtonStyle 0x7f04000c
int attr actionDropDownStyle 0x7f04000d
int attr actionLayout 0x7f04000e
int attr actionMenuTextAppearance 0x7f04000f
int attr actionMenuTextColor 0x7f040010
int attr actionModeBackground 0x7f040011
int attr actionModeCloseButtonStyle 0x7f040012
int attr actionModeCloseDrawable 0x7f040013
int attr actionModeCopyDrawable 0x7f040014
int attr actionModeCutDrawable 0x7f040015
int attr actionModeFindDrawable 0x7f040016
int attr actionModePasteDrawable 0x7f040017
int attr actionModePopupWindowStyle 0x7f040018
int attr actionModeSelectAllDrawable 0x7f040019
int attr actionModeShareDrawable 0x7f04001a
int attr actionModeSplitBackground 0x7f04001b
int attr actionModeStyle 0x7f04001c
int attr actionModeWebSearchDrawable 0x7f04001d
int attr actionOverflowButtonStyle 0x7f04001e
int attr actionOverflowMenuStyle 0x7f04001f
int attr actionProviderClass 0x7f040020
int attr actionViewClass 0x7f040021
int attr activityChooserViewStyle 0x7f040022
int attr alertDialogButtonGroupStyle 0x7f040023
int attr alertDialogCenterButtons 0x7f040024
int attr alertDialogStyle 0x7f040025
int attr alertDialogTheme 0x7f040026
int attr allowStacking 0x7f040027
int attr alpha 0x7f040028
int attr alphabeticModifiers 0x7f040029
int attr arrowHeadLength 0x7f04002a
int attr arrowShaftLength 0x7f04002b
int attr autoCompleteTextViewStyle 0x7f04002c
int attr autoSizeMaxTextSize 0x7f04002d
int attr autoSizeMinTextSize 0x7f04002e
int attr autoSizePresetSizes 0x7f04002f
int attr autoSizeStepGranularity 0x7f040030
int attr autoSizeTextType 0x7f040031
int attr background 0x7f040032
int attr backgroundSplit 0x7f040033
int attr backgroundStacked 0x7f040034
int attr backgroundTint 0x7f040035
int attr backgroundTintMode 0x7f040036
int attr barLength 0x7f040037
int attr borderlessButtonStyle 0x7f040038
int attr buttonBarButtonStyle 0x7f040039
int attr buttonBarNegativeButtonStyle 0x7f04003a
int attr buttonBarNeutralButtonStyle 0x7f04003b
int attr buttonBarPositiveButtonStyle 0x7f04003c
int attr buttonBarStyle 0x7f04003d
int attr buttonGravity 0x7f04003e
int attr buttonIconDimen 0x7f04003f
int attr buttonPanelSideLayout 0x7f040040
int attr buttonStyle 0x7f040041
int attr buttonStyleSmall 0x7f040042
int attr buttonTint 0x7f040043
int attr buttonTintMode 0x7f040044
int attr checkboxStyle 0x7f040045
int attr checkedTextViewStyle 0x7f040046
int attr closeIcon 0x7f040047
int attr closeItemLayout 0x7f040048
int attr collapseContentDescription 0x7f040049
int attr collapseIcon 0x7f04004a
int attr color 0x7f04004b
int attr colorAccent 0x7f04004c
int attr colorBackgroundFloating 0x7f04004d
int attr colorButtonNormal 0x7f04004e
int attr colorControlActivated 0x7f04004f
int attr colorControlHighlight 0x7f040050
int attr colorControlNormal 0x7f040051
int attr colorError 0x7f040052
int attr colorPrimary 0x7f040053
int attr colorPrimaryDark 0x7f040054
int attr colorSwitchThumbNormal 0x7f040055
int attr commitIcon 0x7f040056
int attr contentDescription 0x7f040057
int attr contentInsetEnd 0x7f040058
int attr contentInsetEndWithActions 0x7f040059
int attr contentInsetLeft 0x7f04005a
int attr contentInsetRight 0x7f04005b
int attr contentInsetStart 0x7f04005c
int attr contentInsetStartWithNavigation 0x7f04005d
int attr controlBackground 0x7f04005e
int attr coordinatorLayoutStyle 0x7f04005f
int attr customNavigationLayout 0x7f040060
int attr defaultQueryHint 0x7f040061
int attr dialogCornerRadius 0x7f040062
int attr dialogPreferredPadding 0x7f040063
int attr dialogTheme 0x7f040064
int attr displayOptions 0x7f040065
int attr divider 0x7f040066
int attr dividerHorizontal 0x7f040067
int attr dividerPadding 0x7f040068
int attr dividerVertical 0x7f040069
int attr drawableSize 0x7f04006a
int attr drawerArrowStyle 0x7f04006b
int attr dropDownListViewStyle 0x7f04006c
int attr dropdownListPreferredItemHeight 0x7f04006d
int attr editTextBackground 0x7f04006e
int attr editTextColor 0x7f04006f
int attr editTextStyle 0x7f040070
int attr elevation 0x7f040071
int attr expandActivityOverflowButtonDrawable 0x7f040072
int attr firstBaselineToTopHeight 0x7f040073
int attr font 0x7f040074
int attr fontFamily 0x7f040075
int attr fontProviderAuthority 0x7f040076
int attr fontProviderCerts 0x7f040077
int attr fontProviderFetchStrategy 0x7f040078
int attr fontProviderFetchTimeout 0x7f040079
int attr fontProviderPackage 0x7f04007a
int attr fontProviderQuery 0x7f04007b
int attr fontStyle 0x7f04007c
int attr fontVariationSettings 0x7f04007d
int attr fontWeight 0x7f04007e
int attr gapBetweenBars 0x7f04007f
int attr goIcon 0x7f040080
int attr height 0x7f040081
int attr hideOnContentScroll 0x7f040082
int attr homeAsUpIndicator 0x7f040083
int attr homeLayout 0x7f040084
int attr icon 0x7f040085
int attr iconTint 0x7f040086
int attr iconTintMode 0x7f040087
int attr iconifiedByDefault 0x7f040088
int attr imageButtonStyle 0x7f040089
int attr indeterminateProgressStyle 0x7f04008a
int attr initialActivityCount 0x7f04008b
int attr isLightTheme 0x7f04008c
int attr itemPadding 0x7f04008d
int attr keylines 0x7f04008e
int attr lastBaselineToBottomHeight 0x7f04008f
int attr layout 0x7f040090
int attr layout_anchor 0x7f040091
int attr layout_anchorGravity 0x7f040092
int attr layout_behavior 0x7f040093
int attr layout_dodgeInsetEdges 0x7f040094
int attr layout_insetEdge 0x7f040095
int attr layout_keyline 0x7f040096
int attr lineHeight 0x7f040097
int attr listChoiceBackgroundIndicator 0x7f040098
int attr listDividerAlertDialog 0x7f040099
int attr listItemLayout 0x7f04009a
int attr listLayout 0x7f04009b
int attr listMenuViewStyle 0x7f04009c
int attr listPopupWindowStyle 0x7f04009d
int attr listPreferredItemHeight 0x7f04009e
int attr listPreferredItemHeightLarge 0x7f04009f
int attr listPreferredItemHeightSmall 0x7f0400a0
int attr listPreferredItemPaddingLeft 0x7f0400a1
int attr listPreferredItemPaddingRight 0x7f0400a2
int attr logo 0x7f0400a3
int attr logoDescription 0x7f0400a4
int attr maxButtonHeight 0x7f0400a5
int attr measureWithLargestChild 0x7f0400a6
int attr multiChoiceItemLayout 0x7f0400a7
int attr navigationContentDescription 0x7f0400a8
int attr navigationIcon 0x7f0400a9
int attr navigationMode 0x7f0400aa
int attr numericModifiers 0x7f0400ab
int attr overlapAnchor 0x7f0400ac
int attr paddingBottomNoButtons 0x7f0400ad
int attr paddingEnd 0x7f0400ae
int attr paddingStart 0x7f0400af
int attr paddingTopNoTitle 0x7f0400b0
int attr panelBackground 0x7f0400b1
int attr panelMenuListTheme 0x7f0400b2
int attr panelMenuListWidth 0x7f0400b3
int attr popupMenuStyle 0x7f0400b4
int attr popupTheme 0x7f0400b5
int attr popupWindowStyle 0x7f0400b6
int attr preserveIconSpacing 0x7f0400b7
int attr progressBarPadding 0x7f0400b8
int attr progressBarStyle 0x7f0400b9
int attr queryBackground 0x7f0400ba
int attr queryHint 0x7f0400bb
int attr radioButtonStyle 0x7f0400bc
int attr ratingBarStyle 0x7f0400bd
int attr ratingBarStyleIndicator 0x7f0400be
int attr ratingBarStyleSmall 0x7f0400bf
int attr searchHintIcon 0x7f0400c0
int attr searchIcon 0x7f0400c1
int attr searchViewStyle 0x7f0400c2
int attr seekBarStyle 0x7f0400c3
int attr selectableItemBackground 0x7f0400c4
int attr selectableItemBackgroundBorderless 0x7f0400c5
int attr showAsAction 0x7f0400c6
int attr showDividers 0x7f0400c7
int attr showText 0x7f0400c8
int attr showTitle 0x7f0400c9
int attr singleChoiceItemLayout 0x7f0400ca
int attr spinBars 0x7f0400cb
int attr spinnerDropDownItemStyle 0x7f0400cc
int attr spinnerStyle 0x7f0400cd
int attr splitTrack 0x7f0400ce
int attr srcCompat 0x7f0400cf
int attr state_above_anchor 0x7f0400d0
int attr statusBarBackground 0x7f0400d1
int attr subMenuArrow 0x7f0400d2
int attr submitBackground 0x7f0400d3
int attr subtitle 0x7f0400d4
int attr subtitleTextAppearance 0x7f0400d5
int attr subtitleTextColor 0x7f0400d6
int attr subtitleTextStyle 0x7f0400d7
int attr suggestionRowLayout 0x7f0400d8
int attr switchMinWidth 0x7f0400d9
int attr switchPadding 0x7f0400da
int attr switchStyle 0x7f0400db
int attr switchTextAppearance 0x7f0400dc
int attr textAllCaps 0x7f0400dd
int attr textAppearanceLargePopupMenu 0x7f0400de
int attr textAppearanceListItem 0x7f0400df
int attr textAppearanceListItemSecondary 0x7f0400e0
int attr textAppearanceListItemSmall 0x7f0400e1
int attr textAppearancePopupMenuHeader 0x7f0400e2
int attr textAppearanceSearchResultSubtitle 0x7f0400e3
int attr textAppearanceSearchResultTitle 0x7f0400e4
int attr textAppearanceSmallPopupMenu 0x7f0400e5
int attr textColorAlertDialogListItem 0x7f0400e6
int attr textColorSearchUrl 0x7f0400e7
int attr theme 0x7f0400e8
int attr thickness 0x7f0400e9
int attr thumbTextPadding 0x7f0400ea
int attr thumbTint 0x7f0400eb
int attr thumbTintMode 0x7f0400ec
int attr tickMark 0x7f0400ed
int attr tickMarkTint 0x7f0400ee
int attr tickMarkTintMode 0x7f0400ef
int attr tint 0x7f0400f0
int attr tintMode 0x7f0400f1
int attr title 0x7f0400f2
int attr titleMargin 0x7f0400f3
int attr titleMarginBottom 0x7f0400f4
int attr titleMarginEnd 0x7f0400f5
int attr titleMarginStart 0x7f0400f6
int attr titleMarginTop 0x7f0400f7
int attr titleMargins 0x7f0400f8
int attr titleTextAppearance 0x7f0400f9
int attr titleTextColor 0x7f

#include <iostream>
using namespace std;
double shengmingli=2000;//定义主角初始生命力
int gongjili=150;//定义主角初始攻击力
int fangyuli=200;//定义主角初始防御力
int money=20;//定义主角初始金钱数量
bool guoguan;//定义是否通关判定
void wuqidian();//定义武器店函数
void yaodian();//定义药店函数
void guaiwu1();//定义小怪物函数
void guaiwu2();//定义大怪物函数
int main()
{
cout<<"欢迎你开始玩打怪物小游戏!\n";
cout<<"小镇\n";
cout<<"一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店"<<endl;
cout<<"和一家武器店。\n";
int xiaozhen;//定义选择项目
cout<<"1.去武器店"<<endl;
cout<<"2.去药品店"<<endl;
cout<<"3.去打小怪物"<<endl;
cout<<"4.去打大怪物"<<endl;
cout<<"5.退出游戏"<<endl;
cout<<"6.显示你的状态"<<endl;
cin>>xiaozhen;
while(xiaozhen!=5)//输入5时退出游戏
{
if(shengmingli<=0)//主角生命力小于等于0时游戏结束
{
cout<<"你死啦!"<<endl;
break;
}
if(guoguan)
{
cout<<"恭喜通关!"<<endl;
break;
}
if(xiaozhen==6)//输入6可检测自己的状态
{
cout<<"你的生命力:"<<shengmingli<<endl;
cout<<"你的攻击力:"<<gongjili<<endl;
cout<<"你的防御力:"<<fangyuli<<endl;
cout<<"你拥有的钱:"<<money<<endl;
}
else
switch(xiaozhen)
{
case 1 : wuqidian();break;
case 2 : yaodian();break;
case 3 : guaiwu1();break;
case 4 : guaiwu2();break;
default : cout<<"请不要乱选!"<<endl;break;
}
cin>>xiaozhen;
}
if(xiaozhen==5)
{
cout<<"正在退出游戏……"<<endl;
}
cin.get();
cin.get();
return 0;
}
void wuqidian()
{
cout<<"欢迎来到武器店!"<<endl;
cout<<"1、买小刀(1M加2攻击力)"<<endl;
cout<<"2、买短剑(2M加20攻击力)"<<endl;
cout<<"3、买大砍刀(5M加40攻击力)"<<endl;
cout<<"4、买双节棍(7M加60攻击力)"<<endl;
cout<<"5、买盾牌(2M加30防御力)"<<endl;
cout<<"6、买铠甲(5M加60防御力)"<<endl;
cout<<"7、离开武器店"<<endl;
int wuqidian;
cin>>wuqidian;
while(wuqidian!=7)//输入7时结束函数
{
switch(wuqidian)
{
case 1 : if(money<10)
cout<<"你的钱不够"<<endl;//钱不够时返回Flase
else
cout<<"购买成功!"<<endl;//钱足够时返回True
gongjili+=2;
money-=1;
break;
case 2 : if(money<80)
cout<<"你的钱不够"<<endl;
else
cout<<"购买成功!"<<endl;
gongjili+=20;
money-=80;
break;
case 3 : if(money<140)
cout<<"你的钱不够"<<endl;
else
cout<<"购买成功!"<<endl;
gongjili+=40;
money-=140;
break;
case 4 : if(money<200)
cout<<"你的钱不够"<<endl;
else
cout<<"购买成功!"<<endl;
gongjili+=60;
money-=200;
break;
case 5 : if(money<60)
cout<<"你的钱不够"<<endl;
else
cout<<"购买成功!"<<endl;
fangyuli+=30;
money-=60;
break;
fangyuli+=60;
money-=100;
break;
default : cout<<"无"<<endl;
break;
}
cin>>wuqidian;
}
if(wuqidian==7)
{ //返回main()主函数
cout<<"欢迎下次再来!"<<endl;
cout<<"欢迎你开始玩打怪物小游戏!\n";
cout<<"小镇\n";
cout<<"一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店"<<endl;
cout<<"和一家武器店。\n";
cout<<"1.去武器店"<<endl;
cout<<"2.去药品店"<<endl;
cout<<"3.去打小怪物"<<endl;
cout<<"4.去打大怪物"<<endl;
cout<<"5.退出游戏"<<endl;
cout<<"6.显示你的状态"<<endl;
}
}
/*
yaodian()的设置与wuqidian()相同,可参照阅读.
*/
void yaodian()
{
cout<<"欢迎来到药品店!"<<endl;
cout<<"1、买1号补血药(10M加200生命)"<<endl;
cout<<"2、买2号补血药(50M加1000生命力)"<<endl;
cout<<"3、买3号补血药(100M加2200生命力)"<<endl;
cout<<"4、离开药品店"<<endl;
int yaodian;
cin>>yaodian;
while(yaodian!=4)
{
switch(yaodian)
{
case 1 : if(money<10)
cout<<"你的钱不够"<<endl;
else
cout<<"购买成功!"<<endl;
shengmingli+=200;
money-=10;
break;
case 2 : if(money<50)
cout<<"你的钱不够"<<endl;
else
cout<<"购买成功!"<<endl;
shengmingli+=1000;
money-=50;
break;
case 3 : if(money<100)
cout<<"你的钱不够"<<endl;
else
cout<<"购买成功!"<<endl;
shengmingli+=2200;
money-=100;
break;
default : cout<<"无"<<endl;
break;
}
cin>>yaodian;
}
if(yaodian==4)
{
cout<<"欢迎下次再来!"<<endl;
cout<<"欢迎你开始玩打怪物小游戏!\n";
cout<<"小镇\n";
cout<<"一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店"<<endl;
cout<<"和一家武器店。\n";
cout<<"1.去武器店"<<endl;
cout<<"2.去药品店"<<endl;
cout<<"3.去打小怪物"<<endl;
cout<<"4.去打大怪物"<<endl;
cout<<"5.退出游戏"<<endl;
cout<<"6.显示你的状态"<<endl;
}
}
/*这里是两个战斗函数,使用指针来处理.避免造成内存崩溃.*/
void guaiwu1()
{
cout<<"开始与小怪物战斗!!!"<<endl;
double* g_shengmingli=new double;//定义怪物生命
int* g_gongjili=new int;//定义怪物攻击力
int* g_fangyuli=new int;//定义怪物防御力
int* g_money=new int;//定义怪物金钱
*g_shengmingli=100;
*g_gongjili=5;
*g_fangyuli=3;
*g_money=5;
double* tongji1=new double;//用来计算主角对怪物的杀伤
double* tongji2=new double;//用来计算怪物对主角的杀伤
*tongji1=0;
*tongji2=0;
int* huihe=new int;//定义回合数
*huihe=1;
cout<<"你开始对小怪物进行攻击!"<<endl;
int* xuanze=new int;
/*
攻击计算公式
杀伤=攻击力*2-防御力
玩家每回合可以选择攻击与逃跑
*/
while((*g_shengmingli)>0 && shengmingli>0 && (*xuanze)!=2)
{
cout<<"现在是"<<"第"<<*huihe<<"回合!"<<endl;
cout<<"请选择你的动作:\n";
cout<<"1、攻击\n2、逃跑\n";
cin>>*xuanze;
switch((*xuanze))
{
case 1 : cout<<"你对小怪物发动了攻击!"<<endl;
*g_shengmingli-=gongjili*2-(*g_fangyuli);
*tongji1=gongjili*2-(*g_fangyuli);
cout<<"你打掉了小怪物"<<*tongji1<<"的生命!"<<endl;
cout<<"小怪物还剩"<<(*g_shengmingli)-(*tongji1)<<"点生命"<<endl;
shengmingli-=(*g_gongjili)*2-fangyuli;
*tongji2=(*g_gongjili)*2-fangyuli;
cout<<"小怪物对你发动了攻击!"<<endl;
cout<<"小怪物打掉了你"<<*tongji2<<"的生命!"<<endl;
cout<<"你还剩"<<shengmingli-(*tongji2)<<"点生命"<<endl;break;
case 2 : cout<<"你决定逃跑!"<<endl;
cout<<"逃跑成功!"<<endl;continue;
default : cout<<"请不要乱选!"<<endl;
}
(*huihe)++;
}
if((*g_shengmingli)<=0)
{//杀死怪物后的返回
cout<<"小怪物被你杀死了!你真厉害!!!"<<endl;
money+=(*g_money);
cout<<"欢迎你开始玩打怪物小游戏!\n";
cout<<"小镇\n";
cout<<"一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店"<<endl;
cout<<"和一家武器店。\n";
cout<<"1.去武器店"<<endl;
cout<<"2.去药品店"<<endl;
cout<<"3.去打小怪物"<<endl;
cout<<"4.去打大怪物"<<endl;
cout<<"5.退出游戏"<<endl;
cout<<"6.显示你的状态"<<endl;
}
else
if(shengmingli<=0)
{//被怪物杀死后的返回
cout<<"你被小怪物杀死了!游戏结束!!!"<<endl;
}
else
if((*xuanze)==2)
{//逃跑的返回
cout<<"你逃回了小镇!"<<endl;
cout<<"欢迎你开始玩打怪物小游戏!\n";
cout<<"小镇\n";
cout<<"一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店"<<endl;
cout<<"和一家武器店。\n";
cout<<"1.去武器店"<<endl;
cout<<"2.去药品店"<<endl;
cout<<"3.去打小怪物"<<endl;
cout<<"4.去打大怪物"<<endl;
cout<<"5.退出游戏"<<endl;
cout<<"6.显示你的状态"<<endl;
}
delete g_shengmingli;
delete g_gongjili;
delete g_fangyuli;
delete g_money;
delete tongji1;
delete tongji2;
}
/*
设置均与void函数guaiwu1()相同,可参照上例阅读.
*/
void guaiwu2()
{
cout<<"开始与大怪物战斗!!!"<<endl;
double* g_shengmingli=new double;
int* g_gongjili=new int;
int* g_fangyuli=new int;
*g_shengmingli=3600;
*g_gongjili=500;
*g_fangyuli=500;
double* tongji1=new double;
double* tongji2=new double;
*tongji1=0;
*tongji2=0;
int* huihe=new int;
*huihe=1;
cout<<"你开始对大怪物进行攻击!"<<endl;
int* xuanze=new int;
while((*g_shengmingli)>0 && shengmingli>0 && (*xuanze)!=2)
{
cout<<"现在是"<<"第"<<*huihe<<"回合!"<<endl;
cout<<"请选择你的动作:\n";
cout<<"1、攻击\n2、逃跑\n";
cin>>*xuanze;
switch((*xuanze))
{
case 1 : cout<<"你对大怪物发动了攻击!"<<endl;
*g_shengmingli-=gongjili*2-(*g_fangyuli);
*tongji1=gongjili*2-(*g_fangyuli);
cout<<"你打掉了大怪物"<<*tongji1<<"的生命!"<<endl;
cout<<"大怪物还剩"<<(*g_shengmingli)-(*tongji1)<<"点生命"<<endl;
shengmingli-=(*g_gongjili)*2-fangyuli;
*tongji2=(*g_gongjili)*2-fangyuli;
cout<<"大怪物对你发动了攻击!"<<endl;
cout<<"大怪物打掉了你"<<*tongji2<<"的生命!"<<endl;
cout<<"你还剩"<<shengmingli-(*tongji2)<<"点生命"<<endl;break;
case 2 : cout<<"你决定逃跑!"<<endl;
cout<<"逃跑成功!"<<endl;continue;
default : cout<<"请不要乱选!"<<endl;
}
(*huihe)++;
}
if((*g_shengmingli)<=0)
{
cout<<"大怪物被你杀死了!你真厉害!!!"<<endl;
guoguan=true;
cout<<"欢迎你开始玩打怪物小游戏!\n";
cout<<"小镇\n";
cout<<"一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店"<<endl;
cout<<"和一家武器店。\n";
cout<<"1.去武器店"<<endl;
cout<<"2.去药品店"<<endl;
cout<<"3.去打小怪物"<<endl;
cout<<"4.去打大怪物"<<endl;
cout<<"5.退出游戏"<<endl;
cout<<"6.显示你的状态"<<endl;
}
else
if(shengmingli<=0)
{
cout<<"你被大怪物杀死了!游戏结束!!!"<<endl;
}
else
if((*xuanze)==2)
{
cout<<"你逃回了小镇!"<<endl;
cout<<"欢迎你开始玩打怪物小游戏!\n";
cout<<"小镇\n";
cout<<"一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店"<<endl;
cout<<"和一家武器店。\n";
cout<<"1.去武器店"<<endl;
cout<<"2.去药品店"<<endl;
cout<<"3.去打小怪物"<<endl;
cout<<"4.去打大怪物"<<endl;
cout<<"5.退出游戏"<<endl;
cout<<"6.显示你的状态"<<en;
}
delete g_shengmingli;
delete g_gongjili;
delete g_fangyuli;
delete tongji1;
delete tongji2;
}

#include<stdio.h>
#include<time.h>
#include<conio.h>
#include<stdlib.h>
int head=3 ,tail=0;
int main()
{
int i,j,k=0;
int zuobiao[2][80];
long start;
int direction=77;
int gamespeed;
int timeover;
int change(char qipan[20][80],int zuobiao[2][80],char direction);
zuobiao[0][tail]=1;zuobiao[1][tail]=1;zuobiao[0][1]=1;zuobiao[1][1]=2;zuobiao[0][2]=1;zuobiao[1][2]=3;zuobiao[0][head]=1;zuobiao[1][head]=4;
/*处理棋盘*/
char qipan[20][80];//定义棋盘
for(i=0;i<20;i++)
for(j=0;j<80;j++)
qipan[i][j]=' ';//初始化棋盘
for(i=0;i<80;i++)
qipan[0][i]='_';
for(i=0;i<20;i++)
qipan[i][0]='|';
for(i=0;i<20;i++)
qipan[i][79]='|';
for(i=0;i<80;i++)
qipan[19][i]='_';
qipan[1][1]=qipan[1][2]=qipan[1][3]='*';//初始化蛇的位置
qipan[1][4]='#';
printf("This is a game of a SNAKE.\nGOOD LUCK TO YOU !\n");
printf("Input your game speed,please.(e.g.300)\n");
scanf("%d",&gamespeed);

while(direction!='q')
{
system("cls");
for(i=0;i<20;i++)//打印出棋盘
for(j=0;j<80;j++)
printf("%c",qipan[i][j]);
timeover=1;
start=clock();
while(!kbhit()&&(timeover=clock()-start<=gamespeed));
if(timeover)
{
getch();
direction=getch();
}
else
direction=direction;
if(!(direction==72||direction==80||direction==75||direction==77))
{
return 0;
system("cls");
printf("GAME OVER!\n");
}
if(!change(qipan,zuobiao,direction))
{
direction='q';
system("cls");
printf("GAME OVER!\n");
}
}
return 0;
}
int change(char qipan[20][80],int zuobiao[2][80],char direction)
{
int x,y;
if(direction==72)
x=zuobiao[0][head]-1;y=zuobiao[1][head];
if(direction==80)
x=zuobiao[0][head]+1;y=zuobiao[1][head];
if(direction==75)
x=zuobiao[0][head];y=zuobiao[0][head]-1;
if(direction==77)
x=zuobiao[0][head];y=zuobiao[1][head]+1;
if(x==0||x==18||y==78||y==0)
return 0;
if(qipan[x][y]!=' ')
return 0;
qipan[zuobiao[0][tail]][zuobiao[1][tail]]=' ';
tail=(tail+1)%80;
qipan[zuobiao[0][head]][zuobiao[1][head]]='*';
head=(head+1)%80;
zuobiao[0][head]=x;
zuobiao[1][head]=y;
qipan[zuobiao[0][head]][zuobiao[1][head]]='#';
return 1;
}

这是一个双人枪战哦~

#include<iostream>
#include<cstdio>
#include<windows.h>
#include<conio.h>
using namespace std;
int SIZ = 20;
HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord;

HANDLE hCon;
enum Color { DARKBLUE = 1, DARKGREEN, DARKTEAL, DARKRED, DARKPINK, DARKYELLOW, GRAY, DARKGRAY, BLUE, GREEN, TEAL, RED, PINK, YELLOW, WHITE };
void SetColor(Color c) {
    if(hCon == NULL)
        hCon = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hCon, c);
}

SYSTEMTIME sys;

//sys.wYear,sys.wMonth,sys.wDay,sys.wHour,sys.wMinute, sys.wSecond,sys.wMilliseconds,sys.wDayOfWeek
struct PLAYER {
    int x,y;
    int hp;
    int gun;
    int direct;
} p1,p2;
int map[1005][1005];

int abs(int x) {
    if(x < 0) return -x;
    return x;
}

void locate(int x,int y) {
    coord.X=y - 1;
    coord.Y=x - 1;
    SetConsoleCursorPosition(hout,coord);
}

void print_map() {
    locate(1,1);
    SetColor(GRAY);
    for(int i = 1; i <= SIZ; i++) cout<<"¡ö";
    locate(SIZ,1);
    for(int i = 1; i <= SIZ; i++) cout<<"¡ö";
    for(int i = 2; i < SIZ; i++) {
        locate(i,1);
        cout<<"¡ö";
        locate(i,SIZ*2-1);
        cout<<"¡ö";
    }
    locate(SIZ+1,1);
    SetColor(WHITE);
}

void create_tree(int x,int y) {
    map[x][y] = map[x+1][y] = map[x-1][y] = map[x][y+1] = map[x][y-1] = 2;
}

void use_map(int x) {
    if(x == 1) {
        SIZ = 20;
        SetColor(DARKGREEN);
        map[16][6]=map[15][6]=map[17][6]=map[16][7]=map[16][5]=map[14][13]=map[13][12]=map[13][13]=2;
        for(int i = 2; i < SIZ; i++) {
            for(int j = 2; j < SIZ; j++) {
                if(map[i][j] == 2) {
                    locate(i,j*2-1);
                    cout<<"¡ö";
                }
            }
        }
        SetColor(GRAY);
        for(int i = 5; i <= 15; i++) {
            map[i][i] = 1;
            locate(i,i*2-1);
            cout<<"¡ö";
        }
        SetColor(WHITE);
    } else if(x == 2) {
        SIZ = 30;
        SetColor(GRAY);
        for(int i = 4; i <= 26; i++) {
            if(i == 13 || i == 14 ||i == 15) continue;
            map[i][4] = map[4][i] = map[26][i] = map[i][26] = 1;
        }
        for(int i = 1; i <= SIZ; i++) {
            for(int j = 1; j <= SIZ; j++) {
                if(map[i][j] == 1) {
                    locate(i,j*2-1);
                    cout<<"¡ö";
                }
            }
        }
        SetColor(DARKGREEN);
        for(int i = 10; i<=20; i++) {
            if(i == 13 || i == 17) continue;
            map[i][10] = map[10][i] = map[20][i] = map[i][20] = 2;
        }
        create_tree(5,5);
        create_tree(18,18);
        for(int i = 1; i <= SIZ; i++) {
            for(int j = 1; j <= SIZ; j++) {
                if(map[i][j] == 2) {
                    locate(i,j*2-1);
                    cout<<"¡ö";
                }
            }
        }
        SetColor(WHITE);
    }
}
void cleanbody(int x,int y);
void putbody(int x,int y,int z);

void player_init() {
    p1.hp = p2.hp = 300;
    p1.gun = p2.gun = 1;
    p1.direct = 4;
    p2.direct = 2;
    p1.x = 2;
    p1.y = 2;
    p2.x = SIZ - 1;
    p2.y = SIZ - 1;
    putbody(p1.x,p1.y,1);
    putbody(p2.x,p2.y,2);
}

void mapinit() {
    for(int i = 1; i <= SIZ; i++) {
        map[i][1] = map[1][i] = map[SIZ][i] = map[i][SIZ] = 1;
    }
}

void init() {
    printf("Use Which Map?
");
    int x;
    cin>>x;
    system("cls");
    use_map(x);
    mapinit();
    print_map();
    player_init();
}

void putbody(int x,int y,int z) {
    if(z == 1) SetColor(BLUE);
    else if(z == 2) SetColor(RED);
    locate(x,y*2-1);
    cout<<"¡ö";
    SetColor(WHITE);
}
void cleanbody(int x,int y) {
    locate(x,y*2-1);
    cout<<" ";
}
/*
    LIST
    direct:
        w 1
        a 2
        s 3
        d 4
    gun:
        usp 1
        mimigun 2
        awp 3
    block:
        void 0
        stone 1
        tree 2
        player 3
        clip 4
*/
bool judge(int x,int y) {
    if(map[x][y] == 1) return false;
    if(map[x][y] == 2) return false;
    if(map[x][y] == 3) return false;
    return true;
}

bool judge_gun(int x,int y) {
    if(map[x][y] == 1) return 0;
    if(map[x][y] == 2) return 0;
    if(map[x][y] == 3) {
        if(p1.x == x && p1.y == y) p1.hp -= 50;//´Ë´¦ÔÝʱ²»¹ÜÍþÁ¦
        else p2.hp -= 50;
        return 0;
    }
    return 1;
}

int cnt;
struct Clip {
    int x,y;
    int derect;
    int force;
    int start;
    bool flag;
} clip[1000000];
void create_clip(int y,int x,int a,int b) {
    int X,Y;
    if(y == 1) {
        if(!judge_gun(a-1,b)) return;
        X = a-1;
        Y = b;
    } else if(y == 2) {
        if(!judge_gun(a,b-1)) return;
        X = a;
        Y = b-1;
    } else if(y == 3) {
        if(!judge_gun(a+1,b)) return;
        X = a+1;
        Y = b;
    } else if(y == 4) {
        if(!judge_gun(a,b+1)) return;
        X = a;
        Y = b+1;
    }
    cnt++;
    GetLocalTime( &sys );
    clip[cnt].start = sys.wMilliseconds + sys.wSecond * 60 + sys.wHour * 3600;
    clip[cnt].x = X;
    clip[cnt].y = Y;
    if(x == 1) {
        clip[cnt].derect = p1.direct;
    } else if(x == 2) {
        clip[cnt].derect = p2.direct;
    }
}

void shoot(int x) {
    if(x == 1) {
        create_clip(p1.direct,1,p1.x,p1.y);
    } else if(x == 2) {
        create_clip(p2.direct,2,p2.x,p2.y);
    }
}

void clean_clip(int x,int y) {
    locate(x,y*2-1);
    cout<<"  ";
    locate(1,1);
}

void print_clip(int x,int y,int i) {
    if(clip[i].flag) {
        clean_clip(x,y);
        return;
    }
    locate(x,y*2-1);
    SetColor(YELLOW);
    cout<<"''";
    locate(1,1);
//  system("pause");
}

void clipmove() {
    GetLocalTime( &sys );
    int t = sys.wMilliseconds + sys.wSecond * 60 + sys.wHour * 3600;
    for(int i = 1; i <= cnt; i++) {
        if(clip[i].flag) continue;
        if(abs(clip[i].start - t) > 50) {
            clip[i].start = t;
            int x = clip[i].x;
            int y = clip[i].y;
            if(clip[i].derect==1) {
                if(!judge_gun(clip[i].x-1,clip[i].y)) {
                    clip[i].flag = 1;
                    clean_clip(x,y);
                    continue;
                }
                clean_clip(clip[i].x,clip[i].y);
                clip[i].x--;
                print_clip(clip[i].x,clip[i].y,i);
            } else if(clip[i].derect==2) {
                if(!judge_gun(clip[i].x,clip[i].y-1)) {
                    clip[i].flag = 1;
                    clean_clip(x,y);
                    continue;
                }
                clean_clip(clip[i].x,clip[i].y);
                clip[i].y--;
                print_clip(clip[i].x,clip[i].y,i);
            } else if(clip[i].derect==3) {
                if(!judge_gun(clip[i].x+1,clip[i].y)) {
                    clip[i].flag = 1;
                    clean_clip(x,y);
                    continue;
                }
                clean_clip(clip[i].x,clip[i].y);
                clip[i].x++;
                print_clip(clip[i].x,clip[i].y,i);
            } else if(clip[i].derect==4) {
                if(!judge_gun(clip[i].x,clip[i].y+1)) {
                    clip[i].flag = 1;
                    clean_clip(x,y);
                    continue;
                }
                clean_clip(clip[i].x,clip[i].y);
                clip[i].y++;
                print_clip(clip[i].x,clip[i].y,i);
            }
        }
    }
}

void judge_hp() {
    int x = p1.hp;
    int y = p2.hp;
    if(x<0 && y<0 && x > y) swap(x,y);
    if(x <= 0) {
        locate(1,1);
        system("cls");
        printf("GAME OVER!
THE WINNER IS P2!");
        Sleep(5000);
        printf("
-MADE BY Floatiy-");
        exit(0);
    } else if(y <= 0) {
        locate(1,1);
        system("cls");
        printf("GAME OVER!
THE WINNER IS P1!");
        Sleep(5000);
        printf("
-MADE BY Floatiy-");
        exit(0);
    }
}

void prog() {
    char ch;
    while(true) {
        if(kbhit()) {
            ch=getch();
            if(ch == 'w' && judge(p1.x-1,p1.y)) {
                p1.direct = 1;
                cleanbody(p1.x,p1.y);
                map[p1.x][p1.y] = 0;
                putbody(--p1.x,p1.y,1);
                map[p1.x][p1.y] = 3;
            } else if(ch == '8' && judge(p2.x-1,p2.y)) {
                p2.direct = 1;
                cleanbody(p2.x,p2.y);
                map[p2.x][p2.y] = 0;
                putbody(--p2.x,p2.y,2);
                map[p2.x][p2.y] = 3;
            } else if(ch == 'a' && judge(p1.x,p1.y-1)) {
                p1.direct = 2;
                cleanbody(p1.x,p1.y);
                map[p1.x][p1.y] = 0;
                putbody(p1.x,--p1.y,1);
                map[p1.x][p1.y] = 3;
            } else if(ch == '4' && judge(p2.x,p2.y-1)) {
                p2.direct = 2;
                cleanbody(p2.x,p2.y);
                map[p2.x][p2.y] = 0;
                putbody(p2.x,--p2.y,2);
                map[p2.x][p2.y] = 3;
            } else if(ch == 's' && judge(p1.x+1,p1.y)) {
                p1.direct = 3;
                cleanbody(p1.x,p1.y);
                map[p1.x][p1.y] = 0;
                putbody(++p1.x,p1.y,1);
                map[p1.x][p1.y] = 3;
            } else if(ch == '5' && judge(p2.x+1,p2.y)) {
                p2.direct = 3;
                cleanbody(p2.x,p2.y);
                map[p2.x][p2.y] = 0;
                putbody(++p2.x,p2.y,2);
                map[p2.x][p2.y] = 3;
            } else if(ch == 'd' && judge(p1.x,p1.y+1)) {
                p1.direct = 4;
                cleanbody(p1.x,p1.y);
                map[p1.x][p1.y] = 0;
                putbody(p1.x,++p1.y,1);
                map[p1.x][p1.y] = 3;
            } else if(ch == '6' && judge(p2.x,p2.y+1)) {
                p2.direct = 4;
                cleanbody(p2.x,p2.y);
                map[p2.x][p2.y] = 0;
                putbody(p2.x,++p2.y,2);
                map[p2.x][p2.y] = 3;
            } else if(ch == '0') {
                shoot(2);
            } else if(ch == ' ') {
                shoot(1);
            }
            Sleep(20);
        }
        clipmove();
        judge_hp();
    }
}

void welcome() {
    printf("²Ù×÷·½·¨£º
Íæ¼Ò1 wasd¿ØÖÆÒƶ¯£¬¿Õ¸ñ¹¥»÷
Íæ¼Ò2 Êý×ÖС¼üÅÌ4568¿ØÖÆÒƶ¯£¬0¹¥»÷
");
    Sleep(2000);
}

int main() {
    welcome();
    GetLocalTime( &sys );
    init();
    prog();
    return 0;
}


比俄罗斯块贪吃蛇

联系我!邮箱453849458@qq.com 游戏要求 代码要求。


C语言。求大神解从键盘上任意输入n个数(以0结束),统计正负数的个数...
include <stdio.h>;int main(int argc, char **argv) { int m, zss = 0, fss = 0, zs = 0, fs = 0; printf("请输入数字,输入0表示输入结束:\\n"); do { scanf("%d", &m); if (m > 0) { zss = zss + m; zs++; } else if (m < 0) {...

求c语言\/c++大神编写发红包问题
其中\\n表示换行的意思。它是一个转义字符,前面在讲字符常量的时候见过。其中 n 是“new line”的缩写,即“新的一行”。此外需要注意的是,printf 中的双引号和后面的分号必须是在英文输入法下。双引号内的字符串可以是英文,也可以是中文。这句话的意思是将变量 i 以十进制输出。那么现在有一个...

C语音菜鸟求大神指教 《等值数目》语言简单点。。指针不是很擅长,万...
include <stdio.h> include "stdlib.h"define NODES 9999 struct state { int f_x;int g_y;};define min(a,b) (((a)<(b))?(a):(b))void main(){ int m,n;printf("请依次输入数组f,数组g的长度:\\n");scanf("%d,%d",&m,&n);int *f=(int *)malloc(sizeof(int)*m); ...

C语言题目,求大神解答
PS p1[10] = { {1, "a", "m"}, {2, "b", "f"}, {3, "c", "m"}, {4, "d", "f"}, {5, "e", "m"} };PS p2[5] = { {1, "a", "m"}, {3, "c", "m"}, {5, "e", "m"}, {6, "f", "f"}, {7, "g", "m"} };\/\/执行删除操作 int ...

C语言 折半排序法(二分排序法)求大神补充,急需
int TwoPointsRanking(int array[], int num, size_t size, int max) { int left = 0; int right = size-1; int middle = 0; int moveindex = 0; do { if (size == max) { return -1; } if (size == 0) { array[0] = num; } else ...

C语言编程的题,求大神指教!
include<stdio.h>#include<string.h>#define max 100int main(){ int a[max][max],n,i,j; memset(a,0,max*max*4);\/\/初始化数组 scanf("%d",&n);\/\/输入构建2维数组大小 for(i=0;i<n;i++) { for(j=0;j<n;j++) { if((i+j)<n) { a[i...

关于c语言程序设计的问题求大神帮忙!万分感谢!
之所以这样做,主要是因为:在一个较大的复杂项目中,有很多人共同完成一个项目(每人可能承担其中一部分模块),其中有的模块可能是用汇编语言写的,有的模块可能是用VC写的,有的模块可能是用VB写的,有的模块可能是购买或已有的标准库模块,因此,各类源程序都需要先各自编译成目标程序文件(二进制机器...

C语言编写程序题,求大神
最简单明了的程序如下:include<stdio.h>main(){double x,y,max,min;min=max=0;for(x=0;x<=2;x+=0.2){y=2*x*x*x-3*x*x*x*x+6*x*x*x*x*x-4*x-50;printf("当x=%f时,y=%f\\n",x,y);if(y>max) max=y;if(y<min) min=y;}printf("最大值是%f\\n",max);...

求大神帮忙!! C语言看程序写代码注释,需要问题的话可以追问我,程序已...
include<stdio.h>#define n 4#define Y(x) (2*x*x*x-3*x*x*x*x+6*x*x*x*x*x-4*x+50)int main(){float y,x,loop=0,max,min;float x_max,x_min;max=min=Y(0);\/\/把Y(0)的值赋予给max,min 为50; for(loop=0;loop<=20;loop+=2)\/\/做循环 {x=(float)loop\/10...

求大神C语言编写一个简单代码,真的很简单
include<stdio.h>int main(){ printf("如果你和狗熊赛跑,你觉得会是下面那种结果?\\n"); printf(" a.你比狗熊跑得快\\n"); printf(" b.你和狗熊一样快\\n"); printf(" c.你没有狗熊快 \\n"); printf(" 请输入a或b或c后按回车键 \\n"); char choice; scanf("%c", &choice);...

崇文区13760718529: 跪求C++大神,只需要写一个小游戏源代码,事成有现金酬谢. -
王梵迪皿: #include <iostream>

崇文区13760718529: 请高手帮我做一个用C++写的一个猜拳的小游戏的程序~ -
王梵迪皿: #include#include #include void show(int input) { switch(input) { case 0:cout<<("出的是石头!"); break; case 1:cout<<("出的是剪子!"); break; case 2:cout<<("出的是布!"); break; default:; } } void compare(int inputPlay,int ...

崇文区13760718529: 求一个用c++编写的小游戏程序,如五子棋,贪吃蛇或者其他的也行... 留邮箱:jinxinyanhuo@qq.com -
王梵迪皿: #define N 200#include #include #include #define LEFT 0x4b00#define RIGHT 0x4d00#define DOWN 0x5000#define UP 0x4800#define ESC 0x011b int i,key; int score=0;/*得分*/ int gamespeed=50000;/*游戏速度自己调整*/ struct Food { int x...

崇文区13760718529: 用C++做一个简单的小游戏,最好有消灭星星的,很急啊!!!! -
王梵迪皿: #include<iostream> #include<windows.h> #include<time.h> #include<conio.h> using namespace std; // 刷新当前屏幕 inline void Refresh(char q[][22], int grade, int gamespeed){system("cls"); // 清屏int i,j;cout << endl;for(i=0;i<22;i++){...

崇文区13760718529: 跪求大神帮忙编写一个c++21点游戏的程序,新手完全不懂,真的麻烦了, -
王梵迪皿: #include#include#includeusingnamespacestd;constintNum=1000;intj=2;intrandNum[Num];intcard[52];doublecardvalue[52];stringcardname[52];stringcolor[4]={"红心","黑桃","梅花","方片"};intPcard[9];intCcard[9];intPcardnum=0;...

崇文区13760718529: 急求一个猜拳小游戏的C++程序拜托各位大神 -
王梵迪皿: #include#includevoid show(int input) { switch(input) { case 0:cout>inputPlay; if(inputPlay>=0&&inputPlay>isGoOn; }while(isGoOn!='N'||isGoOn!='n'); } 这段代码应该对你的思路会有用,自己再添加一下功能就好了.希望采纳

崇文区13760718529: 用C++编个猜数字的小游戏 -
王梵迪皿: #include #include const int max=100; void main() { srand((unsigned)time(NULL));//初始化随机数种子 int i = rand()%max; //产生一个随机数字, cout<<"请输入要猜的数字("<<<")以内:"; int number; cin>>number; while(number!=i) { if(number>i) cout<<"大了!"; else if(number cout<<"小了!"; cin>>number; } cout<<"对了!"; } 以上代码VC++6.0调试通过! 希望可以给你帮助!

崇文区13760718529: 求C/C++高手,写个贪吃蛇小游戏,谢谢啊!!! -
王梵迪皿: #define N 200 #include <graphics.h> #include <stdlib.h> #include <dos.h> #define LEFT 0x4b00 #define RIGHT 0x4d00 #define DOWN 0x5000 #define UP 0x4800 #define ESC 0x011b int i,key; int score=0;/*得分*/ int gamespeed=50000;/*游...

崇文区13760718529: 谁有c++的小游戏程序啊 ? -
王梵迪皿: 谁有c++的小游戏程序啊 Program Description=程序名称:game.c */ /*程序目的:打砖块游戏演示 */ /*written by :董大钿 *...

崇文区13760718529: 跪求用VC++编写的简单点的小游戏程序源代码,谢谢 -
王梵迪皿: #include<graphics.h>#include<stdio.h>#include<math.h>#include<conio.h>#include<stdlib.h>#include<dos.h>#define PI 3.1415926#define x0 320#define y0 240 DrawClock(int x,int y,int color) { int r=150; setcolor(color); circle(x,y,r); circle(x,y,2); } ...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网