noob type help

Blitz3D Forums/Blitz3D Beginners Area/noob type help

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

oh well i didn't actually test it, i'll write an example now.


ok here's my example
Graphics3D 800,600,32
SetBuffer BackBuffer()

Type player
Field e;for entity
Field life
End Type

Global cam;makes it accessable in the function

;set up scene

cam=CreateCamera()
CreateLight();note this has no variable so we cant access this later but its still there

p.player=New player ;creates a list for the type
p\e=CreateCube(); creates a cube under the p\e var
p\life=100;sets p\e to 100
PositionEntity p\e,0,0,30;puts it 30 units infront of the camera
EntityPickMode p\e,2;sets it to be pickable
EntityColor p\e,234,65,107; sets a random color that i pulled out of a hat :)


While Not KeyHit(1)

pick_on_player();this is the function that uses the type

UpdateWorld
RenderWorld
Rect MouseX(),MouseY(),10,10,1
Flip
Wend
End


Function pick_on_player()


For p.player=Each player;access the type

If MouseHit(1)
If CameraPick(cam,MouseX(),MouseY()) = p\e Then

p\life = p\life - 2
CameraClsColor cam,235,65,78

EndIf
EndIf 

Next;loop to "p" or stop accessing the type

End Function