| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2117 人关注过本帖
标题:一个小飞机游戏(源码)(懒了点)
只看楼主 加入收藏
专科西校
Rank: 1
等 级:新手上路
帖 子:3
专家分:5
注 册:2018-11-6
收藏
 问题点数:0 回复次数:3 
一个小飞机游戏(源码)(懒了点)
Public Class Form1
    Dim x, q, w, f As Integer
    Dim aa As Integer = 0
   
    Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress

        Select Case Asc(e.KeyChar)
            Case 87 : PictureBox1.Top = PictureBox1.Top - 5
            Case 83 : PictureBox1.Top = PictureBox1.Top + 5
            Case 65 : PictureBox1.Left = PictureBox1.Left - 5
            Case 68 : PictureBox1.Left = PictureBox1.Left + 5
            Case 13 : po(PictureBox21)
        End Select
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        f = 0
        Me.WindowState = FormWindowState.Maximized
    End Sub

    Private Sub hei(ByVal pic)
        Randomize()
        x = Rnd() * 1500 + 50
        w = Rnd() * 15 + 1
        pic.Visible = True
        pic.Top = pic.Top + w
        If pic.Top >= PictureBox1.Top - 20 And pic.Left >= PictureBox1.Left - 20 And pic.left <= PictureBox1.Left + 80 Then

            If aa = 0 Then
                f = f + 1
                If f = 1 Then
                    MessageBox.Show("您应该挂了")
                End If
            End If
        End If
        If pic.Top >= PictureBox21.Top And pic.Left >= PictureBox21.Left - 20 And pic.left <= PictureBox21.Left + 18 Then

            pic.Top = 0
            pic.Left = x

        End If
        If pic.Top >= 800 Then
            pic.Top = 0
            pic.Left = x
        End If

    End Sub
    Private Sub hong(ByVal pic)
        Randomize()
        x = Rnd() * 1500 + 50
        q = Rnd() * 15 + 1
        pic.Visible = True
        pic.Top = pic.Top + q
        If pic.Top >= PictureBox1.Top - 20 And pic.Left >= PictureBox1.Left - 20 And pic.left <= PictureBox1.Left + 80 Then
            aa = aa + 1
            Select aa
                Case 1 : PictureBox26.Visible = True
                Case 2 : PictureBox27.Visible = True
                Case 3 : PictureBox25.Visible = True

            End Select

            pic.Top = 0
            pic.Left = x
        End If
        If pic.Top >= 800 Then
            pic.Top = 0
            pic.Left = x
        End If

    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Static i As Integer
        i = (i + 1) Mod 3
        If i = 0 Then
            Timer1.Interval = 1 * 100
            PictureBox1.Image = PictureBox3.Image
        ElseIf i = 1 Then
            Timer1.Interval = 2 * 100
            PictureBox1.Image = PictureBox2.Image
        Else
        End If
        '敌机碰撞

        

            hei(PictureBox4)
            hei(PictureBox5)
            hei(PictureBox7)
            hei(PictureBox9)
            hei(PictureBox11)
            hei(PictureBox12)
            hei(PictureBox14)
            hei(PictureBox15)
            hei(PictureBox16)
            hei(PictureBox17)
            hei(PictureBox6)
            hei(PictureBox8)
            hei(PictureBox10)
            hei(PictureBox13)
        hei(PictureBox20)
        hei(PictureBox18)
        '奖励




        hong(PictureBox19)


        '子弹动
        dong(PictureBox21)



      


    End Sub
    Private Sub po(ByVal pic)
        pic.top = PictureBox1.Top
        pic.left = PictureBox1.Left + 22
        pic.Visible = True
    End Sub

    Private Sub dong(ByVal pic)
        pic.top = pic.top - 40


    End Sub

   
End Class
搜索更多相关主题的帖子: Sub End Top Left If 
2018-11-06 19:56
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4938
专家分:30047
注 册:2008-10-15
收藏
得分:0 
这个程序跑起来不卡?
我第一个程序也是这移控件,结果卡死啦。后面才学会自己绘图。
这个程序给初学者学习还行,就是没写注释。

授人于鱼,不如授人于渔
早已停用QQ了
2018-11-06 21:48
沉默的痞子
Rank: 4
等 级:贵宾
威 望:12
帖 子:96
专家分:127
注 册:2015-10-7
收藏
得分:0 
回复 2楼 风吹过b
自己绘图是怎么弄的,有没有示例?我之前做了一个坦克大战,子弹也是用控件的,卡的不行
2018-11-22 08:49
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:364
帖 子:4938
专家分:30047
注 册:2008-10-15
收藏
得分:0 
你参考一下这个贴子
https://bbs.bccn.net/thread-481230-1-1.html
几个讨论贴,涉及到绘图。最后的绘图方法,不建议初学者学习。

和 这个贴子
https://bbs.bccn.net/thread-489168-1-1.html
这个是给新手写的。

授人于鱼,不如授人于渔
早已停用QQ了
2018-11-22 11:14
快速回复:一个小飞机游戏(源码)(懒了点)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015604 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved