VB Code:
  1. Public Sub Collision()
  2.  
  3.  
  4.  
  5. For X = 1 To MaxBullets
  6.     With Bullet(X)
  7.         'makes sure it is visible, has moved, and can move
  8.         If .Visible = True And .Moved = True And .Move = True Then
  9.             'Gets rid of bullets outside of the arena (move to collision
  10.             If .Left > ArenaWidth Then
  11.                 BulletCollideEffects (X), ArenaWidth - .Width, .Top, plat(1), True
  12.             ElseIf .Left < 0 Then
  13.                 BulletCollideEffects (X), 0, .Top, plat(1), True
  14.             ElseIf .Top < 0 Then
  15.                 BulletCollideEffects (X), .Left, 0, plat(1), False
  16.             ElseIf .Top > ArenaHeight Then
  17.                 BulletCollideEffects (X), .Left, ArenaHeight - .Height, plat(1), False
  18.             End If
  19.        
  20.             If .Xinertia = 0 Then .Xinertia = 1 'prevent divide by 0
  21.             M = .Yinertia / .Xinertia 'find slope
  22.             If M = 0 Then M = 0.001 'prevent divide by 0
  23.             'y intercept for top left (b) and bottom right(bb)
  24.             B = (.Top - .Yinertia) - (M * (.Left - .Xinertia))
  25.             BB = ((.Top + .Height) - .Yinertia) - (M * ((.Left + .Width) - .Xinertia))
  26.            
  27.             For Y = 1 To PlatCount
  28.                
  29.                 If plat(Y).Visible Then
  30.                     'finds the point where it passes each side
  31.                     Ty = plat(Y).Top
  32.                     Tx = (B - Ty) / -M
  33.                     Tbx = (BB - Ty) / -M
  34.                    
  35.                     Hy = plat(Y).Top + plat(Y).Height
  36.                     Hx = (B - Hy) / -M
  37.                     Hbx = (BB - Hy) / -M
  38.                    
  39.                     Lx = plat(Y).Left
  40.                     Ly = M * Lx + B
  41.                     Lby = M * Lx + BB
  42.                    
  43.                     Wx = plat(Y).Left + plat(Y).Width
  44.                     Wy = M * Wx + B
  45.                     Wby = M * Wx + BB
  46.                    
  47.                     'makes sure that it crosses the line inside the block
  48.                     If Ly >= plat(Y).Top And Ly <= plat(Y).Top + plat(Y).Height And .Left >= Lx And .Left - .Xinertia <= Lx Then
  49.                             BulletCollideEffects (X), Lx - .Width, (Ly), plat(Y), True
  50.                            
  51.                     ElseIf Wy >= plat(Y).Top And Wy <= plat(Y).Top + plat(Y).Height And .Left <= Wx And .Left - .Xinertia >= Wx Then
  52.                         BulletCollideEffects (X), (Wx), (Wy), plat(Y), True
  53.                        
  54.                     ElseIf Lby >= plat(Y).Top And Lby <= plat(Y).Top + plat(Y).Height And .Left >= Lx And .Left - .Xinertia <= Lx Then
  55.                             BulletCollideEffects (X), Lx - .Width, Lby - .Height, plat(Y), True
  56.                            
  57.                     ElseIf Wby >= plat(Y).Top And Wby <= plat(Y).Top + plat(Y).Height And .Left <= Wx And .Left - .Xinertia >= Wx Then
  58.                         BulletCollideEffects (X), (Wx), Wby - .Height, plat(Y), True
  59.                        
  60.                     End If
  61.                        
  62.                    
  63.                            
  64.                     If Tx >= plat(Y).Left And Tx <= plat(Y).Left + plat(Y).Width And .Top >= Ty And .Top - .Yinertia <= Ty Then
  65.                             BulletCollideEffects (X), (Tx), Ty - .Height, plat(Y), False
  66.                            
  67.                     ElseIf Hx >= plat(Y).Left And Hx <= plat(Y).Left + plat(Y).Width And .Top <= Hy And .Top - .Yinertia >= Hy Then
  68.                         BulletCollideEffects (X), (Hx), (Hy), plat(Y), False
  69.                        
  70.                     ElseIf Tbx >= plat(Y).Left And Tbx <= plat(Y).Left + plat(Y).Width And .Top >= Ty And .Top - .Yinertia <= Ty Then
  71.                             BulletCollideEffects (X), Tbx - .Width, Ty - .Height, plat(Y), False
  72.                            
  73.                     ElseIf Hbx >= plat(Y).Left And Hbx <= plat(Y).Left + plat(Y).Width And .Top <= Hy And .Top - .Yinertia >= Hy Then
  74.                         BulletCollideEffects (X), Hbx - .Width, (Hy), plat(Y), False
  75.                        
  76.                     End If
  77.                    
  78.                 End If
  79.            
  80.             Next Y
  81.            
  82.             For Y = 1 To PlayerCount
  83.                
  84.                 If player(Y).Visible Then
  85.                     'finds the point where it passes each side
  86.                     Ty = player(Y).Top
  87.                     Tx = (B - Ty) / -M
  88.                     Tbx = (BB - Ty) / -M
  89.                    
  90.                     Hy = player(Y).Top + player(Y).Height
  91.                     Hx = (B - Hy) / -M
  92.                     Hbx = (BB - Hy) / -M
  93.                    
  94.                     Lx = player(Y).Left
  95.                     Ly = M * Lx + B
  96.                     Lby = M * Lx + BB
  97.                    
  98.                     Wx = player(Y).Left + player(Y).Width
  99.                     Wy = M * Wx + B
  100.                     Wby = M * Wx + BB
  101.                    
  102.                     'makes sure that it crosses the line inside the block
  103.                     If Ly >= player(Y).Top And Ly <= player(Y).Top + player(Y).Height And .Left >= Lx And .Left - .Xinertia <= Lx Then
  104.                             BulletCollideEffects (X), Lx - .Width, (Ly), player(Y), True
  105.                            
  106.                     ElseIf Wy >= player(Y).Top And Wy <= player(Y).Top + player(Y).Height And .Left <= Wx And .Left - .Xinertia >= Wx Then
  107.                         BulletCollideEffects (X), (Wx), (Wy), player(Y), True
  108.                        
  109.                     ElseIf Lby >= player(Y).Top And Lby <= player(Y).Top + player(Y).Height And .Left >= Lx And .Left - .Xinertia <= Lx Then
  110.                             BulletCollideEffects (X), Lx - .Width, Lby - .Height, player(Y), True
  111.                            
  112.                     ElseIf Wby >= player(Y).Top And Wby <= player(Y).Top + player(Y).Height And .Left <= Wx And .Left - .Xinertia >= Wx Then
  113.                         BulletCollideEffects (X), (Wx), Wby - .Height, player(Y), True
  114.                        
  115.                     End If
  116.                        
  117.                    
  118.                            
  119.                     If Tx >= player(Y).Left And Tx <= player(Y).Left + player(Y).Width And .Top >= Ty And .Top - .Yinertia <= Ty Then
  120.                             BulletCollideEffects (X), (Tx), Ty - .Height, player(Y), False
  121.                            
  122.                     ElseIf Hx >= player(Y).Left And Hx <= player(Y).Left + player(Y).Width And .Top <= Hy And .Top - .Yinertia >= Hy Then
  123.                         BulletCollideEffects (X), (Hx), (Hy), player(Y), False
  124.                        
  125.                     ElseIf Tbx >= player(Y).Left And Tbx <= player(Y).Left + player(Y).Width And .Top >= Ty And .Top - .Yinertia <= Ty Then
  126.                             BulletCollideEffects (X), Tbx - .Width, Ty - .Height, player(Y), False
  127.                            
  128.                     ElseIf Hbx >= player(Y).Left And Hbx <= player(Y).Left + player(Y).Width And .Top <= Hy And .Top - .Yinertia >= Hy Then
  129.                         BulletCollideEffects (X), Hbx - .Width, (Hy), player(Y), False
  130.                        
  131.                     End If
  132.                    
  133.                 End If
  134.            
  135.             Next Y
  136.            
  137.            
  138.            
  139.         End If
  140.        
  141.         If Bullet(X).Type = 1 Then
  142.             For Y = 1 To PlayerCount
  143.                 If collide(Bullet(X), player(Y)) = True And Bullet(X).Belong <> (Y) And Bullet(X).Visible = True Then
  144.                     player(Y).Xinertia = Bullet(X).Xinertia
  145.                     player(Y).Yinertia = Bullet(X).Yinertia
  146.                     player(Y).Life = player(Y).Life - GT(1).Power
  147.                 End If
  148.             Next Y
  149.         End If
  150.        
  151.         If .Visible And .Kiboshed Then
  152.             For Y = 1 To PlayerCount
  153.                 If player(Y).OnFire = False And player(Y).Visible And collide(player(Y), Bullet(X)) And GT(.Type).Explode Then
  154.                      CenterX = .Left + (.Width / 2)
  155.                      CenterY = .Top + (.Height / 2)
  156.                      CenterX2 = player(Y).Left + (player(Y).Width / 2)
  157.                      CenterY2 = player(Y).Top + (player(Y).Height / 2)
  158.                      
  159.                      'absolute of cursor position
  160.                     XXX = Abs(CenterX2 - CenterX)
  161.                     YYY = Abs(CenterY - CenterY2)
  162.                      
  163.                     'Makes sure you do not divide by 0
  164.                     If XXX = 0 Then
  165.                          Angle = 0
  166.                     Else
  167.                         'find angle
  168.                          Angle = Atn(YYY / XXX)
  169.                     End If
  170.                    
  171.                     'finds absolute x and y aim
  172.                     XXX = RR * Cos(Angle)
  173.                     YYY = RR * Sin(Angle)
  174.                    
  175.                     'Sets result aiming co-ordinates
  176.                     player(Y).Xinertia = Sgn(CenterX2 - CenterX) * XXX / 20
  177.                     player(Y).Yinertia = (Sgn(CenterY2 - CenterY) * YYY) / 20
  178.                    
  179.                     'other effects
  180.                     player(Y).OnFire = True
  181.                     player(Y).Firetime = 40
  182.                     player(Y).Life = player(Y).Life - 10
  183.                 End If
  184.             Next Y
  185.         End If
  186.     End With
  187. Next X

This is my collision sub, it checks (almost) every collision in my game however it is VERY redundant as you can see but i cant figure out how to shrink it

also note that collide is a function elsewhere in the code for finding if two things are actually touching where the majority of this code is for objects moving over something and finding if and where they should have hit

and if you were wondering, that is the bulletcollideeffects sub