vb如何在游戏中实现土地!
私有声明函数GetTickCount Lib "kernel32 "()为Long
私人建筑合并油漆= & ampHBB0226
私人Const SRCAND = & ampH8800C6
私人Const SRCCOPY = & ampHCC0020
私有声明函数BitBlt Lib " GDI 32 "(ByVal hDestDC As Long,_
ByVal X一样长,ByVal Y一样长,ByVal n一样长,ByVal n一样高,_
ByVal hSrcDC为Long,ByVal xSrc为Long,ByVal ySrc为Long,ByVal dwRop为Long)
私有声明函数GetAsyncKeyState Lib " user 32 "(ByVal vKey As Long)为整数
私人常数VK _逃生= & ampH1B '
私人常数VK _ UP = & amp;H26 '
私人Const VK _唐= & ampH28 '
私人常数VK _左= & ampH25 '左侧
私人Const VK _右= & ampH27 '右
将帧调暗为单帧
“Dim MAPX As Long,MAPY As Long”地图坐标。
“Dim AN As Single,BN As Single”角色坐标
我单身,玩得久
游戏画面的每秒帧数。
私有子窗体_Load()
表单1。height = 480 * 15:form 1。宽度= 640 * 15
我。显示
PICMAP。Picture = LoadPicture("MAP.jpg ")
MAPX = 1024: MAPY = 65438+
FRAME = 1
AN = 0: BN = 200
I = 0.2
PLAY = 1
FPSY = GetTickCount()
FPSX = FPSY
末端接头
私有子定时器1_Timer()
多项活动
速度= (FPSY - FPSX)
Label1。Caption = " FPS = " & ampInt(1000 /(速度+ 1))
BitBlt Me.hDC,MAPX,MAPY,2048,2048,PICMAP.hDC,0,0,vbSrcCopy
BitBlt Me.hDC,MAPX - 2048,MAPY,2048,2048,PICMAP.hDC,0,0,vbSrcCopy
BitBlt Me.hDC,MAPX,MAPY - 2048,2048,2048,PICMAP.hDC,0,0,vbSrcCopy
BitBlt Me.hDC,MAPX - 2048,MAPY - 2048,2048,2048,PICMAP.hDC,0,0,vbSrcCopy
AN = AN +速度* I
如果一个& lt-50那么我= -I: PLAY = 1
如果一个& gt550那么我=-我:玩= 2
我。恢复精神
如果GetAsyncKeyState(VK _转义)和& ampH8000然后结束
如果MAPX & gt0和GetAsyncKeyState(VK右)和& ampH8000然后MAPX = MAPX -速度*帧
如果MAPX & lt2048和GetAsyncKeyState(VK _左)和& ampH8000然后MAPX = MAPX +速度*帧
如果MAPY & gt0和GetAsyncKeyState(VK向下)和& ampH8000然后MAPY = MAPY - SPEED * FRAME
如果MAPY & lt2048和GetAsyncKeyState(VK_UP)和& ampH8000然后MAPY = MAPY +速度*帧
FPSX = FPSY
FPSY = GetTickCount()
末端接头