Ooops
January 15, 2021, 06:34:53 PM

Author Topic: [bb] Basic Cannonballs Physics 3D by Erroneouss [ 1+ years ago ]  (Read 408 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : Basic Cannonballs Physics 3D
Author : Erroneouss
Posted : 1+ years ago

Description : .

Code :
Code: BlitzBasic
  1. .


Comments :


Techlord(Posted 1+ years ago)

 This code snippet could be useful for creating a game like the world famous qbasic's: Gorillas. Adjusting the angle and speed of the cannonball would be required.


MErren(Posted 1+ years ago)

 Nice Work! Short and OK.Look also to my Prg, it may help for more.<a href="codearcs7a54.html?code=1164" target="_blank">http://www.blitzbasic.com/codearcs/codearcs.php?code=1164[/url]feel inspired.


Matty(Posted 1+ years ago)

 "theduck" - here is a more general equation for what you are doing.  new y = -0.5*gravity*time*time + initial y velocity * time + initial y positionnew x position = initial x position + time* intial velocity in x directionnew z position = initial z position + time* initial velocity in z directionIf you use a scale of 1 blitz unit = 1 metre then gravity should be (for Earth) 9.8.Time is usually measured in seconds elapsed since cannon ball fired.initial x, y ,z positions are the position of the ball prior to being fired.This assumes a constant acceleration due to gravity as well as no air resistance.initial x,y,z velocities are the velocities of the cannon ball in those directions as it is fired.


RustyKristi(Posted 8 months ago)

 For posterity, I found this code that was deleted above on archive site.
Code: [Select]
Type cannonball
 Field x
 Field y
 Field cube
End Type


Graphics3D 640,480,16,2
SetBuffer(BackBuffer())

cam=CreateCamera()
MoveEntity cam,35,10,-70

c.cannonball=New cannonball
ccube=CreateSphere()


While True
If KeyHit(57) c.cannonball=New cannonball:ccube=CreateSphere():cx=0:cy=0

For c.cannonball=Each cannonball
cy=(-0.01347*cx*cx+0.9325*cx+5.5)*2
cx=cx+1
PositionEntity ccube,cx,cy,0  
Next

RenderWorld
Flip
Wend



Dan(Posted 8 months ago)

 The code does not free the Sphere/Type when it goes offscreen.Here is a fix for this:
Code: [Select]
Type cannonball
Field x
Field y
Field cube
End Type


Graphics3D 640,480,32,2
SetBuffer(BackBuffer())

cam=CreateCamera()
MoveEntity cam,35,10,-70

c.cannonball=New cannonball
ccube=CreateSphere()


While True
If KeyHit(57) c.cannonball=New cannonball:ccube=CreateSphere():cx=0:cy=0
p=0
For c.cannonball=Each cannonball
p=p+1
cy=(-0.01347*cx*cx+0.9325*cx+5.5)*2
cx=cx+1
PositionEntity ccube,cx,cy,0

If cy<0
 FreeEntity ccube
 Delete c
EndIf
Next

RenderWorld
Text 0,0,"Active Cannonballs="+p
Flip (1)
Wend


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal