Fast collision mapping?

BlitzPlus Forums/BlitzPlus Programming/Fast collision mapping?

Regular K(Posted 2005) [#1]
I am wanting to have fast bullets in my game, but to do that without them going through walls with detection I would need collision mapping!

I tried the collision mapping in the archives (http://www.blitzbasic.com/codearcs/codearcs.php?code=1099) but it isnt fast enough.

There could be anywhere from 100 to 10,000 walls existing (not in screen) at once.

Any ideas are welcome, thanks :)


Grey Alien(Posted 2005) [#2]
You could increase the frame rate and move the bullet by proportioanlly less each frame so that it never moves faster than a wall thickness, or make the walls thicker.

Or implement a timing loop that goes very fast like 200-500 frames per second but doesn't actually draw anything, then chuck out a frame when you need to. This way the bullet can move a small amount each time and will always collide.
I use this method to great sucess after reading some of the posts about frame independant timing loops on this forum.


Regular K(Posted 2005) [#3]
I will do some experiments trying that, thanks.


Bot Builder(Posted 2005) [#4]
Why even have bullett objects or anything at all? just do a line pick or equivalent.


Grey Alien(Posted 2005) [#5]
What do you mean "line pick" ? Like a vuass cannon or something i.e. instant hit?


Regular K(Posted 2005) [#6]
This is in the BlitzPlus forum, so, this is obviously being made in BlitzPlus.


starfox(Posted 2005) [#7]
Ok, line intersect then

code here
Function Ray2dintersect(x1,y1,x2,y2,x3,y3,x4,y4)
  d# = (y4-y3)*(x2-x1) - (x4-x3)*(y2-y1)
  If d = 0 Then Return 0
  ua# =((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / d#
  ub# =((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / d#
  If (ua# >= 0.0) And (ub# >= 0.0) And (ub# <= 1.0)
	intersectedx#=x1+ua*(x2-x1)
	intersectedy#=y1+ua*(y2-y1)
	Return 1
  EndIf
Return 0
End Function