求助大家,我是新手,能不能用Rnd函数制作游戏
vb吧
全部回复
仅看楼主
level 13
IMBACK_CK 楼主
2014年03月13日 03点03分 1
level 13
IMBACK_CK 楼主
简单的,比如什么赌博小游戏之类的。
2014年03月13日 03点03分 2
level 13
IMBACK_CK 楼主
哪位大神能给个代码之类的,我想研究研究,谢谢。
2014年03月13日 03点03分 3
level 13
产生一个随机数,猜大小
2014年03月13日 03点03分 4
level 7
Option Explicit
Dim level As Integer
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Load()
Picture2.Left = Picture1.Left
Picture2.Top = Picture1.Top
Picture3.Left = Picture1.Left
Picture3.Top = Picture1.Top
End Sub
Private Sub Text1_Change()
Dim strlength As Integer '字符串长度
Dim randomNum As Single '随机数
Dim str1 As String
Dim a As String
Dim i, temp
strlength = 0 '每次开始时把字符串长度还原为0
a = Text1.Text
For i = 1 To Len(a) '代表字符串的长度
temp = Asc(Mid(a, i, 1)) '挨个取字符
If temp > 255 Or temp < 0 Then '不是asc码
strlength = strlength + 2
Else
strlength = strlength + 1
End If
Next i
strlength = strlength / 2
Select Case strlength
Case 0 To 9
Picture1.Visible = True
Picture2.Visible = False
Picture3.Visible = False
Label2.Caption = "慢慢说。你还有" & Str(30 - strlength) & "个字可以说"
level = 1
Case 10 To 19
If level = 1 Then
randomNum = Rnd * 10 '得到随机数
If randomNum <= 10 And randomNum > 9 Then
Text1.Enabled = False
Label2.Caption = "很抱歉这是个误会,,,"
Command1.Visible = True
Command1.Caption = "您可以离开了"
End If
level = 2
Else
Picture1.Visible = False
Picture2.Visible = True
Picture3.Visible = False
str1 = "怎么还没有说完~"
Label2.Caption = str1 & "你还有" & Str(30 - strlength) & "个字可以说"
End If
Case 20 To 29
If level = 2 Then
randomNum = Rnd * 10
If randomNum <= 10 And randomNum > 9 Then
Text1.Enabled = False
Label2.Caption = "很抱歉这是个误会,,,"
Command1.Visible = True
Command1.Caption = "您可以离开了"
End If
level = 3
Else
Picture1.Visible = False
Picture2.Visible = False
Picture3.Visible = True
str1 = "我已经不耐烦了@"
Label2.Caption = str1 & "你还有" & Str(30 - strlength) & "个字可以说"
End If
Case Else
Command1.Visible = True
Text1.Enabled = False
Label2.Caption = "你已经没有机会啦!"
Command1.Caption = "交钱吧,肇事犯!"
End Select
End Sub
2014年03月13日 04点03分 5
万分感谢!
2014年03月13日 04点03分
这代码=_=老早了一个教程里
2014年03月13日 04点03分
回复 卡扎菲猫 :嗯, 我在学习中, 就贴出来啦。。 我还在看哪个文档《VB经典教程,控件使用大全,》
2014年03月13日 04点03分
回复 卡扎菲猫 :大神。能不能给个比这个稍微简单点的?
2014年03月13日 04点03分
level 7
这个是说,
一个肇事者 一个警察
警察给肇事者 解释的机会
如果 肇事者说的话 能打动 警察 就 不罚款
否则 就要罚款
里面的程序 是在 肇事者每次 说一句话的时候, 会产生一个随机数,
如果 这个数在 0,9 之间 就代表打动的警察, 就不罚款
否则 就罚款
2014年03月13日 04点03分 6
嗯嗯。我好好研究研究
2014年03月13日 04点03分
level 11
或者可以做简单的姓名大作战游戏,
2014年03月13日 10点03分 7
求详细…[乖][乖][乖][乖]
2014年03月13日 10点03分
回复 IMBACK_CK :额。。。就是输入两个名字,随机他们的血量,然后随机攻击力等等。。
2014年03月13日 11点03分
吧务
level 13
猜价格
2014年03月13日 10点03分 8
1