用VB 制作一娱乐小游戏,请高人帮忙!!
'添加一个名为label1的标签控件,并将其index设为0;再添加一个名为command1的按钮控件Dim a(1 To 9) As BooleanDim win As Boolean, begin As Boolean, haveload As Boolean, start As BooleanPrivate Sub Command1_Click()start = True: begin = FalseFor i = 1 To 9 a(i) = FalseNext iForm_LoadEnd SubPrivate Sub Form_Load()a(9) = TrueLabel1(0).Visible = FalseMe.Height = 4400Me.Width = 4000Scale (0, 0)-(3, 3.3)If haveload = False Then haveload = True: start = True Command1.Top = 3: Command1.Left = 2 Command1.Width = 1: Command1.Height = 0.3 Command1.Caption = "开始" For i = 1 To 9 Load Label1(i) Next iEnd IfFor i = 1 To 9Label1(i).Height = 1Label1(i).Width = 1Label1(i).Visible = TrueLabel1(i).Top = (i - 1) \ 3Label1(i).Left = (i - 1) Mod 3Label1(i).Caption = Str(i)Label1(i).BackColor = QBColor(i)Label1(i).FontBold = TrueLabel1(i).FontSize = 40Next iLabel1(9).Caption = "": Label1(9).BackColor = vbWhiteRandomizeFor i = 1 To 500 r% = Int(9 * Rnd) + 1 Call Label1_Click(r)Next ibegin = TrueEnd SubPrivate Sub Label1_Click(index As Integer)Dim x1 As Integer, y1 As IntegerIf start = True Then If a(index) = False Then x1 = (index - 1) Mod 3: y1 = (index - 1) \ 3 If x1 - 1 > -0.2 Then If a(x1 + y1 * 3) = True Then Call yidong(x1 + y1 * 3, index) End If If x1 + 1 -0.2 Then If a(x1 + 1 + (y1 - 1) * 3) = True Then Call yidong(x1 + (y1 - 1) * 3 + 1, index) End If If y1 + 1 i Then win = False Next i If win = True And begin = True Then MsgBox ("恭喜你成功了"): begin = False: start = FalseEnd IfEnd SubSub yidong(x, index)Label1(0).Caption = Label1(index).Caption Label1(index).Caption = Label1(x).Caption Label1(x).Caption = Label1(0).Caption a(index) = True: a(x) = False Label1(0).BackColor = Label1(index).BackColor Label1(index).BackColor = Label1(x).BackColor Label1(x).BackColor = Label1(0).BackColorEnd Sub
可以用VB,简单,我在学校的时候写过一个拼图的,结果写出来之后悲催的发现,自己根本不会拼图,于是每次测试都只能让其他同学帮我拼……
随机抽取就用随机数函数…至于那个“作弊”很简单,添买号时的输入框用val(选号输入框1.text)与随机生成出来的中奖号码进行对比,if (val(选号输入框1.text) = 中奖号码1) and 中奖号码1<>0 then 中奖号码1 = 中奖号码1 - 1 elseif (val(选号输入框1.text) = 中奖号码1) and 中奖号码1 = 0 then 中奖号码1 = 9 end if 这样有个十百千位就多几个选号输入框、中奖号码,然后按照上述代码,若玩家猜对,会将正确的号码-1(0变成9,9变成8……)作弊功能你可以加个文本来记录买过的号,如果有买过的号就让号码变化 建一个文本文件:记录.txt放在生成的exe下,代码:
Dim i, j, k, l, m, n, x, y, z
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Open "记录.txt" For Input As #1
j = Input(LOF(1), 1)
Close #1
i = Text1.Text'用于记录买过的号
Open "记录.txt" For Output As #1
Print #1, j & i & "\"
Close #1
End Sub
Private Sub Command3_Click()
Timer1.Enabled = False
x = Label1.Caption
y = Label2.Caption
z = Label3.Caption
n = x & y & z
Open "记录.txt" For Input As #1
l = Input(LOF(1), 1)
Close #1
k = Split(l, "\", -1)
re: For m = 0 To UBound(k)
If n = k(m) Then
If z = 9 Then
z = 0
Else
Label3.Caption = z + 1
End If
GoTo re
End If
Next m
End Sub
Private Sub Form_Load()
Timer1.Interval = 50
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Int(9 * Rnd + 0)
Label2.Caption = Int(9 * Rnd + 0)
Label3.Caption = Int(9 * Rnd + 0)
End Sub
只会当玩家的路过= =
我插进来,问问什么是VB啊
常魏美立: Private Enum tpsSpeed QUICKLY = 0 SLOWLY = 1End Enum'定义蛇的运动方向枚举值Private Enum tpsDirec...
兴义市19259417657: 做一个VB的小游戏,难度不用太高,程序十句左右就够了,只要简单的和case语句 就足够了,希望在线的帮下忙 - ?
常魏美立: ' 锤子剪刀布 Private Sub Command1_Click() Iguess = Int(Rnd * 3) + 1 Do YouGuess = Val(InputBox("我已想好了,你出什么?(1=锤子, 2=剪刀,3=布:", "猜拳")) Loop Until YouGuess <= 3 And YouGuess >= 1 If Iguess = YouGuess ...
兴义市19259417657: 求一个VB 小游戏代码 越简单越好谁帮忙写一个 网站上复制的不要 - ?
常魏美立: Private Sub Form_Click() Dim p As POINTAPIDim Px As Integer Dim Py As Integer Call GetCursorPos(p)Px = CInt(ScaleWidth * Rnd) Py = CInt(ScaleHeight * Rnd) If Px + 500 > ScaleWidth Then Px = Px - 550 ElseIf Px - 500 < 0 Then Px = Px + ...
兴义市19259417657: ■用vb编一个简单的游戏(代码)(要详细) - ?
常魏美立: '猜数字,这个简单了吧. Private Sub Form_Load()Randomizenum = Int(Rnd * 1000)str1 = "输入一个0到999间的整数"Donum1 = Val(InputBox(str1))If num1 > num Thenstr1 = "大了"ElseIf num1 < num Thenstr1 = "小了"ElseMsgBox "恭喜您!答对了."Exit DoEnd IfLoop End Sub
兴义市19259417657: 高分急求一个简单的VB小游戏程序代码和控件,名字叫记忆牌,感谢各位了!可以用的话可以追加哦! - ?
常魏美立: 工程我已发Dim b(0 To 8)Dim m, k, nPrivate Sub Command1_Click()a = "012345678"For i = 0 To 8Randomize...
兴义市19259417657: 求VB程序高手~帮做一个简单的VB扑克牌小游戏,简单的就行,加代码解释.详谈? - ?
常魏美立: 要对应位相同才会a=a+1 你的程序 如果位置不同 即使数字一样也会b=b+1 比如 5493 与 3945 输出是0A4B 5493 与 5941 输出是1A4B 直接新建5个
兴义市19259417657: 求一个VB精简版能做的简单小游戏的制作过程和代码 - ?
常魏美立: 一个timer 一个label 在timer里写随机移动 label位置 让玩家去点击label 点中则加几分~ 你可自行调节移动的速度 来增加难度 left top这2个属性是位置 用rnd函数随机
兴义市19259417657: 如何设计一个很简单的VB程序小游戏 - ?
常魏美立: 利用vb控件做个坦克大战类的游戏即可,炮弹和坦克都用控件实现就行.唯一难点是控制控件移动以及炮弹击中目标的碰撞检测判断.给你一个简单实现代码 这是一种碰撞检测方法,下述属于简化的矩形碰撞检测,若是需要复杂碰撞可以用一个...
兴义市19259417657: 用vb编程编一个小游戏 - ?
常魏美立: '窗体添加label1控件,将index属性设置为0,使成为控件数组,再添加timer1控件 Option Explicit Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer Dim m As Integer Private Sub Form_KeyPress(...
兴义市19259417657: 如何用vb写一个这样的小游戏 - ?
常魏美立: 把代码复制到空窗体中按F5运行即可. 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(...