Bowling game?

Blitz3D Forums/Blitz3D Programming/Bowling game?

jeffmorris(Posted 2006) [#1]
I wish to create a bowling game using Blitz BASIC 3D. I may have to use Blitz-ODE or JV-ODE. Bowling lanes are 62 feet and 10-3/16 inches long and 41-1/2 inches wide. Gutters (I hate them) are on either side of the bowling lane. Approach lanes are 15 feet long. Foul lines are 3/8" to 1" wide. The distance between foul line and the first pin is 60 feet. 10 bowling pins are set 12 inches apart in a triangle pattern. Pins are 15 inches high and 4-3/4 inches wide, and weigh 3 pounds and 8 oz. Balls are 8-1/2 inches in diameter and weigh between 6 and 16 pounds. I found out that there is a form of bowling that uses bumpers instead of gutters and I wish to create that kind of bowling game.


simonh(Posted 2006) [#2]
Um, what are you asking?


WolRon(Posted 2006) [#3]
He's not asking anything. He's simply stating facts...

That's a new phenomenon going around lately; not asking questions, just making statements. See, notice there's not a single question mark in his entire statement?

I too, wish to create a bowling game, much like the one in Super Monkey Ball, with all of the weird lanes and such.

:)

Anybody else wishing to make a game?


octothorpe(Posted 2006) [#4]
Perhaps this belongs here?

http://blitzbasic.com/logs/userlog.php?user=9213


jeffmorris(Posted 2006) [#5]
How do I create a bowling game? I tried to create the bowling game using the sample programs that came with Blitz-ODE and JV-ODE but I ran into problems.


Shifty Geezer(Posted 2006) [#6]
Um, you may want to explain what the problems were. Just 'I had problems' isn't going to get you any answers.

The basics of a bowling game should be a doddle to setup with JV-ODE once you've spent time learning how to use it. Even with custom collision meshes for the pins. And if your problem is with ODE, yuou'd be better off talking about it in the userlibs forum.


WolRon(Posted 2006) [#7]
jeffmorris, you need to ask SPECIFIC questions.

Nobody has the time or ambition to explain everything there is to know about 'making a bowling game'.

For example, in your first post in this thread, you states all kinds of dimensions, so it appears that you want to know how to set up your game objects with those dimensions. If that's what you wanted, then you should have asked:
How do I get all of my game objects to approximately the same size in relation to the objects in a real bowling alley?

To which I might reply:
"UNIT"s in blitz are arbitrary. They have no definite size. Many people use the standard rule that 1 blitx unit is equal to 1 meter. But that's just a guideline and if something else suits you better you can use something else. For example, a lot of your dimensions use feet and inches. Since it's kind of hard to divide a unit up into 12 inches (1 inch would equal 0.0833333333 units), I would sway away from making 1 foot = 1 unit. 1 inch equaling 1 unit would probably be the best ratio. Your longest object (the lane) would be 754-3/16 units long, which isn't any outrageous scale.


octothorpe(Posted 2006) [#8]
Also, this is precisely what this forum is for.

Feel free to say: "here is the type of game I want to make and I have no idea how to start, please help!"


jeffmorris(Posted 2006) [#9]
I took one of the sample programs (JV-ODE - Capped Cylinders Demo) that came with Blitz-ODE and JV-ODE and tried to modify it but the program didn't place 10 pins in a triangle pattern. The program placed 10 pins in a row and caused the pins to fall down.


jhocking(Posted 2006) [#10]
"Tried to modify it" is pretty vague. What did you do?


jeffmorris(Posted 2006) [#11]
I wrote a new program that places 10 cylinders at the end of the bowling lane and a sphere at the beginning of the lane. Pressing the up arrow key causes the ball to run to the cylinders. Here's the code:

Graphics3D 800,600 
SetBuffer BackBuffer() 
camera=CreateCamera()
CameraClsColor camera,239,239,239 
PositionEntity camera,0,25,-25
light=CreateLight() 
RotateEntity light,0,90,0
plane=CreatePlane()
EntityColor plane,255,128,0
pin=CreateCylinder(16)
EntityColor pin,255,255,255
ScaleMesh pin,2.5,15,2.5
PositionEntity pin,0,7.5,720
CopyEntity(pin)
PositionEntity pin,6,7.5,732
CopyEntity(pin)
PositionEntity pin,-6,7.5,732
CopyEntity(pin)
PositionEntity pin,0,7.5,744
CopyEntity(pin)
PositionEntity pin,12,7.5,744
CopyEntity(pin)
PositionEntity pin,-12,7.5,744
CopyEntity(pin)
PositionEntity pin,6,7.5,756
CopyEntity(pin)
PositionEntity pin,-6,7.5,756
CopyEntity(pin)
PositionEntity pin,18,7.5,756
CopyEntity(pin)
PositionEntity pin,-18,7.5,756
ball=CreateSphere(16)
EntityColor ball,63,63,63
ScaleMesh ball,4.25,4.25,4.25
PositionEntity ball,0,4.25,0
While Not KeyDown( 1 ) 
 If KeyDown( 200 )=True Then MoveEntity ball,0,0,0.25
 RenderWorld 
 Flip 
Wend 
End



WolRon(Posted 2006) [#12]
You keep moving 'pin'. If you want to move each pin copy, you need to name them.

pin2 = CopyEntity(pin)
PositionEntity pin2,6,7.5,732



octothorpe(Posted 2006) [#13]
There's nothing wrong with jeffmorris's approach as it currently stands:

- create pin_x
- move pin_x to spot #1
- copy pin_x (the copy becomes pin #1)
- move pin_x to spot #2
- copy pin_x (the copy becomes pin #2)
...
- move pin_x to spot #10 (and there it stays as pin #10)


Shifty Geezer(Posted 2006) [#14]
jeffmoris : No offence but I think you're in way over your head. You should be assigning the copied entities to variables so you can manage your pins, such as using an array. You'll need collision detection and response. In the case of ODE which will manage this nicely, you'll want a custom type to structure the various objects. Then you'll need to refine the ODE settings to get the resonses you want.

You have a lot to learn...

Basically you need an understanding of objects and managing them. I don't know what tutorials there are on the matter to illustrate why this is important. These are beginner questions though and you should go to the Beginners Fourm to ask them. And when asking questions, actually ask questions! Have a 'Where, When, Why, Who or How' in your message and a question mark at the end.


jeffmorris(Posted 2006) [#15]
Where do I find documents on using JV-ODE? I modified "JV-ODE Car Demo" program and got it to place ten cylinders in triangle pattern but I don't know how to replace the car with five objects with the bowling ball which is a sphere. Is it possible to name the cylinders so that they have different names?

AppTitle "JV-ODE Car Demo"
Include "JV-ODE.bb"
Graphics3D 800,600,0,2
Global CMass#=200			; ### Car Mass
Global WMass#=8				; ### Wheel Mass
Global WorldERP#=1			; ### World Error Correction
Global WorldFriction#=64	; ### World Friction
Global HingeTorque#=24		; ### Hinge Torque
Global SuspensionHS#=0.01	; ### Hinge Suspension Hardness/Softness (Higher=Softer - Lower=Harder)
Global Speed#=0
Global Steer#=0
Global Car
Global CGeom
Global CMesh
Global CarStartY=20
Dim Wheel(4)
Dim WGeom(4)
Dim Joint(4)
Type ODEGeom
	Field body
	Field geom
	Field mesh
End Type
Global World=dWorldCreate()
Global Space=dHashSpaceCreate(0)
Global ContactGroup=dJointGroupCreate(0)
dWorldSetAutoDisableFlag(World,1)
dWorldSetGravity(World,0,-0.98,0)
dWorldSetERP(World,WorldERP)
dContactSetMode(dContactSlip1)
dContactSetMu(WorldFriction)

ode.ODEGeom=New ODEGeom
ode\body=dBodyCreate(World)
Car=ode\body
dBodySetRotation(ode\body,0,0,0)
dBodySetPosition(ode\body,0,CarStartY,0)
mass=dMassCreate()
dMassSetBox(mass,1,3,1,4)
dMassSetBoxTotal(mass,CMass,3,1,4)
dMassTranslate(mass,0,-1,0)
dBodySetMass(ode\body,mass)
dMassDestroy(mass)
ode\geom=dCreateBox(Space,3,1,4)
CGeom=ode\geom
dGeomSetBody(ode\geom,ode\body)
ode\mesh=CreateCube()
CMesh=ode\mesh
ScaleMesh ode\mesh,1.5,0.5,2
RotateMesh ode\mesh,0,0,0
PositionMesh ode\mesh,0,0,0
EntityColor ode\mesh,40,80,255
EntityAlpha ode\mesh,1
For count=1 To 4
	ode.ODEGeom=New ODEGeom
	ode\body=dBodyCreate(World)
	Wheel(count)=ode\body
	dBodySetRotation(ode\body,0,0,0)
	dBodySetPosition(ode\body,0,0,0)
	mass=dMassCreate()
	dMassSetSphere(mass,1,0.7)
	dMassSetSphereTotal(mass,WMass,0.7)
	dBodySetMass(ode\body,mass)
	dMassDestroy(mass)
	ode\geom=dCreateSphere(Space,0.7)
	WGeom(count)=ode\geom
	dGeomSetBody(ode\geom,ode\body)
	ode\mesh=CreateCylinder(8)
	ScaleMesh ode\mesh,0.7,0.25,0.7
	RotateMesh ode\mesh,0,0,90
	PositionMesh ode\mesh,0,0,0
	EntityColor ode\mesh,255,255,255
Next
dBodySetPosition(Wheel(1),-2,CarStartY-0.5,+2)
dBodySetPosition(Wheel(2),+2,CarStartY-0.5,+2)
dBodySetPosition(Wheel(3),-2,CarStartY-0.5,-2)
dBodySetPosition(Wheel(4),+2,CarStartY-0.5,-2)

SeedRnd MilliSecs()

ode.ODEGeom=New ODEGeom
ode\body=dBodyCreate(World)
dBodySetRotation(ode\body,90,0,0)
dBodySetPosition(ode\body,0,30,100)
ode\geom=dCreateCCylinder(Space,1,8)
dGeomSetBody(ode\geom,ode\body)
ode\mesh=CreateCylinder(8)
ScaleMesh ode\mesh,2,10,2
RotateMesh ode\mesh,90,0,0
PositionMesh ode\mesh,0,0,0
EntityColor ode\mesh,Rnd(255),Rnd(255),Rnd(255)
EntityAlpha ode\mesh,1
EntityShininess ode\mesh,0.7

ode.ODEGeom=New ODEGeom
ode\body=dBodyCreate(World)
dBodySetRotation(ode\body,90,0,0)
dBodySetPosition(ode\body,6,30,112)
ode\geom=dCreateCCylinder(Space,1,8)
dGeomSetBody(ode\geom,ode\body)
ode\mesh=CreateCylinder(8)
ScaleMesh ode\mesh,2,10,2
RotateMesh ode\mesh,90,0,0
PositionMesh ode\mesh,0,0,0
EntityColor ode\mesh,Rnd(255),Rnd(255),Rnd(255)
EntityAlpha ode\mesh,1
EntityShininess ode\mesh,0.7

ode.ODEGeom=New ODEGeom
ode\body=dBodyCreate(World)
dBodySetRotation(ode\body,90,0,0)
dBodySetPosition(ode\body,-6,30,112)
ode\geom=dCreateCCylinder(Space,1,8)
dGeomSetBody(ode\geom,ode\body)
ode\mesh=CreateCylinder(8)
ScaleMesh ode\mesh,2,10,2
RotateMesh ode\mesh,90,0,0
PositionMesh ode\mesh,0,0,0
EntityColor ode\mesh,Rnd(255),Rnd(255),Rnd(255)
EntityAlpha ode\mesh,1
EntityShininess ode\mesh,0.7

ode.ODEGeom=New ODEGeom
ode\body=dBodyCreate(World)
dBodySetRotation(ode\body,90,0,0)
dBodySetPosition(ode\body,0,30,124)
ode\geom=dCreateCCylinder(Space,1,8)
dGeomSetBody(ode\geom,ode\body)
ode\mesh=CreateCylinder(8)
ScaleMesh ode\mesh,2,10,2
RotateMesh ode\mesh,90,0,0
PositionMesh ode\mesh,0,0,0
EntityColor ode\mesh,Rnd(255),Rnd(255),Rnd(255)
EntityAlpha ode\mesh,1
EntityShininess ode\mesh,0.7

ode.ODEGeom=New ODEGeom
ode\body=dBodyCreate(World)
dBodySetRotation(ode\body,90,0,0)
dBodySetPosition(ode\body,12,30,124)
ode\geom=dCreateCCylinder(Space,1,8)
dGeomSetBody(ode\geom,ode\body)
ode\mesh=CreateCylinder(8)
ScaleMesh ode\mesh,2,10,2
RotateMesh ode\mesh,90,0,0
PositionMesh ode\mesh,0,0,0
EntityColor ode\mesh,Rnd(255),Rnd(255),Rnd(255)
EntityAlpha ode\mesh,1
EntityShininess ode\mesh,0.7

ode.ODEGeom=New ODEGeom
ode\body=dBodyCreate(World)
dBodySetRotation(ode\body,90,0,0)
dBodySetPosition(ode\body,-12,30,124)
ode\geom=dCreateCCylinder(Space,1,8)
dGeomSetBody(ode\geom,ode\body)
ode\mesh=CreateCylinder(8)
ScaleMesh ode\mesh,2,10,2
RotateMesh ode\mesh,90,0,0
PositionMesh ode\mesh,0,0,0
EntityColor ode\mesh,Rnd(255),Rnd(255),Rnd(255)
EntityAlpha ode\mesh,1
EntityShininess ode\mesh,0.7

ode.ODEGeom=New ODEGeom
ode\body=dBodyCreate(World)
dBodySetRotation(ode\body,90,0,0)
dBodySetPosition(ode\body,6,30,136)
ode\geom=dCreateCCylinder(Space,1,8)
dGeomSetBody(ode\geom,ode\body)
ode\mesh=CreateCylinder(8)
ScaleMesh ode\mesh,2,10,2
RotateMesh ode\mesh,90,0,0
PositionMesh ode\mesh,0,0,0
EntityColor ode\mesh,Rnd(255),Rnd(255),Rnd(255)
EntityAlpha ode\mesh,1
EntityShininess ode\mesh,0.7

ode.ODEGeom=New ODEGeom
ode\body=dBodyCreate(World)
dBodySetRotation(ode\body,90,0,0)
dBodySetPosition(ode\body,-6,30,136)
ode\geom=dCreateCCylinder(Space,1,8)
dGeomSetBody(ode\geom,ode\body)
ode\mesh=CreateCylinder(8)
ScaleMesh ode\mesh,2,10,2
RotateMesh ode\mesh,90,0,0
PositionMesh ode\mesh,0,0,0
EntityColor ode\mesh,Rnd(255),Rnd(255),Rnd(255)
EntityAlpha ode\mesh,1
EntityShininess ode\mesh,0.7

ode.ODEGeom=New ODEGeom
ode\body=dBodyCreate(World)
dBodySetRotation(ode\body,90,0,0)
dBodySetPosition(ode\body,18,30,136)
ode\geom=dCreateCCylinder(Space,1,8)
dGeomSetBody(ode\geom,ode\body)
ode\mesh=CreateCylinder(8)
ScaleMesh ode\mesh,2,10,2
RotateMesh ode\mesh,90,0,0
PositionMesh ode\mesh,0,0,0
EntityColor ode\mesh,Rnd(255),Rnd(255),Rnd(255)
EntityAlpha ode\mesh,1
EntityShininess ode\mesh,0.7

ode.ODEGeom=New ODEGeom
ode\body=dBodyCreate(World)
dBodySetRotation(ode\body,90,0,0)
dBodySetPosition(ode\body,-18,30,136)
ode\geom=dCreateCCylinder(Space,1,8)
dGeomSetBody(ode\geom,ode\body)
ode\mesh=CreateCylinder(8)
ScaleMesh ode\mesh,2,10,2
RotateMesh ode\mesh,90,0,0
PositionMesh ode\mesh,0,0,0
EntityColor ode\mesh,Rnd(255),Rnd(255),Rnd(255)
EntityAlpha ode\mesh,1
EntityShininess ode\mesh,0.7

Global Light=CreateLight()
RotateEntity Light,45,-90,0
LightColor Light,255,255,255
AmbientLight 130,130,130
Global CameraPivot=CreatePivot(CMesh)
PositionEntity CameraPivot,0,10,-10
Global Camera=CreateCamera()
CameraClsColor Camera,0,0,0
CameraRange Camera,1,1000
dCreatePlane(Space,0,1,0,0)
Plane=CreatePlane()
EntityAlpha Plane,0.8
PlaneTexture=CreateTexture(128,128,9)
ClsColor 0,200,80
Cls
Color 255,255,255
Rect 0,0,64,64,1
Rect 64,64,64,64,1
CopyRect 0,0,128,128,0,0,BackBuffer(),TextureBuffer(PlaneTexture)
ScaleTexture PlaneTexture,20,20
EntityTexture Plane,PlaneTexture,0,0
Mirror=CreateMirror()
SetupCar()
While Not KeyHit(1)
	UpdateKeys()
	PTime=MilliSecs()
	UpdateCar()
	UpdateGeoms()
	dSpaceCollide(Space,World,ContactGroup)
	dWorldQuickStep(World,0.1)
	dJointGroupEmpty(ContactGroup)
	PhysicsTime#=MilliSecs()-PTime
	UpdateCam()
	UpdateWorld
	RenderWorld
	Text 0,0,"JV-ODE Version "+dGetVersion()
	Text 0,15,"Physics Time:"+PhysicsTime
	Text 0,30,"Car Speed:"+Speed
	Text 640,0,"A - Accelerate"
	Text 640,15,"Z - Brake/Reverse"
	Text 640,30,"Arrows - Steering"
	Text 640,45,"Space - Reset Car"
	Flip
Wend
dJointGroupDestroy(ContactGroup)
dSpaceDestroy(Space)
dWorldDestroy(World)
dCloseODE()
End

Function SetupCar()
  For count=1 To 4
	Joint(count)=dJointCreateHinge2(World,0)
	dJointAttach(Joint(count),Car,Wheel(count))
	dJointSetHinge2Anchor(Joint(count),dBodyGetPositionX(Wheel(count)),dBodyGetPositionY(Wheel(count)),dBodyGetPositionZ(Wheel(count)))
	dJointSetHinge2Axis1(Joint(count),0,1,0)
	dJointSetHinge2Axis2(Joint(count),-1,0,0)
	dJointSetHinge2Param(Joint(count),dParamSuspensionERP,0.8)
	dJointSetHinge2Param(Joint(count),dParamSuspensionCFM,SuspensionHS)
	If count>2
      dJointSetHinge2Param(Joint(count),dParamLoStop,0)
      dJointSetHinge2Param(Joint(count),dParamHiStop,0)
	End If
  Next
  Speed=0
End Function

Function UpdateKeys()
  If KeyDown(30)=1
	Speed=Speed+0.08
	If Speed>30 Then Speed=30
  End If
  If KeyDown(44)=1
	Speed=Speed-0.1
	If Speed<-10 Then Speed=-10
	If Speed>0 Then Speed=Speed*0.97
  End If
  If KeyDown(30)=0 And KeyDown(44)=0 Then Speed=Speed*0.99
  If KeyDown(203)=1 Or KeyDown(205)=1
	If KeyDown(203)=1
      Steer=0.5
	Else
      Steer=-0.5
	End If
  Else
    Steer=0
  End If
  If KeyHit(57)=1
	Speed=0
	dBodySetRotation(Car,0,0,0)
  End If
End Function

Function UpdateCar()
  For count=1 To 4
	dBodyEnable(Wheel(count))
  Next
  dBodyEnable(Car)
  For count=1 To 4
	dJointSetHinge2Param(Joint(count),dParamVel2,Speed)
	dJointSetHinge2Param(Joint(count),dParamFMax2,HingeTorque)
  Next
  For count=1 To 2
	angle#=Steer-dJointGetHinge2Angle1(Joint(count))
	dJointSetHinge2Param(Joint(count),dParamVel,angle)
	dJointSetHinge2Param(Joint(count),dParamFMax,400)
  Next
End Function

Function UpdateCam()
  PositionEntity CameraPivot,0,3,-12
  camx#=EntityX(CameraPivot,1)-EntityX(Camera)
  camy#=EntityY(CameraPivot,1)-EntityY(Camera)
  camz#=EntityZ(CameraPivot,1)-EntityZ(Camera)
  TranslateEntity Camera,camx*0.5,camy*0.5,camz*0.5
  PointEntity Camera,CMesh
End Function

Function UpdateGeoms()
  For ode.ODEGeom=Each ODEGeom
	RotateEntity ode\mesh,dGeomGetPitch#(ode\geom),dGeomGetYaw#(ode\geom),dGeomGetRoll#(ode\geom)
	PositionEntity ode\mesh,dGeomGetPositionX#(ode\geom),dGeomGetPositionY#(ode\geom),dGeomGetPositionZ#(ode\geom)
  Next
End Function



Ross C(Posted 2006) [#16]
Maybe you should learn the basics of loading in meshes and such before attempting to throw in physics too?


Shifty Geezer(Posted 2006) [#17]
Yes. Jeffmoris, take the time to learn the language. You can't write a program by taking someone else's and hacking changes. The ODE programs are there for examples, but you need to learn from them.

Learn how to create a scene with ground and a couple of boxes. Learn how to add forces to the boxes and have them collide. Learn to change them for other shapes and change their properties like mass and friction. then you'll understand the structuring you need for you objects (types). eg. For one you'll want an array of pins and a separate Ball object. Clunking them all into For Every ODEGeom routines is going to limit your object management (though admittedly with only one ball and ten pins, you could easily manage with an array of 11 objects with the first reserved for the ball)


jhocking(Posted 2006) [#18]
Don't even mess with ODE until you are solid on developing 3D games using Blitz's default command set.


VIP3R(Posted 2006) [#19]
I agree, it would be a very good idea to learn some of the basics of 3D programming before you dive into physics. Very brave of you though :)

Anyway, I've added a 10 Pin Bowling demo in JV-ODE Physics Thread 6 in the Blitz3D/Userlibs forum, you may find it very useful.


Bouncer(Posted 2006) [#20]
LOL... Somebody move this to beginners section...


danjo(Posted 2006) [#21]
aH- i see what you've forgotten jeff.
look for the command in the help section,
Knockpinsover=true
when the ball goes down the alley ;)


i later realized you maY actually look for it; dont; im taking the @#!*.


Pineapple(Posted 2006) [#22]
If you must make a bowling game, hunt down Gabriel... He made a pretty good one using Blitz3D, so if your truely stuck, he'd be the mannath!!! :)

Though, if your brand new, try something easier, because I don't think he'd appreciate getting hounded every 5 mins until he eventually wrote the game for you!

I would'nt!

Good luck

Dabz