Gravity causes accelleration. To properly model accelleration, you need to keep track of the velocity of your entities. To keep track of additional information for an entity, use a TYPE:
Don't call TranslateEntity() directly anymore. Instead, modify the velocity of your physical_bodies and let the physics updating code in the loop move the entity for you.
P.S. Yes, there is a way to find the physical_body object that represents an entity, given only the entity (e.g. from a Pick.) To do so, store the object's Handle() in the entity's EntityName.
Const GRAVITY# = 0.02 Type physical_body Field entity ; each physical_body represents one entity Field vx#, vy#, vz# ; keep track of velocity End Type ; here's a simple constructor to make it easier to create objects Function create_physical_body.physical_body(entity) this.physical_body = New physical_body this\entity = entity Return this End Function ; don't work with entities directly: ;player = createcube() ;positionentity(player, 1, 2, 3) ; instead, create objects to store the entities: player.physical_body = create_physical_body( CreateCube() ) PositionEntity(player\entity, 1, 2, 3) ; game loop While Not(KeyHit(1)) ; update all physical_bodies For pb.physical_body = Each physical_body pb\vy = pb\vy + GRAVITY ; add gravity TranslateEntity(pb\entity, pb\vx, pb\vy, pb\vz) ; move entity Next ; update graphics RenderWorld Flip Wend
Don't call TranslateEntity() directly anymore. Instead, modify the velocity of your physical_bodies and let the physics updating code in the loop move the entity for you.
P.S. Yes, there is a way to find the physical_body object that represents an entity, given only the entity (e.g. from a Pick.) To do so, store the object's Handle() in the entity's EntityName.