一个VB编写的俄罗斯方块
'VB语言版俄罗斯方块
'Totoo、Aoo34智造(一个人的两个名字),一些方块,很多计算
Const Boxl As Integer = 372, BoxNum As Integer = 200
Private Sub Combo1_DropDown()
Turn
End Sub
Timer1.Interval = TimeLen
CheckTop
Fail
Cleaner
XFull
End Sub
Call Load
Form1.Width = Screen.Width
Form1.Height = Screen.Height
'For a = 0 To 3
With Label1
.Caption = " 华康强大 华夏复兴"
.Width = Form1.ScaleWidth - 10 * Boxl
.Height = 20 * Boxl
.Move 10 * Boxl, 0
End With
'Next a
With Label2
.Move 0, 20 * Boxl
.Caption = "经以此纪念伟大的盗版者,中国人民的英雄——雷华康!"
End With
Form1.Caption = "w,a,s,d分别为变形、左、右及降落"
TimeLen = 200
Timer1.Interval = 1000
Call ClearUpEr
ShapeAdd
For a = 0 To 3
With Shape2(a)
.Width = Boxl
.Height = Boxl
End With
Next a
End Sub
Private Sub ClearUpEr()
'Totoo作品
With Form1
.Width = WN * 372 / 2 * 3
.Height = 27 * Boxl
End With
Dim Ia As Integer, ib As Integer
Dim x(BoxNum) As Integer, y(BoxNum) As Integer
x(1) = 0
y(1) = 0
For a = 0 To 199
With Shape1(a)
.Width = Boxl * (Iret + 1)
.Height = Boxl * (Iret + 1)
End With
Ia = Ia + 1
If (Ia <> 0) And (a Mod WN = 0) Then Ia = 0: ib = ib + 1
x(a) = Boxl * Ia
y(a) = Boxl * (ib - 1)
Shape1(a).Move x(a), y(a)
Next a
'Totoo作品
End Sub
'Totoo作品
Dim Sret As Integer
x(1) = 0: y(1) = 0: stet = 3
For j = 2 To 4
If j = 4 Then
If x(3) = 1 And y(3) = 1 Then
Rndget Sret, 2
If Sret = 0 Then GoTo Four:
End If
End If
Rndget Sret, 2
If Sret = 1 Then
Sret = j
NextBox Sret, Sret - 1, 1, 1
Else
Sret = j
NextBox Sret, Sret - 1, 1, 0
End If
If 1 = 2 Then
Four:
Rndget Sret, 2
Select Case x(2)
Case 1:
If Sret = 1 Then
NextBox 4, 2, 1, 1
Else
NextBox 4, 3, -1, 1
End If
Case 0:
If Sret = 1 Then
NextBox 4, 2, 1, 0
Else
NextBox 4, 3, -1, 0
End If
End Select
End If
initialize:
For a = 1 To 4
With Shape2(a - 1)
.Move x(a) * Boxl, y(a) * Boxl
.Width = Boxl
.Height = Boxl
End With
Next a
corect:
Dim reta3, reta4 As Integer
For a = 1 To 4
reta3 = x(a)
If reta3 > reta4 Then: reta4 = reta3
Next a
Randomize
reta3 = Fix(Rnd * (9 - reta4)) + 1
For a = 1 To 4
x(a) = x(a) + reta3
Next a
'Totoo作品
End Sub
'Totoo作品,中国智造
For a = 1 To 10
For b = 1 To 20
If BF(a, b) = 1 Then
Shape1(a + (b - 1) * 10 - 1).FillStyle = 0
Else
Shape1(a + (b - 1) * 10 - 1).FillStyle = 1
End If
Next b
Next a
Sub CheckTop()
'Totoo作品,中国智造
On Error GoTo done:
For a = 1 To 4
If x(a) + 1 < 19 Then On Error Resume Next
If y(a) > 18 Then GoTo done:
If BF(x(a) + 1, y(a) + 2) = 1 Then GoTo done:
If x(a) + 1 > 20 Or x(a) + 1 < 1 Then GoTo Over:
Next a
If 1 = 2 Then
Over:
Call ClsBox
'Timelen = 500
Call ShapeAdd
'MsgBox "GameOver!": End
End If
If 1 = 2 Then
done:
For a = 1 To 4
If BF(x(a) + 1, y(a) + 1) = 1 Then GoTo Over:
Next a
For a = 1 To 4
BF(x(a) + 1, y(a) + 1) = 1
Next a
Call ShapeAdd: If BottomAsk = True Then TimeLen = 500: BottomAsk = False
End If
Pass:
End Sub
Dim ret As Integer
For a = 1 To 4
ret = x(a) - x(3): mY(a) = ret + y(3)
ret = y(a) - y(3): mX(a) = ret + x(3)
doit:
' On Error GoTo chc:
' If 1 = 2 Then
' If syssin Then
'chc:
' On Error Resume Next
' Else
' On Error GoTo handle:
' End If
' End If
'
Next a
'
'If 1 = 2 Then
'handle:
' If BF(mX(a) + 2, mY(a) + 2) = 1 Then GoTo Pass:
'End If
ComeTure
'Pass:
'Totoo作品,中国智造
End Sub
Dim Ia As Integer, I As Integer
Dim mY As Integer, BfRet(1 To 10, 1 To 20) As Integer
Dim Cleanit As Boolean
For b = 1 To 20
For a = 1 To 10
If BF(a, b) = 1 Then Ia = Ia + 1
Next a
If Ia = 10 Then I = I + 1: Toper(I) = b: '记录满格
Ia = 0
Next b
If I <> 0 Then
For b = 1 To I
For a = 1 To 10
BF(a, Toper(b)) = 0
Next a
socre = socre + 200
Next b
Label2.Caption = "得分:" & Str(socre)
End If
If (Clean = True) Then
For a = 1 To 10
Cleanit = False
For b = 1 To 20
mY = 0
mY = BF(a, b)
If BF(a, b) = 1 Then
For c = 1 To I
If Toper(c) <> 0 Then
If b < Toper(c) Then
mY = mY + 1
Cleanit = True
End If
End If
If c = I Then
If b + mY > 20 Then GoTo Pass:
BfRet(a, b + mY - 1) = 1
If 1 = 2 Then
Pass:
For d = 1 To 10
BfRet(a, 20) = 1
Next d
End If
End If
Next c
End If
mY = 0
Next b
If Cleanit = True Then
For b = 1 To 20
BF(a, b) = BfRet(a, b)
BfRet(a, b) = 0
Next b
End If
Next a
End If
For L = 1 To I
Toper(L) = 0
Next L
End Sub
Dim SFN As String
CommonDialog1.ShowOpen
SFN = CommonDialog1.FileName
If SFN <> "" Then
Open SFN & ".totooDat" For Output As #1
For a = 1 To 10
For b = 1 To 20
Print #1, BF(a, b)
Next b, a
Print socre
Close #1
End If
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 65, 37: MoveLeft
Case 68, 39: MoveRight
Case 87, 38: Turn
Case 83, 40: TimeLen = 20: BottomAsk = True
End Select
If KeyCode = 13 Then
EntI = EntI + 1
If EntI Mod 2 = 1 Then
TimeLen = 10
Else: TimeLen = 1000: End If
End If
End Sub
Clean = True
For a = 1 To 4
y(a) = y(a) + 1
Shape2(a - 1).Move x(a) * Boxl, y(a) * Boxl
Next a
End Sub
Public BF(1 To 10, 1 To 20) As Integer, mX(1 To 4), mY(1 To 4) As Integer
Public retY(1 To 20), Toper(1 To 20) As Integer, Saver(1 To 10) As String
Public socre, Iret, MarkNum As Integer, TimeLen As Integer, EntI As Integer
Public SystemAsk As Boolean, BottomAsk As Boolean, ret As String
Public Repeat As Boolean, Clean As Boolean
Public Sub MoveLeft()
'Totoo作品
On Error GoTo Pass:
For a = 1 To 4
mX(a) = x(a) - 1
If BF(mX(a) + 1, y(a) + 1) = 1 Then GoTo Pass:
Next a
For a = 1 To 4
x(a) = mX(a)
Next a
Pass:
End Sub
On Error GoTo Pass:
For a = 1 To 4
mX(a) = x(a) + 1
If BF(mX(a) + 1, y(a) + 1) = 1 Then GoTo Pass:
Next a
For a = 1 To 4
x(a) = mX(a)
Next a
Pass:
End Sub
For a = 1 To 10
For b = 1 To 20
BF(a, b) = 0
Next b
Next a
End Sub
If d = 0 Then
x(a) = x(b): y(a) = y(b) + c
Else
x(a) = x(b) + c: y(a) = y(b)
End If
End Sub
Public Sub Rndget(a, b As Integer)
Randomize
a = Fix(Rnd * b)
End Sub
For a = 1 To 4
x(a) = mX(a): y(a) = mY(a)
Next a
End Sub
'用400行完成,希望对学习者有所帮助!
一个VB编写的俄罗斯方块的更多相关文章
- VB编写的验证码生成器
验证码(CAPTCHA)是“Completely AutomatedPublicTuring test to tell Computers andHumansApart”(全自动区分计算机和人类的图灵 ...
- OD学习笔记10:一个VB程序的加密和解密思路
前边,我们的例子中既有VC++开发的程序,也有Delphi开发的程序,今天我们给大家分析一个VB程序的加密和解密思路. Virtual BASIC是由早期DOS时代的BASIC语言发展而来的可视化编程 ...
- 【转载】Pyqt 编写的俄罗斯方块
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function from __future__ ...
- GitHub入门之二 参与一个项目编写
接上文:大多数时候我们也需要把别人的代码进行整合和修改,而不是简单的修改,这时就需要对一个项目进行修改. 注意,本系列文章主要说明在github网站上的操作,更多高级操作请使用git控制台 一.for ...
- 怎样用VB编写.DLL动态链接库文件
VB一般可以生成两种特殊的DLL,一个是ActiveX DLL和ActiveX Control(*.ocx).这两种DLL都是VB支持的标准类型,在VB自身的例子中有,你可以参考.更详细的介绍可以参考 ...
- VS2010环境下使用VB编写串口助手
1.在Form1的设计模式下添加以下控件: 2.添加好控件之后我们就可以打开Form1.vb进行编程了: '使用串口需要引用的命名空间 Imports System.IO.Ports Imports ...
- 用Shell编写的俄罗斯方块代码
用Shell编写的俄罗斯方块代码 不得不承认任何一门语言玩6了,啥都能搞出来啊,竟然用Shell编写出来了一个俄罗斯方块游戏的代码,很有意思,这个代码不是我写出来的,不过大家可以下载一下在window ...
- ksonnet 一个简化编写以及部署kubernetes的工具
ksonnet 是一个基于jsonnet的快速简化kubernetes yaml 配置的工具,可以实现配置的复用 同时也包含一个registry 的概念,可以实现可复用组件的分发,同时支持helm 环 ...
- 一个能够编写、运行SQL查询并可视化结果的Web应用:SqlPad
SqlPad 是一个能够用于编写.运行 SQL 查询并可视化结果的 Web 应用.支持 PostgreSQL.MySQL 和 SQL Server.SqlPad 目前仅适合单个团队在内网中使用,它直接 ...
随机推荐
- linear-grident的属性和使用以及对颜色后面参数(百分比)的理解
linear-grident的属性和使用 css3新增Gradient属性,用来增加渐变的效果,渐变分为线性渐变 linear-grident 和 径向渐变 radial-grident,这篇文章 ...
- 利用UICollectionView实现列表和宫格视图的切换
很多时候我们需要列表和宫格视图的来回切换,就像苹果的天气应用一样,我之前见过一个用tableview和collectionview来实现这种效果的,我本人不太喜欢这个,那么有没有更好的方法呢?答案是: ...
- [Python Study Notes] python面试题总结
python语法以及其他基础部分 可变与不可变类型: 浅拷贝与深拷贝的实现方式.区别:deepcopy如果你来设计,如何实现: __new__() 与 __init__()的区别: 你知道几种设计模式 ...
- yii2 源码分析Behavior类分析 (四)
Behavior类是所有事件类的基类,它继承自object类 Behavior类的前面注释描述大概意思: * Behavior类是所有事件类的基类 * * 一个行为可以用来增强现有组件的功能,而不需要 ...
- Git 如何 clone 非 master 分支的代码
问题描述 我们每次使用命令 git clone git@gitlab.xxx.com:xxxxx.git 默认 clone 的是这个仓库的 master 分支.如果最新的代码不在 master 分支上 ...
- python学习:匿名函数
Python 函数 lambda 匿名函数 -lambda 函数是一种快速定义单行的最小函数,可以用在任何需要函数的地方. def fun(x,y): return x*y fu ...
- NOIP 总结
NOIP 总结 实在不知道写什么标题 决定还是把我的noip总结贴上来,毕竟保存还是挺麻烦的. 扯淡 联赛考完有三个星期了,成绩也出了一个星期左右了. 终于还是决定动笔写一点联赛的总结. Day1 可 ...
- Java并发系列[6]----Semaphore源码分析
Semaphore(信号量)是JUC包中比较常用到的一个类,它是AQS共享模式的一个应用,可以允许多个线程同时对共享资源进行操作,并且可以有效的控制并发数,利用它可以很好的实现流量控制.Semapho ...
- 单元测试——Qunit
为什么需要单元测试 正确性:测试可以验证代码的正确性,在上线前做到心里有底 自动化:当然手工也可以测试,通过console可以打印出内部信息,但是这是一次性的事情,下次测试还需要从头来过,效率不能得到 ...
- CentOS7上LNMP安装包一步搭建LNMP环境
系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian Linux系统 需要5GB以上硬盘剩余空间 需要128MB以上内存(如果为128MB的小内存VPS,Xe ...