function for type collide...
Blitz3D Forums/Blitz3D Beginners Area/function for type collide...
| ||
Ok heres the thing... i just begining a project game that is basicly you running around a world being able to shoot things with various weapons, pick up items, blah blah.. i wanted to make a function called "Is_Hit()" that would go something like: Function Is_Hit(entity) If EntityDistance (player1,entity) <= 1 Then Return True Else Return False EndIf End Function Now I want to use it in a function like: Function UpdateItems() For item.Items = Each Items If Is_Hit(????) Then ityp=item\typ Select ityp Case 0 ;do stuff if its a collectable for points Case 1 ;do stuff if its a powerup Case 2 ;do stuff if its a weapon Case ;3,4,5...blah End Select EndIf ;do other stuff like rotating objects and distance fading Next End Function Now what do i put in the ???? area above to pass the courent type to the function? Also it this a good start to A pickups function? Thanks all. Ed |
| ||
It depends what fields you have in your TYPE definition? But you need to pass the entity or mesh, so something like 'Item\Mesh' I guess. Btw, have you considered using 'Collisions' to detect this instead? Rhy :) |
| ||
Yah this part of my code is realy just psudo-code and im jeting some rules set down so i can design parts around them. the types just for this example asume anything you want. And as for the collisions, sure i could do that, i figured on this distance one so it would effectively create a "bubble" around a player so you wouldnt need to totaly match the items x,y,z to have an effect. Also i thought it would sorta "jump start" the pickup prossess if i have an animation for it. Its all in exparamentation night now. (+i need to work on my Collisions :P ) But lets see.. for the ??? i would need to put "item" maby? because the courently selected item could be refrenced by that word? or should i use "this"? (was looking as some code and saw some use of this in a select/case situation) |
| ||
Ok, here is an example TYPE definition TYPE Item Field Mesh% Field Typ% END TYPE Some constants to make code clearer Const HealthPack% = 1 Const Ammo% = 2 etc Then to create a new instance of that type Local Thing.Item = New Item Thing\Mesh = LoadMesh("HealthPack.b3d") Thing\Typ = HealthPack Then to check for collision If IsHit(Thing\Mesh) Then Select Thing\Typ Case HealthPack ;do stuff for health pack pickup etc Hope that helps, Rhy :) |