paddle collision
paddle collision
paddle collision
paddle collision
paddle collision
paddle collision paddle collision paddle collision paddle collision paddle collision paddle collision paddle collision paddle collision
paddle collision paddle collision
paddle collision
Go Back  Xtreme Visual Basic Talk > > > paddle collision


Reply
 
Thread Tools Display Modes
  #1  
Old 05-02-2011, 10:18 AM
ztomtomz ztomtomz is offline
Newcomer
 
Join Date: Nov 2010
Posts: 13
Default paddle collision


my paddle width is 120,
i am trying to get a paddle on a brick breaker game to work but all that seems to happen is it keeps going though the middle of the paddle can anyone help me out
Code:
If ball.style.posTop + ball.height > padd.style.posTop  Then
    If  ball.style.posLeft + ball.width >= padd.style.posleft + 41 Then
    If ball.style.posLeft <= (padd.style.posleft + padd.width)-41  Then
     yInc= - yInc - 1
     end if
     end if
     end if
   'collison right
     If ball.style.posTop + ball.height > padd.style.posTop  Then
    If ball.style.posLeft + ball.width  >= (padd.style.posleft + padd.width)-40 Then
    If ball.style.posLeft <= padd.style.posleft + padd.width  Then
     yInc= - yInc - 1
     xInc = 3
    End If
    End if
    end if
    'collison left
   If ball.style.posTop + ball.height > padd.style.posTop  Then
   If ball.style.posLeft + ball.width >= padd.style.posleft  Then
   If ball.style.posLeft <= padd.style.posleft + 40 Then

    yInc= -yInc - 1 
    xInc = -3 
  End If
  End if
  end if

Last edited by Cerian Knight; 05-03-2011 at 08:01 AM. Reason: Added [code]...[/code] tags
Reply With Quote
  #2  
Old 05-03-2011, 08:05 AM
Cerian Knight's Avatar
Cerian Knightpaddle collision Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,199
Default

Set a break point to verify that your code detects the collision. Once collision is detected you must move the ball away from the paddle so it is no longer in a collision state and reverse the direction vector before allowing the ball to continue moving.

What language is this (e.g., VB6, VB.NET)?
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
  #3  
Old 05-03-2011, 08:41 AM
ztomtomz ztomtomz is offline
Newcomer
 
Join Date: Nov 2010
Posts: 13
Default

I am writing in vb.net and yeah ive already got it to do that ive got a timer set and xInc=2 and yInc=3 so once it collides with the paddle its bouncing off but it still manages to go down the gaps between where it bounces of to the left and middle and also the right and middle. im not sure if im going at this all wrong
Reply With Quote
  #4  
Old 05-05-2011, 05:26 AM
masterpreenx masterpreenx is offline
Newcomer
 
Join Date: Sep 2010
Location: Davao City Philippines
Posts: 24
Default

if collision is already occurred and the ball changes direction but still manages to go down. why don't you change its speed to negative value. negative value means going upward on Y axis.

thus changing this when collision is occurred

yInc= -3

where it goes upward.
Reply With Quote
  #5  
Old 05-05-2011, 10:14 AM
Cerian Knight's Avatar
Cerian Knightpaddle collision Cerian Knight is offline
Polymath (in disciplina)

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 4,199
Default

If necessary, perhaps add a 'ignore paddle locking flag' with a timeout so that the direction cannot be reversed again by re-collision with the paddle.
__________________
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
paddle collision
paddle collision
paddle collision paddle collision
paddle collision
paddle collision
paddle collision paddle collision paddle collision paddle collision paddle collision paddle collision paddle collision
paddle collision
paddle collision
 
paddle collision
paddle collision
 
-->