主题:想問一下一個遊戲的編碼
peters1390
[专家分:0] 发布于 2010-05-01 23:47:00
我現在還是一位新手,之前想試一試做一個小遊戲。就是當一個球碰到板就彈起來,卻不知道怎樣寫。我的球和板都是以圖片形式用的,請各位朋友教一教我吧!謝謝!請你們一以球是“ball”,板是“board”,來寫這個編碼吧
回复列表 (共4个回复)
沙发
merry05 [专家分:8920] 发布于 2010-05-02 10:16:00
u should do it yourself and get hold of some help from some program exports of this forum,or u could spend some money for someone's work
but how much you will pay depends on the diffulty of your task and any other factors
please remember short-term pain for long-term gain
good luck
板凳
一江秋水 [专家分:9680] 发布于 2010-05-02 11:29:00
Dim x As Integer
Dim y As Integer
Private Sub Form_Click()
Timer1.Enabled = Not Timer1.Enabled
End Sub
Private Sub Form_Load()
Timer1.Interval = 100 '每100毫秒移动一次
x = 100 '每个时间周期内小球在X轴的移动距离
y = 100 '每个时间周期内小球在Y轴的移动距离
End Sub
Private Sub Form_Resize()
If ball.Top <= 0 Then ball.Top = -25: y = -y
If ball.Top >= (Form1.Height - 420) Then ball.Top = (Form1.Height - 445) - ball.Height: y = -y
If ball.Left <= 0 Then ball.Left = -25: x = -x
If ball.Left >= (Form1.Width - 100) Then ball.Left = (Form1.Width - 125) - ball.Width: x = -x
End Sub
Private Sub Timer1_Timer()
ball.Move ball.Left + x, ball.Top + y
If ball.Top <= 0 Then y = -y '小球顶部碰到窗体上边界
If ball.Top >= Form1.Height - 800 Then y = -y '小球底部碰到窗体下边界
If ball.Left <= 0 Then x = -x '小球左部碰到窗体左边界
If ball.Left >= Form1.Width - 500 Then x = -x '小球右部碰到窗体右边界
我这是在窗体中移动小球,如果你要在图片框中移动,改一下吧
3 楼
peters1390 [专家分:0] 发布于 2010-05-02 17:38:00
谅谅ぃ筁埃窱娩は紆ぇи临稱ê瞴窱遏狾碞琌瓜礛は紆
4 楼
gfan [专家分:60] 发布于 2010-05-05 14:57:00
多年项目开发经验,专业做毕业设计等中小型项目开发,熟悉各种数据库操作(sql server ,access ,mysql等),熟练应用VC, Delphi, VB, ASP, C#等开发语言.若有需要请联系QQ: 383147818 加我请注明: pfan项目
我来回复