廣告廣告
  加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 4338 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為IE收藏   收藏主題   上一主題 | 下一主題   
za08280714
數位造型
個人文章 個人相簿 個人日記 個人地圖
小人物
級別: 小人物 該用戶目前不上站
推文 x0 鮮花 x3
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片
推文 x0
[Basic][求助] VB2008拋物線碰撞偵測問題
請問各位大大..PictureBox1碰撞偵測PictureBox2程式裡的拋物線的碰撞偵測都沒有反應.請問是程式碼哪邊有錯誤碰撞偵測我是放在Timer1_Tick這裡.是位置放錯還是拋物線的碰撞偵測不能用那種碰撞偵測方式.


Public Class Form1

    '---------- Local structures ----------

    'Positions [位置的變數]
    Structure struc_pos
        Dim x, y As Integer 'Current position [目前的 x,y]
        Dim ini_x, ini_y As Integer 'Initial position [拋物線參考的最初 x,y,就是物理中表示的 x0,y0]
        Dim ang As Single 'Current angle [目前的角度,為碰撞時可轉換]
        Dim vx, vy As Single 'Current velocity [目前的速度分量]
        Dim ini_vx, ini_vy As Single 'Initial velocity [一開始的 速度分量,就是物理中表示的 vx0,vy0]
        Dim ini_v As Single 'Initial velocity [一開始的速度]
        Dim g As Single  'Gravity constant [重力常數]
    End Structure

    '---------- Local constants ----------

    'Initial positions
    Const user_ini_v As Single = 90 '[設定一開始的速度(可調整)]
    Const user_ini_x As Integer = 50, user_ini_y As Integer = 500 '[圖片一開始的座標(可調整)]

    '---------- Local variables ----------

    'Graphics [繪圖]
    Dim g As System.Drawing.Graphics
    Dim dstRect, srcRect As Rectangle

    'List [清單]
    Dim listPic As New List(Of Image) 'List of picture
    Dim listAng As New List(Of Integer) 'List of angle

    'Collection [集合]
    Dim collRep As New Collection

    'Positions [宣告座標的巢狀結構]
    Dim pos As struc_pos

    'Flags [旗標]
    Dim stat_moving As Integer 'Status (Pausing->0, Moving->1) [紀錄是否在移動]
    Dim stat_ang, max_ang As Integer 'Angle [角度(DEG),與最大值]
    Dim passedTime, multiTi As Single 'Time [已經過時間,與時間加倍量]

    'Help texts
    Const hlp_1 As String = "(1) 按 ""上"",""下"" 切換角度" & vbNewLine & "(2) 按 ""空白鍵"" 開始發射/停止" & vbNewLine & vbNewLine & "當物體碰撞到底下邊緣才會消失"


    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

        local_kc_dir(e.KeyCode)

    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim i As Integer

        '--- Variables ---

        'Position
        With pos
            .g = 9.8
            .ini_v = user_ini_v
        End With

        'Status
        stat_moving = 0
        stat_ang = 6 '[設定一開始是第三張圖片,30度的]

        'Time
        multiTi = 15 '[時間加倍量,太低圖片會跑很慢]

        '--- List of Images ---
        '[讀取圖片,並讀取角度值]
        max_ang = -1
        For i = 0 To 360 Step 15
            listPic.Add(Image.FromFile("00_" & i & ".gif"))
            listAng.Add(i)
            max_ang += 1
        Next

        '--- Obj. ---

        'PictureBox1
        local_renew_resetpic()
        PictureBox1.Visible = False

        'Timer1
        Timer1.Interval = 50

        '--- Sub ---
        local_change_pic()

    End Sub

    Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

        dstRect = Me.ClientRectangle
        srcRect = dstRect

        g = e.Graphics

        '--- Picture ---
        dstRect = New Rectangle(New Point(pos.x, pos.y), PictureBox1.Size)

        g.DrawImage(PictureBox1.Image, dstRect, srcRect, GraphicsUnit.Pixe ..

訪客只能看到部份內容,免費 加入會員 或由臉書 Google 可以看到全部內容




獻花 x0 回到頂端 [樓 主] From:臺灣中華電信股份有限公司 | Posted:2011-11-13 17:22 |
Freelife
數位造型
個人文章 個人相簿 個人日記 個人地圖
初露鋒芒
級別: 初露鋒芒 該用戶目前不上站
推文 x2 鮮花 x60
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片

PictureBox1.Location = New Point(pos.ini_x, pos.ini_y)

這一行取到的值都一樣,後續的動作就不會有效果囉。


獻花 x0 回到頂端 [1 樓] From:臺灣中華電信股份有限公司 | Posted:2011-11-15 11:18 |
za08280714
數位造型
個人文章 個人相簿 個人日記 個人地圖
小人物
級別: 小人物 該用戶目前不上站
推文 x0 鮮花 x3
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片

請問大大那要如何修改才能有碰撞偵測


獻花 x0 回到頂端 [2 樓] From:臺灣中華電信股份有限公司 | Posted:2011-11-15 16:24 |
61039100
個人文章 個人相簿 個人日記 個人地圖
小人物
級別: 小人物 該用戶目前不上站
推文 x0 鮮花 x4
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片

回 覆 鎖 定 :

  此回覆已被鎖定,只有『管理員及回覆者』看的到 !!!



此文章被評分,最近評分記錄
財富:-250 (by ebolaman) | 理由: 胡亂灌水,總共五篇在此合併扣分(鎖回文)


獻花 x0 回到頂端 [3 樓] From:未知地址 | Posted:2011-12-28 14:24 |

首頁  發表文章 發表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.018668 second(s),query:16 Gzip disabled
本站由 瀛睿律師事務所 擔任常年法律顧問 | 免責聲明 | 本網站已依台灣網站內容分級規定處理 | 連絡我們 | 訪客留言