急!!vb简易的小游戏代码,不要太复杂,不过石头剪刀布那种就算了

来自:    更新日期:早些时候
求vb游戏代码,急需!!! 不需要太复杂的=_=~

石头剪刀布 帮你写~~~~~~~~~~

//不知道你要什么效果,凑合着看吧
#include
#include
using namespace std;
void main()
{
srand(time(NULL));
int p1,p2;
cout<<"玩家一出:"<<endl;
switch(rand()%3)
{
case 0:
cout<<"剪刀"<<endl;
p1=0;
break;
case 1:
cout<<"石头"<<endl;
p1=1;
break;
case 2:
cout<<"布"<<endl;
p1=2;
break;
}
cout<<"玩家二出:"<<endl;
switch(rand()%3)
{
case 0:
cout<<"剪刀"<<endl;
p2=0;
break;
case 1:
cout<<"石头"<<endl;
p2=1;
break;
case 2:
cout<<"布"<<endl;
p2=2;
break;
}
if(p1==0&&p2==0)
cout<<"平局"<<endl;
else if(p1==0&&p2==1)
cout<<"玩家二赢"<<endl;
else if(p1==0&&p2==2)
cout<<"玩家一赢"<<endl;
else if(p1==1&&p2==1)
cout<<"平局"<<endl;
else if(p1==1&&p2==2)
cout<<"玩家二赢"<<endl;
else if(p1==1&&p2==0)
cout<<"玩家一赢"<<endl;
else if(p1==2&&p2==2)
cout<<"平局"<<endl;
else if(p1==2&&p2==0)
cout<<"玩家二赢"<<endl;
else if(p1==2&&p2==1)
cout<<"玩家一赢"<<endl;
}

简易三国志

创建9个command,1个timer,时间20000,9个text,6个farm。

布置如图

代码如下

Private Sub Form_Load()

Text1.Text = "100" '我方剩余士兵

Text2.Text = "170" '对方剩余士兵

Text3.Text = "180" '对方剩余士兵

Text4.Text = "200" '对方剩余士兵

Text5.Text = "500" '金钱

Text6.Text = "170" '武将血量

Text7.Text = "120" '武将血量

Text8.Text = "150" '武将血量

Text9.Text = "151" '武将血量

End Sub

Private Sub command1_click()

If Text1.Text < "0" Or Text6.Text < "0" Then

MsgBox "无法攻击!"

Else:

Do

Text1.Text = Text1.Text - 5

Text2.Text = Text2.Text - 10

Text6.Text = Text6.Text - 10 '你的攻击力暂定为200

Text7.Text = Text7.Text - 5 '你的攻击力暂定为200

Loop Until Text2.Text = "0" Or Text7.Text = "0"

MsgBox "本轮进攻胜利!"

Text5.Text = Text5.Text + 500

End If

End Sub

Private Sub command2_click()

If Text1.Text < "0" Or Text6.Text < "0" Then

MsgBox "无法攻击!"

Else:

Do

Text1.Text = Text1.Text - 10

Text3.Text = Text3.Text - 10

Text6.Text = Text6.Text - 10 '你的攻击力暂定为200

Text8.Text = Text8.Text - 10

Loop Until Text3.Text = "0" Or Text7.Text = "0"

MsgBox "本轮进攻胜利!"

Text5.Text = Text5.Text + 300

End If

End Sub

Private Sub command3_click()

If Text1.Text < "0" Or Text6.Text < "0" Then

MsgBox "无法攻击!"

Else:

Do

Text1.Text = Text1.Text - 20

Text4.Text = Text4.Text - 10

Text6.Text = Text6.Text - 10 '你的攻击力暂定为200

Text9.Text = Text9.Text - 10

Loop Until Text4.Text = "0" Or Text7.Text = "0"

MsgBox "本轮进攻胜利!"

Text5.Text = Text5.Text + 700

End If

End Sub

Private Sub command4_click()

Text1.Text = Text1.Text + 100

Text5.Text = Text5.Text - 50

If Text5.Text = "0" Then

MsgBox "没钱了!"

If Text1.Text = "0" Then

MsgBox "没兵了!"

End If

End If

End Sub

Private Sub command5_click()

Text6.Text = Text1.Text + 300

Text5.Text = Text5.Text - 100

If Text5.Text = "0" Then

MsgBox "没钱了!"

If Text6.Text = "0" Then

MsgBox "没血了!"

End If

End If

End Sub

Private Sub command6_click()

Text6.Text = Text1.Text + 1000

Text5.Text = Text5.Text - 500

If Text5.Text = "0" Then

MsgBox "没钱了!"

If Text6.Text = "0" Then

MsgBox "没可买的了!"

End If

End If

End Sub

Private Sub command7_click()

MsgBox "城市名;洛阳  黄金500 兵马170 守城大将张飞!"

End Sub

Private Sub command8_click()

MsgBox "城市名;长安  黄金400 兵马180 守城大将孙权!"

End Sub

Private Sub command9_click()

MsgBox "城市名;合肥  黄金700 兵马200 守城大将姜维!"

End Sub

Private SubIf Timer1 = "0" Then

MsgBox "台风来啦!"

Text1.Text = Text1.Text - 100

Text5.Text = Text5.Text - 100

End Sub




急!!vb简易的小游戏代码,不要太复杂,不过石头剪刀布那种就算了视频

相关评论:
  • 18894751345求vb小游戏代码 谢谢
    叶岸茅直接复制下面代码到代码框中后运行程序即可:Option Explicit Private WithEvents Timer1 As Timer Private WithEvents Label1 As Label Dim GFangXiang As Boolean Dim HWB As Single Dim She() As ShenTi Dim X As Long, Y As Long Dim ZhuangTai(23, 23) As Long Private Type ShenTi F As...

  • 18894751345求VB小游戏代码
    叶岸茅猜数字 控件:Text1 - 注意将MultiLine属性修改为True Command1 代码:Private Sub Command1_Click()Randomize Dim Num As Long Dim RightAnswer As Boolean Dim InputNum As Long Text1.Text = ""Num = Int(Rnd * 1000) + 1 RightAnswer = False Text1.Text = Text1.Text + "Here's...

  • 18894751345求VB小游戏,简单一点,越简单越好
    叶岸茅2020-08-01 求一个VB 小游戏代码 越简单越好谁帮忙写一个 网站上复制的... 7 2014-01-24 打地鼠vb编程,越简单越好 4 2013-10-01 求VB打字游戏的程序代码,越简单越好! 3 2014-08-19 谁有任务管理器的VB代码?越简单越好。。 2016-09-10 vb如何存储读取数据,越简单越好! 2010-06-16 跪求VB红黄...

  • 18894751345用Vb做一个小游戏
    叶岸茅g_lngGameTime = 0 '清空游戏耗费的秒数g_intDirection = D_DOWN '设定蛇的初始运动方向为下g_intSnakeLength = 4 '设定蛇的初始长度ReDim g_udtSnake(1 To g_intSnakeLength) '重新定义蛇的长度'定义蛇头部的数据With g_udtSnake(SNAKEONE).Snake_OldX = 530.Snake_OldY = 530.Snake_Color = vb...

  • 18894751345如何用vb做一个小游戏
    叶岸茅1、首先双击桌面图标启动 visual basic 6.0。2、然后新建工程,选择标准EXE。3、选择完工程后,点击打开,就可以新建一个exe工程了。4、然后双击 FORM1 窗体,在弹出的代码窗体中复制该代码到 Form_Click() 事件中。5、代码:If a * 100 + b * 10 + c = a ^ 3 + b ^ 3 + c ^...

  • 18894751345...随便什么都行,简单的小游戏,我会追加 的~~!!
    叶岸茅我是个初学者,期末要交个用VB制作简单的小游戏,拜托先将完整代码写出来,下面再补充说明代码中的步骤注意事项,例如要设置的窗口,按键等,请不要将属性设置也写进代码中!(最好我... 我是个初学者,期末要交个用VB制作简单的小游戏,拜托先将完整代码写出来,下面再补充说明代码中的步骤注意事项,例如要设置的窗口,...

  • 18894751345vb小游戏源代码
    叶岸茅当下小游戏主要是指在线玩的flash版本游戏,统称小游戏,其实小游戏还包含单机游戏,小型游戏机等。一般游戏大小小于10m的游戏都统称为小游戏,一些街机类小游戏。因其游戏安装简便,耐玩性强,无依赖性而广受白领及小朋友的喜爱。小游戏”这个词的型含义其实很简单,它不是一些大的游戏,不必花费更多的...

  • 18894751345vb程序小游戏的代码问题
    叶岸茅ImageIndex = -1 End If End Sub 在Timer事件中根据StopMoving(?)决定是否移动图片 Private Sub Timer1_Timer()Dim img As Image For Each img In Image1 If StopMoving(img.Index) = False Then '在这里添加移动图片的代码 - TOP '在这里添加移动图片的代码 - END End If Next End Sub ...

  • 18894751345怎么用VB精简版编写小游戏
    叶岸茅Private Sub Command0_Click()Dim x As String x = "●"If Command2.Caption = x Then Command2.Caption = "○"Else Command2.Caption = "●"End If If Command4.Caption = x Then Command4.Caption = "○"Else Command4.Caption = "●"End If If Command6.Caption = x Then Comma...

  • 18894751345求VB小游戏代码
    叶岸茅1) * Rnd + 300)y = Int((Form1.Height - 1800 + 1) * Rnd + 1000)Load Picture1(n)Picture1(n).Left = x Picture1(n).Top = y Picture1(n).Visible = True n = n + 1 if nn>=200 then timer1.enable=false ''执行语句 end if End Sub 打窗口上随机出现的砖块游戏 ...

  • 相关主题精彩

    版权声明:本网站为非赢利性站点,内容来自于网络投稿和网络,若有相关事宜,请联系管理员

    Copyright © 喜物网