> R2.X = 100
R2.Y = 100
End Sub
Sub mainloop()
While (running = True) ''''''''''''如果游戏没有结束
blt() ''''''''''''主要绘制过程
tfp += 1 ''''''''''''fps++
If tfp = 200 Then ''''''''''''200次的时候计算时间
tfp = 0
ts = (DateTime.Now.Subtract(mytime))
mytime = DateTime.Now
If ts.TotalSeconds <> 0 Then
qiqi = 200 / (ts.TotalSeconds)
fps = qiqi.ToString("##.##") + "F c"
End If
End If
TT.Sleep(10) ''''''''''''硬性规定休息一下,当然可以去掉发挥MAX速度
End While
End Sub
Sub blt()
If BS Is Nothing Then Exit Sub
GetMousePos() ''''得到鼠标位置
''''''''''''下面的就是利用BackSurface的方法来绘制了,随便画,呵呵
BS.DrawFast(0, 0, S1, R1, DrawFastFlags.Wait)
BS.DrawText(10, 10, "1024x768 Frames per Second " + fps, False)
BS.DrawText(10, 30, "当前位置:X=" + M.x.ToString + ",Y=" + M.y.ToString, False)
BS.DrawText(10, 50, "ESC 退出", False)
''''''''''''画出贴图
BS.DrawFast(M.x, M.y, S2, DrawFastFlags.SourceColorKey Or DrawFastFlags.Wait)
''''''''''''顺便在鼠标的位置打出它的坐标
BS.DrawText(M.x + 50, M.y, "(" + M.x.ToString + "," + M.y.ToString + ")", False)
''''''''''''关键一步,翻转,而且不要使用wait,这样可能会丢帧,但是不影响速度
PS.Flip(Nothing, FlipFlags.NoVSync)
End Sub
Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
If e.KeyCode = Keys.Escape Then End ''''ESC退出
End Sub
Sub GetMousePos()
GetCursorPos(M) ''''调用API,得到鼠标位置
上一页 [1] [2] [3] [4] [5] 下一页 [操作系统]Windows2000/XP/2003操作系统常见问题集锦下篇 [操作系统]Windows2000/XP/2003操作系统常见问题集锦上篇 [操作系统]WinXP/2000操作系统自动关机的实现 [操作系统]过河不拆桥—切勿忘记OS/2第二代操作系统之下篇 [操作系统]过河不拆桥—切勿忘记OS/2第二代操作系统之上篇 [系统软件]Visual Studio 2005 Express Editions Beta 2 下载… [常用软件]IE 7出炉,Firefox 2当道.谁才是“王者”? [常用软件]豪华的冲浪引擎MSN Explorer (2) [VB.NET程序]VB.NET实现DirectDraw9 (1) 托管的DDraw [VB.NET程序]学习笔记,VB.NET使用DirectSound9 (2)
|