找回密码
 立即注册→加入我们

QQ登录

只需一步,快速开始

搜索
热搜: 下载 VB C 实现 编写
查看: 4369|回复: 5

【VB】两百行代码给你撸个生死时速

[复制链接]
发表于 2014-12-20 01:34:16 | 显示全部楼层 |阅读模式

欢迎访问技术宅的结界,请注册或者登录吧。

您需要 登录 才可以下载或查看,没有账号?立即注册→加入我们

×
捕获.JPG
技术不宅老C给你用200多行VB代码撸个小游戏
大家来吐槽2d碰撞检测,蛤蛤蛤,谁说vb不适合开发游戏蟆~~
  1. Option Explicit

  2. Dim mySpeed         As Integer
  3. Dim myHP            As Integer
  4. Dim nailVisible     As Boolean
  5. Dim lightingVisible As Boolean
  6. 'Dim showNailTime    As Long
  7. 'Dim showLigTime     As Long
  8. Dim raceTime        As Double

  9. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  10.     'MsgBox KeyCode
  11.     If (KeyCode = 38) Or (KeyCode = 87) Then
  12.         TimUp.Enabled = True
  13.     End If
  14.     If (KeyCode = 40) Or (KeyCode = 83) Then
  15.         TimDown.Enabled = True
  16.     End If
  17.     If (KeyCode = 39) Or (KeyCode = 68) Then
  18.         mySpeed = 75
  19.     End If
  20. End Sub

  21. Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
  22.     If (KeyCode = 39) Or (KeyCode = 68) Then
  23.         mySpeed = 50
  24.     End If
  25. End Sub

  26. Private Sub Form_Load()
  27.     Randomize
  28.     mySpeed = 50
  29.     myHP = 100
  30.     nailVisible = False
  31.     lightingVisible = False
  32.     'showLigTime = Int(Rnd() * 5 + 1)
  33.     'showNailTime = Int(Rnd() * 5 + 1)
  34.     TimShowNail.Interval = Int(Rnd() * 5 + 1)
  35.     TimShowLig.Interval = Int(Rnd() * 5 + 1)
  36.     raceTime = 0
  37. End Sub

  38. Private Sub MuAbout_Click()
  39.     MsgBox "VGT v1.0 Demo" & vbCrLf & "Created By Cyycoish,漫天飞雪 0711" & vbCrLf & "Copyright (C) Ctechnology 2012", , "VGT Demo"
  40. End Sub

  41. Private Sub MuExit_Click()
  42.     End
  43. End Sub

  44. Private Sub MuStart_Click()
  45.     Randomize
  46.     ImgBike2.Left = 120
  47.     ImgBike2.Top = 1080
  48.     ImgBike1.Top = 600
  49.     ImgBike1.Left = 3960
  50.     ImgGov.Left = 2880
  51.     ImgGov.Top = 2400
  52.    
  53.     Label1.Caption = "HP:100%"
  54.     Label6.Caption = "Race time:0s"
  55.    
  56.     mySpeed = 50
  57.     myHP = 100
  58.     nailVisible = False
  59.     lightingVisible = False
  60.     'showLigTime = Int(Rnd() * 5 + 1)
  61.     'showNailTime = Int(Rnd() * 5 + 1)
  62.     TimShowNail.Interval = Int(Rnd() * 5 + 1)
  63.     TimShowLig.Interval = Int(Rnd() * 5 + 1)
  64.     raceTime = 0
  65.    
  66.     TimBack.Enabled = True
  67.     TimClo.Enabled = True
  68.     TimShowNail.Enabled = True
  69.     TimShowLig.Enabled = True
  70.     Timer1.Enabled = True
  71. End Sub

  72. Private Sub TimBack_Timer()
  73.     ImgBack.Left = ImgBack.Left - mySpeed
  74.     If ImgBack.Left <= (-1 * ImgBack.Width / 2) Then
  75.         ImgBack.Left = 0
  76.     End If
  77.     If ImgNail.Visible = True Then
  78.         ImgNail.Left = ImgNail.Left - mySpeed
  79.         If ImgNail.Left <= -1 * (ImgNail.Width) Then
  80.             ImgNail.Visible = False
  81.         End If
  82.         If ((1560 = ImgNail.Top) And ((ImgBike1.Top >= 600) And (ImgBike1.Top <= 780))) And ((ImgBike1.Left <= ImgNail.Left) And (ImgNail.Left <= ImgBike1.Left + ImgBike1.Width)) Then
  83.             ImgNail.Visible = False
  84.             myHP = myHP - 25
  85.             mySpeed = 50
  86.             Label1.Caption = "HP:" & myHP & "%"
  87.             If 0 = myHP Then
  88.                 TimBack.Enabled = False
  89.                 TimClo.Enabled = False
  90.                 TimUp.Enabled = False
  91.                 TimDown.Enabled = False
  92.                 TimGO.Enabled = True
  93.                 Timer1.Enabled = False
  94.             End If
  95.         End If
  96.         If ((1920 = ImgNail.Top) And ((ImgBike1.Top >= 780) And (ImgBike1.Top <= 1080))) And ((ImgBike1.Left <= ImgNail.Left) And (ImgNail.Left <= ImgBike1.Left + ImgBike1.Width)) Then
  97.             ImgNail.Visible = False
  98.             myHP = myHP - 25
  99.             mySpeed = 50
  100.             Label1.Caption = "HP:" & myHP & "%"
  101.             If 0 = myHP Then
  102.                 TimBack.Enabled = False
  103.                 TimClo.Enabled = False
  104.                 TimUp.Enabled = False
  105.                 TimDown.Enabled = False
  106.                 TimGO.Enabled = True
  107.                 Timer1.Enabled = False
  108.             End If
  109.         End If
  110.         
  111.         'Label3.Caption = ImgNail.Left
  112.     End If
  113.    
  114.     If ImgLig.Visible = True Then
  115.         ImgLig.Left = ImgLig.Left - mySpeed
  116.         If ImgLig.Left <= -1 * (ImgLig.Width) Then
  117.             ImgLig.Visible = False
  118.         End If
  119.         If ((1560 = ImgLig.Top) And ((ImgBike1.Top >= 600) And (ImgBike1.Top <= 780))) And ((ImgBike1.Left <= ImgLig.Left) And (ImgLig.Left <= ImgBike1.Left + ImgBike1.Width)) Then
  120.             ImgLig.Visible = False
  121.             mySpeed = 100
  122.             TimLig.Enabled = True
  123.         End If
  124.         If ((1920 = ImgLig.Top) And ((ImgBike1.Top >= 780) And (ImgBike1.Top <= 1080))) And ((ImgBike1.Left <= ImgLig.Left) And (ImgLig.Left <= ImgBike1.Left + ImgBike1.Width)) Then
  125.             ImgLig.Visible = False
  126.             mySpeed = 100
  127.             TimLig.Enabled = True
  128.         End If
  129.     End If
  130.    
  131.     ImgBike2.Left = ImgBike2.Left + (65 - mySpeed)
  132.     If ImgBike2.Left >= ImgBike1.Left Then
  133.         TimBack.Enabled = False
  134.         TimClo.Enabled = False
  135.         TimUp.Enabled = False
  136.         TimDown.Enabled = False
  137.         TimGO.Enabled = True
  138.         Timer1.Enabled = False
  139.     End If
  140.     Label2.Caption = "Map Position:" & ImgBack.Left
  141. End Sub

  142. Private Sub TimClo_Timer()
  143.     ImgClo.Left = ImgClo.Left - 50
  144.     If ImgClo.Left <= (-1 * ImgClo.Width) Then
  145.         ImgClo.Left = Me.ScaleWidth
  146.     End If
  147. End Sub

  148. Private Sub TimDown_Timer()
  149.     TimUp.Enabled = False
  150.     If ImgBike1.Top >= 1080 Then
  151.         TimDown.Enabled = False
  152.         Exit Sub
  153.     End If
  154.     ImgBike1.Top = ImgBike1.Top + 10
  155. End Sub

  156. Private Sub Timer1_Timer()
  157.     raceTime = raceTime + 0.1
  158.     Label6.Caption = "Race Time:" & Format(CStr(raceTime), "0.0") & "s"
  159. End Sub

  160. Private Sub TimGO_Timer()
  161.     If ImgGov.Top <= 840 Then
  162.         TimGO.Enabled = False
  163.         Exit Sub
  164.     End If
  165.     ImgGov.Top = ImgGov.Top - 10
  166. End Sub

  167. Private Sub TimLig_Timer()
  168.     mySpeed = 50
  169.     TimLig.Enabled = False
  170. End Sub

  171. Private Sub TimShowLig_Timer()
  172.     Randomize
  173.     TimShowLig.Interval = Int(Rnd() * 5 + 1)
  174.     If ImgLig.Visible = False Then
  175.         Call ResetLightingPlace(((Int(Rnd() * 10) Mod 2)) = 0)
  176.         ImgLig.Visible = True
  177.     End If
  178. End Sub

  179. Private Sub TimShowNail_Timer()
  180.     Randomize
  181.     'Dim uDN As Boolean
  182.     'uDN = (((Int(Rnd() * 10) Mod 2)) = 0)
  183.     TimShowNail.Interval = Int(Rnd() * 5 + 1)
  184.     If ImgNail.Visible = False Then
  185.         Call ResetNailPlace(((Int(Rnd() * 10) Mod 2)) = 0)
  186.         ImgNail.Visible = True
  187.     End If
  188.     'Label4.Caption = TimShowNail.Interval
  189. End Sub

  190. Private Sub TimUp_Timer()
  191.     TimDown.Enabled = False
  192.     If ImgBike1.Top <= 600 Then
  193.         TimUp.Enabled = False
  194.         Exit Sub
  195.     End If
  196.     ImgBike1.Top = ImgBike1.Top - 10
  197. End Sub

  198. Private Sub ResetNailPlace(upOrDown As Boolean)
  199.     If upOrDown = True Then
  200.         ImgNail.Left = 9600
  201.         ImgNail.Top = 1560
  202.     Else
  203.         ImgNail.Left = 9600
  204.         ImgNail.Top = 1920
  205.     End If
  206. End Sub

  207. Private Sub ResetLightingPlace(upOrDown As Boolean)
  208.     If upOrDown = True Then
  209.         ImgLig.Left = 9600
  210.         ImgLig.Top = 1560
  211.     Else
  212.         ImgLig.Left = 9600
  213.         ImgLig.Top = 1920
  214.     End If
  215. End Sub
复制代码


vgtr.zip (93.89 KB, 下载次数: 41)

回复

使用道具 举报

发表于 2014-12-21 06:52:33 | 显示全部楼层
新人正在学习中
回复 赞! 靠!

使用道具 举报

发表于 2019-5-10 21:03:55 | 显示全部楼层
哈哈哈。
回复

使用道具 举报

发表于 2019-5-10 21:36:08 | 显示全部楼层
下载体验一下
回复 赞! 靠!

使用道具 举报

发表于 2022-11-23 23:44:08 | 显示全部楼层
支持楼主,体验一把!
回复 赞! 靠!

使用道具 举报

发表于 2023-4-4 15:18:29 | 显示全部楼层
这不是忍者神龟那个。。
回复 赞! 靠!

使用道具 举报

本版积分规则

QQ|Archiver|小黑屋|技术宅的结界 ( 滇ICP备16008837号 )|网站地图

GMT+8, 2024-11-21 22:25 , Processed in 0.038878 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表