用VB制作个小游戏。急急急急急~!!!马上就要交了,随便什么都行,简单的小游戏,我会追加 的~~!!
读书不努力,竟然还有些所谓的高手在害你。。。。。。。。。。。。
Private a As Long '用于计时
'timer的时间设为1000,事件写入 a = a + 1
Private Sub Timer1_Timer()
a = a + 1
End Sub
Private Sub Form_Load()
timer1.Enabled = 0
End Sub
Private Sub CommandButton1_Click()
a = Int(Rnd() * 100) '随机一个1~99的整数
timer1.Enabled = 1
Do
b = Val(InputBox("输入数字"))
If a = b Then
timer1.Enabled = 0
MsgBox "猜对了,你用了" & a & "秒"
Exit Do
ElseIf a > b Then
MsgBox "太小了"
Else
MsgBox "太大了"
End If
Loop
End Sub
QUICKLY = 0
SLOWLY = 1
End Enum
'定义蛇的运动方向枚举值
Private Enum tpsDirection
D_UP = 38
D_DOWN = 40
D_LEFT = 37
D_RIGHT = 39
End Enum
'定义运动区域4个禁区的枚举值
Private Enum tpsForbiddenZone
FZ_TOP = 30
FZ_BOTTOM = 5330
FZ_LEFT = 30
FZ_RIGHT = 5730
End Enum
'定义蛇头及身体初始化数枚举值
Private Enum tpsSnake
SNAKEONE = 1
SNAKETWO = 2
SNAKETHREE = 3
SNAKEFOUR = 4
End Enum
'定义蛇宽度的常量
Private Const SNAKEWIDTH As Integer = 100
'该过程用于显示游戏信息
Private Sub Form_Load()
Me.Show
Me.lblTitle = "BS贪食蛇 — (版本 " & App.Major & "." & App.Minor & "." & App.Revision & ")"
Me.Caption = Me.lblTitle.Caption
frmSplash.Show 1
End Sub
'该过程用于使窗体恢复原始大小
Private Sub Form_Resize()
If Me.WindowState <> 1 Then
Me.Caption = ""
Me.Height = 6405 '窗体高度为 6405 缇
Me.Width = 8535 '窗体宽度为 8535 缇
Me.Left = (Screen.Width - Width) \ 2
Me.Top = (Screen.Height - Height) \ 2
End If
End Sub
'该过程用于重新开始开始游戏
Private Sub cmdGameStart_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Beep
msg = MsgBox("您确认要重新开始游戏吗?", 4 + 32, "BS贪食蛇")
If msg = 6 Then Call m_subGameInitialize
End Sub
'该过程用于暂停/运行游戏
Private Sub chkPause_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Me.chkPause.Caption = "暂停游戏(&P)" Then
Me.tmrSnakeMove.Enabled = False
Me.tmrGameTime.Enabled = False
Me.picMoveArea.Enabled = False
Me.lblPauseLab.Visible = True
Me.chkPause.Caption = "继续游戏(&R)"
Else
Me.tmrSnakeMove.Enabled = True
Me.tmrGameTime.Enabled = True
Me.picMoveArea.Enabled = True
Me.lblPauseLab.Visible = False
Me.chkPause.Caption = "暂停游戏(&P)"
End If
End Sub
'该过程用于显示游戏规则
Private Sub cmdGameRules_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Beep
MsgBox " BS贪食蛇:一个规则最简单的趣味游戏,您将用键盘" & Chr(13) & _
"上的4个方向键来控制蛇的运动方向。在运动过程中蛇" & Chr(13) & _
"不能后退,蛇的头部也不能接触到运动区域的边线以外" & Chr(13) & _
"和蛇自己的身体,否则就游戏失败。在吃掉随机出现的" & Chr(13) & _
"果子后,蛇的身体会变长,越长难度越大。祝您好运!!", 0 + 64, "游戏规则"
End Sub
'该过程用于显示游戏开发信息
Private Sub cmdAbout_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Beep
MsgBox "BS贪食蛇" & "(V-" & App.Major & "." & App.Minor & "版本)" & Chr(13) & Chr(13) & _
"" & Chr(13) & Chr(13) & _
"由PigheadPrince设计制作" & Chr(13) & _
"CopyRight(C)2002,BestSoft.TCG", 0, "关于本游戏"
End Sub
'该过程用于退出游戏
Private Sub cmdExit_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Beep
msg = MsgBox("您要退出本游戏吗?", 4 + 32, "BS贪食蛇")
Select Case msg
Case 6
End
Case 7
Me.chkWindowButton(2).Value = 0
Exit Sub
End Select
End Sub
'该过程用于拖动窗体_(点击图标)
Private Sub imgWindowTop_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage Me.hwnd, WM_SYSCOMMAND, SC_MOVE, 0
End Sub
'该共用过程用于处理窗体控制按钮组的相关操作_(锁定、最小化、退出)
Private Sub chkWindowButton_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button <> 1 Then Exit Sub
Select Case Index
Case 0 '锁定窗体
If Me.chkWindowButton(0).Value = 1 Then
Me.imgWindowTop.BorderStyle = 0
Me.imgWindowTop.Enabled = False
Else
Me.imgWindowTop.BorderStyle = 1
Me.imgWindowTop.Enabled = True
End If
Case 1 '最小化
Me.WindowState = 1
Me.chkWindowButton(1).Value = 0
Me.Caption = "BS贪食蛇 — (V-" & App.Major & "." & App.Minor & "版本)"
Case 2 '退出
Beep
msg = MsgBox("您要退出本游戏吗?", 4 + 32, "BS贪食蛇")
Select Case msg
Case 6
End
Case 7
Me.chkWindowButton(2).Value = 0
Exit Sub
End Select
End Select
End Sub
'该过程用于设置蛇运动速度的快慢
Private Sub hsbGameSpeed_Change()
Me.tmrSnakeMove.Interval = Me.hsbGameSpeed.Value
End Sub
'该过程用于通过键盘的方向键改变蛇的运动方向
Private Sub picMoveArea_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case g_intDirection
Case D_UP
If KeyCode = D_DOWN Then Exit Sub
Case D_DOWN
If KeyCode = D_UP Then Exit Sub
Case D_LEFT
If KeyCode = D_RIGHT Then Exit Sub
Case D_RIGHT
If KeyCode = D_LEFT Then Exit Sub
End Select
g_intDirection = KeyCode
End Sub
'该计时循环过程用于计算游戏耗费的秒数并显示
Private Sub tmrGameTime_Timer()
g_lngGameTime = g_lngGameTime + 1
Me.lblGameTime.Caption = g_lngGameTime & "秒"
End Sub
'该计时循环过程用于控制蛇的行动轨迹
Private Sub tmrSnakeMove_Timer()
Dim lngSnakeX As Long, lngSnakeY As Long, lngSnakeColor As Long
Dim lngPointX As Long, lngPointY As Long, lngPointColor As Long
Randomize
Me.picMoveArea.SetFocus
Me.picMoveArea.Cls
'确认蛇头的运动方向并获取新的位置
Select Case g_intDirection
Case D_UP '向上运动
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_OldX
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_OldY
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_CurY - SNAKEWIDTH
Case D_DOWN '向下运动
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_OldX
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_OldY
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_CurY + SNAKEWIDTH
Case D_LEFT '向左运动
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_OldX
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_CurX - SNAKEWIDTH
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_OldY
Case D_RIGHT '向右运动
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_OldX
g_udtSnake(SNAKEONE).Snake_CurX = g_udtSnake(SNAKEONE).Snake_CurX + SNAKEWIDTH
g_udtSnake(SNAKEONE).Snake_CurY = g_udtSnake(SNAKEONE).Snake_OldY
End Select
'根据新的位置绘制蛇头
lngSnakeX = g_udtSnake(SNAKEONE).Snake_CurX
lngSnakeY = g_udtSnake(SNAKEONE).Snake_CurY
lngSnakeColor = g_udtSnake(SNAKEONE).Snake_Color
Me.picMoveArea.PSet (lngSnakeX, lngSnakeY), lngSnakeColor
'移动蛇身体其他部分的位置
For i = 2 To g_intSnakeLength
g_udtSnake(i).Snake_CurX = g_udtSnake(i - 1).Snake_OldX
g_udtSnake(i).Snake_CurY = g_udtSnake(i - 1).Snake_OldY
lngSnakeX = g_udtSnake(i).Snake_CurX
lngSnakeY = g_udtSnake(i).Snake_CurY
lngSnakeColor = g_udtSnake(i).Snake_Color
Me.picMoveArea.PSet (lngSnakeX, lngSnakeY), lngSnakeColor
Next i
'更新蛇旧的坐标位置
For j = 1 To g_intSnakeLength
g_udtSnake(j).Snake_OldX = g_udtSnake(j).Snake_CurX
g_udtSnake(j).Snake_OldY = g_udtSnake(j).Snake_CurY
Next j
'判断蛇在移动中是否到了禁区而导致游戏失败
If m_funMoveForbiddenZone(g_udtSnake(SNAKEONE).Snake_CurX, g_udtSnake(SNAKEONE).Snake_CurY) Then
Beep
MsgBox "您的蛇移动到了禁区,游戏失败!", 0 + 16, "BS贪食蛇"
Me.tmrSnakeMove.Enabled = False
Me.tmrGameTime.Enabled = False
Me.picMoveArea.Visible = False
Exit Sub
End If
'判断蛇在移动中是否碰到了自己的身体而导致游戏失败
If m_funTouchSnakeBody(g_udtSnake(SNAKEONE).Snake_CurX, g_udtSnake(SNAKEONE).Snake_CurY) Then
Beep
MsgBox "您的蛇在移动中碰到了自己的身体,游戏失败!", 0 + 16, "BS贪食蛇"
Me.tmrSnakeMove.Enabled = False
Me.tmrGameTime.Enabled = False
Me.picMoveArea.Visible = False
Exit Sub
End If
'判断蛇是否吃到了果子
If m_funEatPoint(g_udtSnake(SNAKEONE).Snake_CurX, g_udtSnake(SNAKEONE).Snake_CurY) Then
'累加玩家的得分并刷新得分显示
g_intPlayerScore = g_intPlayerScore + 1
Me.lblYourScore.Caption = g_intPlayerScore & "分"
Call m_subAddSnake '加长蛇的身体
Call m_subGetPoint '获取下一个果子的位置和颜色
Else
'绘制果子
lngPointX = g_udtPoint.Point_X
lngPointY = g_udtPoint.Point_Y
lngPointColor = g_udtPoint.Point_Color
Me.picMoveArea.PSet (lngPointX, lngPointY), lngPointColor
End If
End Sub
'该私有子过程用于初始化游戏
Private Sub m_subGameInitialize()
Erase g_udtSnake '清空蛇的结构数组
g_intPlayerScore = 0 '清空玩家的得分
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 = vbBlack
End With
'定义蛇身第2节的数据
With g_udtSnake(SNAKETWO)
.Snake_OldX = 530
.Snake_OldY = 430
.Snake_Color = vbGreen
End With
'定义蛇身第3节的数据
With g_udtSnake(SNAKETHREE)
.Snake_OldX = 530
.Snake_OldY = 330
.Snake_Color = vbYellow
End With
'定义蛇身第4节的数据
With g_udtSnake(SNAKEFOUR)
.Snake_OldX = 530
.Snake_OldY = 230
.Snake_Color = vbRed
End With
Me.picMoveArea.Visible = True
Me.lblYourScore.Caption = g_intPlayerScore & "分"
Me.lblGameTime.Caption = g_lngGameTime & "秒"
Me.tmrSnakeMove.Interval = Me.hsbGameSpeed.Value
Me.tmrSnakeMove.Enabled = True
Me.tmrGameTime.Enabled = True
Call m_subGetPoint '获取第一个果子的位置和颜色
End Sub
'该私有子过程用于返回获取的果子的位置和颜色信息
Private Sub m_subGetPoint()
Dim lngRedValue As Long, lngGreenValue As Long, lngBlueValue As Long
Dim lngPointX As Long, lngPointY As Long, lngPointColor As Long
'随机获取果子的颜色
lngRedValue = Int((255 - 0 + 1) * Rnd + 0)
lngGreenValue = Int((255 - 0 + 1) * Rnd + 0)
lngBlueValue = Int((255 - 0 + 1) * Rnd + 0)
lngPointColor = RGB(lngRedValue, lngGreenValue, lngBlueValue)
'随机获取果子的位置
lngPointX = Int((FZ_LEFT - FZ_RIGHT + 1) * Rnd + FZ_RIGHT)
lngPointY = Int((FZ_TOP - FZ_BOTTOM + 1) * Rnd + FZ_BOTTOM)
Me.PSet (lngPointX, lngPointY), lngPointColor
'设置函数返回值
With g_udtPoint
.Point_X = lngPointX
.Point_Y = lngPointY
.Point_Color = lngPointColor
End With
End Sub
'该私有子过程用于加长蛇的身体
Private Sub m_subAddSnake()
Dim udtSnakeTemp() As Snake
Dim lngSnakeX As Long, lngSnakeY As Long, lngSnakeColor As Long
'备份蛇原先身体的数据并使蛇的身体加长
ReDim udtSnakeTemp(1 To g_intSnakeLength)
For k = 1 To g_intSnakeLength
With udtSnakeTemp(k)
.Snake_CurX = g_udtSnake(k).Snake_CurX
.Snake_CurY = g_udtSnake(k).Snake_CurY
.Snake_OldX = g_udtSnake(k).Snake_OldX
.Snake_OldY = g_udtSnake(k).Snake_OldY
.Snake_Color = g_udtSnake(k).Snake_Color
End With
Next k
g_intSnakeLength = g_intSnakeLength + 1
ReDim g_udtSnake(g_intSnakeLength)
'将备份蛇身体的数据返回到加长的蛇身数组中
For l = 1 To g_intSnakeLength - 1
With g_udtSnake(l)
.Snake_CurX = udtSnakeTemp(l).Snake_CurX
.Snake_CurY = udtSnakeTemp(l).Snake_CurY
.Snake_OldX = udtSnakeTemp(l).Snake_OldX
.Snake_OldY = udtSnakeTemp(l).Snake_OldY
.Snake_Color = udtSnakeTemp(l).Snake_Color
End With
Next l
'写入新加入的身体数据
Select Case g_intDirection
Case D_UP
With g_udtSnake(g_intSnakeLength)
.Snake_OldX = g_udtSnake(g_intSnakeLength - 1).Snake_CurX + SNAKEWIDTH
.Snake_OldY = g_udtSnake(g_intSnakeLength - 1).Snake_CurY
.Snake_Color = g_udtPoint.Point_Color
End With
Case D_DOWN
With g_udtSnake(g_intSnakeLength)
.Snake_OldX = g_udtSnake(g_intSnakeLength - 1).Snake_CurX - SNAKEWIDTH
.Snake_OldY = g_udtSnake(g_intSnakeLength - 1).Snake_CurY
.Snake_Color = g_udtPoint.Point_Color
End With
Case D_LEFT
With g_udtSnake(g_intSnakeLength)
.Snake_OldX = g_udtSnake(g_intSnakeLength - 1).Snake_CurX
.Snake_OldY = g_udtSnake(g_intSnakeLength - 1).Snake_CurY + SNAKEWIDTH
.Snake_Color = g_udtPoint.Point_Color
End With
Case D_RIGHT
With g_udtSnake(g_intSnakeLength)
.Snake_OldX = g_udtSnake(g_intSnakeLength - 1).Snake_CurX
.Snake_OldY = g_udtSnake(g_intSnakeLength - 1).Snake_CurY - SNAKEWIDTH
.Snake_Color = g_udtPoint.Point_Color
End With
End Select
lngSnakeX = g_udtSnake(g_intSnakeLength).Snake_CurX
lngSnakeY = g_udtSnake(g_intSnakeLength).Snake_CurY
lngSnakeColor = g_udtSnake(g_intSnakeLength).Snake_Color
Me.picMoveArea.PSet (lngSnakeX, lngSnakeY), lngSnakeColor
End Sub
'该自定义函数用于返回运动的蛇是否到达禁区而导致游戏失败
Private Function m_funMoveForbiddenZone(SnakeX As Long, SnakeY As Long) As Boolean
If (SnakeX >= FZ_LEFT And SnakeX <= FZ_RIGHT) And (SnakeY >= FZ_TOP And SnakeY <= FZ_BOTTOM) Then
m_funMoveForbiddenZone = False
Else
m_funMoveForbiddenZone = True
End If
End Function
'该自定义函数用于返回运动的蛇是否碰到自己的身体而导致游戏失败
Private Function m_funTouchSnakeBody(SnakeX As Long, SnakeY As Long) As Boolean
For m = 2 To g_intSnakeLength
If SnakeX = g_udtSnake(m).Snake_CurX And SnakeY = g_udtSnake(m).Snake_CurY Then
m_funTouchSnakeBody = True
Exit For
Else
m_funTouchSnakeBody = False
End If
Next m
End Function
'该自定义函数用于返回运动的蛇是否吃到了果子
Private Function m_funEatPoint(SnakeX As Long, SnakeY As Long) As Boolean
If Abs(SnakeX - g_udtPoint.Point_X) <= SNAKEWIDTH And Abs(SnakeY - g_udtPoint.Point_Y) <= SNAKEWIDTH Then
m_funEatPoint = True
Else
m_funEatPoint = False
End If
End Function
'(API函数调用过程_用以实现无标题窗体的拖动操作)---------------------------------
'RleaseCapture函数用以释放鼠标捕获
Public Declare Function ReleaseCapture Lib "user32" () As Long
'SendMessage函数用作向Windows发送移动窗体的消息
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As _
Long, ByVal wMsg As Long, ByVal wParam As Long, IParam As Any) As Long
Public Const WM_SYSCOMMAND = &H112 '声明向Windows发送消息的常量
Public Const SC_MOVE = &HF012 '声明控制移动窗体常量
'(游戏变量声明部分)-------------------------------------------------------------
'定义蛇的数据类型结构
Public Type Snake
Snake_OldX As Long
Snake_OldY As Long
Snake_CurX As Long
Snake_CurY As Long
Snake_Color As Long
End Type
'定义果子的数据类型结构
Public Type Point
Point_X As Long
Point_Y As Long
Point_Color As Long
End Type
'定义蛇的动态数组
Public g_udtSnake() As Snake
'定义果子
Public g_udtPoint As Point
'定义蛇的长度
Public g_intSnakeLength As Integer
'定义蛇的颜色
Public g_lngSnakeColor As Long
'定义蛇的运动方向
Public g_intDirection As Integer
'定义玩家的得分
Public g_intPlayerScore As Integer
'定义游戏耗费的秒数
Public g_lngGameTime As Long
她有一次在家无聊地用自己家电话拨通自己家电话,很多次后终于拨通了,她听到一个空洞洞的声音,好象一个回音谷并且还有水滴的声音。第二天她失踪了,三天后警察在一个回音谷的潭水边找到了我朋友的尸体。
有一次晚上我十二点和朋友吃完饭一起回家,经过一个有坟墓的地方,朋友很害怕。结果第二天早上他精神时常,常常说这么几句话:坟墓有人爬出来。他们在笑。他们在流血。
我家有一个晚上停电,结果找来找去就只有白色蜡烛了,点在床头后照照镜子睡觉,可是那天觉得胸闷,喘不上气,翻来覆去好象被什么东西压着,照找镜子后发现我正背着我奶奶的包!我明明没背上去的!
整个湖都变成红色的了(那是血),从湖里伸出一只手,抓住了女孩的脚,硬把她拉进湖中,随后,人们在离那片森林100公里远的地方找到了女孩的尸体还有衣服,只是她的头不见了,人们打开她的背包,吓坏了,包里就是她的头,她的表情十分痛苦,发现她的那些人把她的尸体丢弃在了那片森林......
如果你看了此帖,请立即回贴,并点击“菩萨保佑”,然后将此贴在别吧转发3份,如果不发那只手会在你洗澡时伸出来,你会和那个女孩是同样下场!要相信,是真的。
buhuhuhuhuhuhuhhhhhhhhhhhhhhhhhh我是个初学者,期末要交个用VB制作简单的小游戏,拜托先将完整代码写出来,下面再补充说明代码中的步骤注意事项,例如要设置的窗口,按键等,请不要将属性设置也写进代码中! (最好我可以直接将代码复制到VB中,设置下属性便可以运行!!!)
代码越简单越好,符合初学者,好的我会追加分,谢谢~~!!!
上学期VB挂科了 老师让我补做一个VB小游戏 可是我一点都没学 朋友们...
从别人那里抄来的!你先试试 Visual Basic小游戏:猜英雄相信不少读者都看过央视的《水浒》吧,林冲、武松、李逵等英雄好汉的音容笑貌仿佛还浮现在我的眼前,那么108将中你最喜欢谁呢?我做了一个小程序来让电脑猜测你的心思,程序界面如图所示。为了简化问题,我选择了其中的27将,将他们分成3组,...
VB 程序编写石头剪刀布小游戏 求高手帮忙
在代码页的最前面加入以下的2行:Option Base 1 Dim x As Integer, y As Integer, z As Integer 另外,所有的以下部分要修改:Text1.Text = ("电脑胜利 ") & x&(" 盘")Text2.Text = ("你胜利 ") & y&(" 盘")改为:Text1.Text = "电脑胜利 " & x & " 盘"Text2.Text = "...
开发一个循环 5 次计算的小游戏,设置随机种子为10,每次随机产生两个...
如果这是VB的程序,那么可以用如下的得到两个1~10的整数:x=Int(Rnd*10)+1 y=Int(Rnd*10)+1 再加上循环for i=1 to 5可以。include <stdio.h> include <stdlib.h> bai\/* 随机库函数 *\/ include \/* 时间库函数 *\/ int count=0, ok=0; \/* count表示回答次数, ok表示回答正确次数...
谁能帮我做一份VB6.0作业,内容为小游戏,最好是自己写的,代码要稍微多一...
很简单,做一个打地鼠的游戏,放9个按钮,然后int(RND*10)select case判断,然后command.enable=1,然后当点击command.enable=0,需要有个Timer控件,用来设定打地鼠的延迟,如果你为了更好一下,你可以收集一些图片的素材,然后给按钮设置
如何编写一套完整的VB小游戏程序
如果只是几百或者1千行并且不是太复杂的小游戏的话,并且不希望非常大的扩展下去,那就随便画画草图脑子有个大概思路就差不多可以开始了.如果楼主想用vb做,那可能不太合适,本人也只是用过它做过一些俄罗斯方块,贪食蛇之类的小游戏还有类似斗地主那样的牌类游戏.简单的说吧,首先你要知道你想做什么,并且...
谁能帮我做一个VB的小游戏!!!高分悬赏
发完了。附件:Vessel.rar
我要用vb做“警察抓小偷”类型的小游戏,请问下怎样进行逐字判断所输入...
逐字判断如下例:Private Sub Command1_Click()Dim t1 As String, t2 As String, t3 As String Dim i As Long, L1 As Long, L2 As Long t1 = "第一个字母A。"L1 = Len(t1)t2 = InputBox("请输入:" & t1, "输出比较")L2 = Len(t2)If L1 = L2 Then For i = 1 To L1 If...
怎么用vb制作俄罗斯方块游戏啊,简单点的。
我们这个小游戏也可以用C语言来实现,在程序的编程上没有VB语言方便实用,C语言和VB语言之间存在很多的共同点,虽然语法方面有点差异,但是在编程思路上完全一样,VB能够实现很多C#不能做到的功能,如When语句、Optional参数、局部Static变量、对象实例访问静态方法、Handles绑定事件、On Error处理异常、Object直接后期绑定等等...
VB硬币小游戏,高手帮忙
VB硬币游戏很简单,核心只要用Rnd函数即可 以下假设有A和B两个角色玩儿硬币游戏,我给你用最简单的代码实现 Dim a As Integer '角色A赢的次数 Dim b As Integer '角色B赢的次数 Dim c As Integer 'c作为硬币正反面 For i=1 To 10 '游戏玩儿10次,算谁赢 c = Rnd * 2 '产生0或1之间的...
用VB制作个小游戏。急急急急急~!!!马上就要交了,随便什么都行,简单的小...
我是个初学者,期末要交个用VB制作简单的小游戏,拜托先将完整代码写出来,下面再补充说明代码中的步骤注意事项,例如要设置的窗口,按键等,请不要将属性设置也写进代码中!(最好我... 我是个初学者,期末要交个用VB制作简单的小游戏,拜托先将完整代码写出来,下面再补充说明代码中的步骤注意事项,例如要设置的窗口,...
薛狗舒秦: Private Enum tpsSpeed QUICKLY = 0 SLOWLY = 1End Enum'定义蛇的运动方向枚举值Private Enum tpsDirec...
回民区17813177830: ■用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
回民区17813177830: 如何设计一个很简单的VB程序小游戏 - ?
薛狗舒秦: 利用vb控件做个坦克大战类的游戏即可,炮弹和坦克都用控件实现就行.唯一难点是控制控件移动以及炮弹击中目标的碰撞检测判断.给你一个简单实现代码 这是一种碰撞检测方法,下述属于简化的矩形碰撞检测,若是需要复杂碰撞可以用一个...
回民区17813177830: 做一个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 ...
回民区17813177830: 求一个VB精简版能做的简单小游戏的制作过程和代码 - ?
薛狗舒秦: 一个timer 一个label 在timer里写随机移动 label位置 让玩家去点击label 点中则加几分~ 你可自行调节移动的速度 来增加难度 left top这2个属性是位置 用rnd函数随机
回民区17813177830: 用vb6.0做一个小游戏 - ?
薛狗舒秦: 你说的贪吃蛇、推箱子都不简单,涉及到很多方面的设计,要花不少时间的.这里估计很少有人能帮得上你.祝你好运.帮你做了一个简单的猜数游戏,代码如下: '只需给窗体添加一个Command1的控件,单击它即可执行,允许多次执行 ...
回民区17813177830: vb制作, 我用vb制作了一个小游戏 打怪升级类 - ?
薛狗舒秦: '插入3个text,一个command Private Sub form_load() Text1.Text = "1000" '血量 Text2.Text = "500" '魔 Text3.Text = "400" '对手 End Sub Private Sub command1_click() If Text1.Text = "0" Or Text2.Text = "0" Then MsgBox "无法攻击!...
回民区17813177830: 用vb做一个益智小游戏 - ?
薛狗舒秦: Dim intI As Integer Dim intJ As Integer Dim intH As Integer Dim intS(0 To 11) As Integer Private Sub Command1_Click() '寻找: Dim intG As Integer If intH + 6 > 11 Then intG = intH - 6 Else intG = intH + 6 End If For intI = 0 To 11 If intI = intS(...
回民区17813177830: 如何用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(...
回民区17813177830: 用VB写一个和电脑猜石头剪刀布的小游戏(要代码)! - ?
薛狗舒秦: Dim com, youdo Until b=7com=Int(3 * Rnd)+1you=inputbox("1代表剪刀,2代表石头,3代表布","请输入一个1-3的数字")if you = "" th...