Collision Help...

Blitz3D Forums/Blitz3D Beginners Area/Collision Help...

Here Is the real code, converted to blitz code.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; NEW PLAYER SHOOT FUNCTION
;; INCLUDES MULTI-HIT COMBO CHECKING
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
function PlayerShoot(p.player)

local mycounter,countx,countz,cntmulti
global centerpivot

;First store positions.
p\OldX = p\CurrX
p\OldZ = p\CurrZ

if p\direction = 4 then
  if getentitytype(centerpivot) <> 9 then
    centerpivot = createpivot()
    entitytype centerpivot,9
  endif

  positionentity centerpivot,p\CurrX * GX#,0,(p\CurrZ + 1)*GZ#
  pointentity p\bubble, centerpivot
  mycounter = 1
  repeat
   moveentity p\bubble,0,0,1
   mycounter = mycounter + 1
  until count collisions > 0 or mycounter > (p\CurrZ + 3) * GZ#
  for countx = 1 to 8
    for countz = 1 to 8
      if meshesintersect(p\bubble,fruitlevel(countx,countz)\item)=true then
        ;are we this item ?  If so, CheckMulti, and continue with function.
        if p\fruit = fruitlevel(countx,countz)\number then
          multi = CheckMulti()
        else
          ;okay we are not this item, so become it, and return to position.
          p\fruit = fruitlevel(countx,countz)\number
          p\bubble = copymesh(fruitlevel(countx,countz)\item)
          positionentity p\bubble,(p\OldX * GX#),0,(p\OldZ * GZ#)
          return
        endif
      endif
      if multi then
        ; go through multi array add up points and set those items in fruitlevel hidden.
        for cntmulti = 1 to multi
          p\points = p\points + multiarray(cntmulti)\points
          fruitlevel(multiarray(cntmulti)\x,multiarray(cntmulti)\z)\hidden = 1
        next
        ; clearing out the multi array items.
        for cntmulti = 1 to multi
          multiarray(cntmulti)\points = -1
          multiarray(cntmulti)\x = -1
          multiarray(cntmulti)\z = -1
        next
      else
        ;remove single item collided with
        fruitlevel(countx,countz)\hidden = 1
        p\points = p\points + fruitlevel(countx,countz)\points        
      endif
    next
  next
  
  for countx = 1 to 8
    for countz = 1 to 8
      if fruitlevel(x,z)\hidden = 1 then
        hideentity fruitlevel(x,z)\item
      endif
    next
  next

;return player to original location.
positionentity p\bubble,(p\OldX * GX#),0,(p\OldZ * GZ#)
;return back to main game loop.
return
endif

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Direction 1 or on TOP.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if p\direction = 1 then
  if getentitytype(centerpivot) <> 9 then
    centerpivot = createpivot()
    entitytype centerpivot,9
  endif

  positionentity centerpivot,p\CurrX * GX#,0,(p\CurrZ - 1)*GZ#
  pointentity p\bubble, centerpivot
  mycounter = 1
  repeat
   moveentity p\bubble,0,0,1
   mycounter = mycounter + 1
  until count collisions > 0 or mycounter > (p\CurrZ - 3) * GZ#
  for countx = 1 to 8
    for countz = 1 to 8
      if meshesintersect(p\bubble,fruitlevel(countx,countz)\item)=true then
        ;are we this item ?  If so, CheckMulti, and continue with function.
        if p\fruit = fruitlevel(countx,countz)\number then
          multi = CheckMulti()
        else
          ;okay we are not this item, so become it, and return to position.
          p\fruit = fruitlevel(countx,countz)\number
          p\bubble = copymesh(fruitlevel(countx,countz)\item)
          positionentity p\bubble,(p\OldX * GX#),0,(p\OldZ * GZ#)
          return
        endif
      endif
      if multi then
        ; go through multi array add up points and set those items in fruitlevel hidden.
        for cntmulti = 1 to multi
          p\points = p\points + multiarray(cntmulti)\points
          fruitlevel(multiarray(cntmulti)\x,multiarray(cntmulti)\z)\hidden = 1
        next
        ; clearing out the multi array items.
        for cntmulti = 1 to multi
          multiarray(cntmulti)\points = -1
          multiarray(cntmulti)\x = -1
          multiarray(cntmulti)\z = -1
        next
      else
        ;remove single item collided with
        fruitlevel(countx,countz)\hidden = 1
        p\points = p\points + fruitlevel(countx,countz)\points        
      endif
    next
  next
  
  for countx = 1 to 8
    for countz = 1 to 8
      if fruitlevel(x,z)\hidden = 1 then
        hideentity fruitlevel(x,z)\item
      endif
    next
  next

;return player to original location.
positionentity p\bubble,(p\OldX * GX#),0,(p\OldZ * GZ#)
;return back to main game loop.
return
endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Now Direction 2 or on left side...
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if p\direction = 2 then
  if getentitytype(centerpivot) <> 9 then
    centerpivot = createpivot()
    entitytype centerpivot,9
  endif

  positionentity centerpivot,(p\CurrX + 1) * GX#,0,p\CurrZ * GZ#
  pointentity p\bubble, centerpivot
  mycounter = 1
  repeat
   moveentity p\bubble,0,0,1
   mycounter = mycounter + 1
  until count collisions > 0 or mycounter > (p\CurrX + 3) * GX#
  for countx = 1 to 8
    for countz = 1 to 8
      if meshesintersect(p\bubble,fruitlevel(countx,countz)\item)=true then
        ;are we this item ?  If so, CheckMulti, and continue with function.
        if p\fruit = fruitlevel(countx,countz)\number then
          multi = CheckMulti()
        else
          ;okay we are not this item, so become it, and return to position.
          p\fruit = fruitlevel(countx,countz)\number
          p\bubble = copymesh(fruitlevel(countx,countz)\item)
          positionentity p\bubble,(p\OldX * GX#),0,(p\OldZ * GZ#)
          return
        endif
      endif
      if multi then
        ; go through multi array add up points and set those items in fruitlevel hidden.
        for cntmulti = 1 to multi
          p\points = p\points + multiarray(cntmulti)\points
          fruitlevel(multiarray(cntmulti)\x,multiarray(cntmulti)\z)\hidden = 1
        next
        ; clearing out the multi array items.
        for cntmulti = 1 to multi
          multiarray(cntmulti)\points = -1
          multiarray(cntmulti)\x = -1
          multiarray(cntmulti)\z = -1
        next
      else
        ;remove single item collided with
        fruitlevel(countx,countz)\hidden = 1
        p\points = p\points + fruitlevel(countx,countz)\points        
      endif
    next
  next
  
  for countx = 1 to 8
    for countz = 1 to 8
      if fruitlevel(x,z)\hidden = 1 then
        hideentity fruitlevel(x,z)\item
      endif
    next
  next

;return player to original location.
positionentity p\bubble,(p\OldX * GX#),0,(p\OldZ * GZ#)
;return back to main game loop.
return
endif

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Now Direction 3 or on right side...
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if p\direction = 3 then
  if getentitytype(centerpivot) <> 9 then
    centerpivot = createpivot()
    entitytype centerpivot,9
  endif

  positionentity centerpivot,(p\CurrX - 1) * GX#,0,p\CurrZ * GZ#
  pointentity p\bubble, centerpivot
  mycounter = 1
  repeat
   moveentity p\bubble,0,0,1
   mycounter = mycounter + 1
  until count collisions > 0 or mycounter > (p\CurrX - 3) * GX#
  for countx = 1 to 8
    for countz = 1 to 8
      if meshesintersect(p\bubble,fruitlevel(countx,countz)\item)=true then
        ;are we this item ?  If so, CheckMulti, and continue with function.
        if p\fruit = fruitlevel(countx,countz)\number then
          multi = CheckMulti()
        else
          ;okay we are not this item, so become it, and return to position.
          p\fruit = fruitlevel(countx,countz)\number
          p\bubble = copymesh(fruitlevel(countx,countz)\item)
          positionentity p\bubble,(p\OldX * GX#),0,(p\OldZ * GZ#)
          return
        endif
      endif
      if multi then
        ; go through multi array add up points and set those items in fruitlevel hidden.
        for cntmulti = 1 to multi
          p\points = p\points + multiarray(cntmulti)\points
          fruitlevel(multiarray(cntmulti)\x,multiarray(cntmulti)\z)\hidden = 1
        next
        ; clearing out the multi array items.
        for cntmulti = 1 to multi
          multiarray(cntmulti)\points = -1
          multiarray(cntmulti)\x = -1
          multiarray(cntmulti)\z = -1
        next
      else
        ;remove single item collided with
        fruitlevel(countx,countz)\hidden = 1
        p\points = p\points + fruitlevel(countx,countz)\points        
      endif
    next
  next
  
  for countx = 1 to 8
    for countz = 1 to 8
      if fruitlevel(x,z)\hidden = 1 then
        hideentity fruitlevel(x,z)\item
      endif
    next
  next

;return player to original location.
positionentity p\bubble,(p\OldX * GX#),0,(p\OldZ * GZ#)
;return back to main game loop.
return
endif

end function

function CheckMulti()
  return 0 ;for now place holder, never return multi-hits.
end function


Here is the updated post of the code, including a placeholder function which I need to figure out how to check for multi-items the same connected to the item I hit with the player bubble.

Anyone feel free to help out with this function, if you have any ideas how to make it work. I only want to check for at most 3 or 4 items connected including the item the player hits.

There UPDATED! 5/4/2004 6:58 Central time. Tell me what ya think now, and if you have any ideas how to do multi-combos again, I am open to suggestions. All 4 Directions added.

____________________________
[PKE] In The End, [PKE]
[PKE] [PKE]
[PKE] There Kan B Only 1,[PKE]
[PKE] [PKE]
[PKE] and May It B... [PKE]
\/\/\/\/\/\/\/\/\/\/\/\/\/\/
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
[PKE] Pain Killa Entertainment [PKE]
[PKE] Pain Is Reality. (tm) [PKE]
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
/\/\/\/\/\/\/\/\/\/\/\/\/\/\
[PKE]OWNER - Ken Cornett [PKE]
[PKE] [PKE]
[PKE] AUDIO - Gene Deel [PKE]
[PKE] [PKE]
[PKE]WEB - DAVE BERNSTEIN[PKE]
\/\/\/\/\/\/\/\/\/\/\/\/\/\/
_____________________________________________
|-=Copyright (c) 2004 - All Rights Reserved.=-|
=============================================