I'm not sure what your programming background/experience is like, but I would guess that maybe you are fairly new to programming? If so then you may want to try playing around with the samples that come with blitz, a large number of the commands are demonstrated in them.
Here is some sample code, like the one earlier, showing one possible way of coding it:
Graphics3D 800,600,0,2
Const COLLISIONTYPE_TREES=1,COLLISIONTYPE_PLAYER=2
camera=CreateCamera()
playerentity=CreateSphere()
EntityColor playerentity,255,100,100
MoveEntity camera,0,20,-20
PointEntity camera,playerentity
EntityParent camera,playerentity ;very very basic 3rd person camera with no smooth movement
EntityType PlayerEntity,COLLISIONTYPE_PLAYER ;assign the player an entitytype for purposes of collision
Type treeobject
Field entityhandle
Field wood
End Type
For i=1 To 10
tree.treeobject=New treeobject
tree\wood=Rand(1,100)
tree\entityhandle=CreateCube() ;replace with loadobject("tree.b3d") or similar
EntityColor tree\entityhandle,100,255,100
PositionEntity tree\entityhandle,Rand(-50,50),0,Rand(-50,50)
EntityType tree\entityhandle,COLLISIONTYPE_TREES
Next
Collisions COLLISIONTYPE_PLAYER,COLLISIONTYPE_TREES,1,2
Repeat
If MilliSecs()>GameTime Then ;very basic frame limiting
GameTime=MilliSecs()+33
If KeyDown(203) Then TranslateEntity playerentity,-0.5,0,0
If KeyDown(205) Then TranslateEntity playerentity,0.5,0,0
If KeyDown(200) Then TranslateEntity playerentity,0,0,0.5
If KeyDown(208) Then TranslateEntity playerentity,0,0,-0.5
EndIf
UpdateWorld
;check collisions as they are updated each time we call updateworld
For ColIndex=1 To CountCollisions(PlayerEntity)
For Tree.TreeObject=Each TreeObject
If Tree\EntityHandle=CollisionEntity(PlayerEntity,ColIndex) Then Tree\Wood=Tree\Wood-1
Next
Next
RenderWorld
;all 2d commands are usually placed after renderworld and before flip
For Tree.TreeObject=Each TreeObject
CameraProject Camera,EntityX(Tree\EntityHandle),EntityY(Tree\EntityHandle)+3.0,EntityZ(Tree\EntityHandle)
If ProjectedX()>0 And ProjectedY()>0 And ProjectedX()<GraphicsWidth() And ProjectedY()<GraphicsHeight() Then Text ProjectedX(),ProjectedY(),"Wood:"+Tree\Wood
Next
Flip
Until KeyDown(1)
FreeEntity camera
FreeEntity playerentity
For tree.treeobject=Each treeobject
FreeEntity tree\entityhandle
Delete tree
Next
End
Hope that helps a bit better.
|