Ok probably going to make a major idiot out of myself but, lets say i have a tree, and it has x amount of wood in it, how would i make it so that if an entity like an axe collides with it, x=x-1, and y=y+1(y being playerinventory)and display x above the tree
I have a question
Blitz3D Forums/Blitz3D Beginners Area/I have a question You would loop through the collisions that the player's entity has made since the last updateworld command like this:
a really basic method is as follows:
Then after your renderworld but before your flip you might do something like this:
The code posted there should give you ideas hopefully. There are 1001 ways of doing this and that is just one of them.
a really basic method is as follows:
type TreeObject field EntityHandle field Wood end type for ColIndex=1 to CountCollisions(PlayerEntity) ColEntity=CollisionEntity(PlayerEntity,ColIndex) FoundTree=false For Tree.TreeObject=each TreeObject If Tree\EntityHandle=ColEntity then FoundTree=true:exit next If FoundTree=true then Tree\Wood=Tree\Wood-1:PlayerWood=PlayerWood+1 next
Then after your renderworld but before your flip you might do something like this:
For Tree.TreeObject=each TreeObject CameraProject Camera,EntityX(Tree\EntityHandle),EntityY(Tree\EntityHandle)+OffsetY#+EntityZ(Tree\EntityHandle) Text Projectedx(),Projectedy(),"Wood:"+Str(Tree\Wood) next
The code posted there should give you ideas hopefully. There are 1001 ways of doing this and that is just one of them.
What is entity handle, sorry for being an idiot
entityhandle, in that example, is the variable you assign to the mesh.
Ie.
mesh = loadmesh("mesh.b3d")
mesh would be the handle.
Ie.
mesh = loadmesh("mesh.b3d")
mesh would be the handle.
i am stupid
i should have known
where it says 'tree object' insert loadmesh and load a tree and that projected text will b above it? i am having trouble w/ dis whole thing
i should have known
where it says 'tree object' insert loadmesh and load a tree and that projected text will b above it? i am having trouble w/ dis whole thing
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:
Hope that helps a bit better.
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.
it does, thanks
& sorry
& sorry
a) Stop apologising and saying you're stupid. No one knows what's what to start with.
b) What matty says - ask questions here by all means, but studying some of the simple examples that come with blitz, reading up on the commands they use and playing with the code is definitely the best way to learn the language IMO.
c)Good luck!
b) What matty says - ask questions here by all means, but studying some of the simple examples that come with blitz, reading up on the commands they use and playing with the code is definitely the best way to learn the language IMO.
c)Good luck!