# Collisions Aren't Working Properly

Page 1 of 1

## 1 Replies - 514 Views - Last Post: 15 November 2012 - 07:57 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=300378&amp;s=2d4135bf9b7dd6838fb58b9b908bc17a&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 DimitriV

• vexing conundrum

Reputation: 587
• Posts: 2,746
• Joined: 24-July 11

# Collisions Aren't Working Properly

Posted 15 November 2012 - 04:24 PM

```
For i As Integer = 0 To objects.Count - 1
objects(i).DrawLocation = New Point(objects(i).DrawLocation.X, objects(i).DrawLocation.Y - 16)

If New Rectangle(objects(i).DrawLocation.X, objects(i).DrawLocation.Y, 32, 32).IntersectsWith(New Rectangle(playerRect.X, playerRect.Y + 64, 32, 0)) Then

If Not objects(i).Transparent = True And Not objects(i).Btype = "air" Then
graph.DrawRectangle(Pens.Black, playerRect)
graph.FillRectangle(Brushes.Chartreuse, playerRect)
fall = False
Debug.WriteLine("collision")

Else

graph.DrawRectangle(Pens.Black, playerRect)
graph.FillRectangle(Brushes.Chartreuse, playerRect)
fall = True
End If

If fall = True Then
Else
REM Deutsch
' Deutsch
For ni = 0 To i
objects(i).DrawLocation = New Point(objects(i).DrawLocation.X, objects(i).DrawLocation.Y + 16)
Next
Exit For
End If

End If

Next

```

Hey guys
I've been hard at work recently on a certain kind of graivity for my game. I got the actual player to move, but now I am trying to instead get the blocks to move. This is proving to be a bit of an issue. What I really want is, as soon as the player hits a non-transparent block or air the blocks will stop moving and it will arrange itself properly. What happens is this...

It is not working the way it's supposed to. I've done what I can but nothing works so I have decided to come to you. I'll keep working on it in the meantime but I hope someone can help me out.

Thanks

Is This A Good Question/Topic? 0

## Replies To: Collisions Aren't Working Properly

### #2 _HAWK_

• Master(Of Foo)

Reputation: 1162
• Posts: 4,444
• Joined: 02-July 08

## Re: Collisions Aren't Working Properly

Posted 15 November 2012 - 07:57 PM

Sorry, that picture does not tell me anything - not sure what to look at. Here is a poss solution, as a guess, the thing about IntersectsWith it checks the rectangle in question - probably the one your moving. Instead create a fake rectangle that would be the new move - if that one IntersectsWith the one your checking(wall, unmovable space, etc...) then cancel the move procedure. Think of it this way, you are setting a new location not moving the player 1 pixel at a time - right? so IntersectWith only knows the new location - which of course could be any number of pixel into the wrong spot before it catches it.