As always our first step toward creating a game will be getting the desired resources. In this tutorial we are going to use inbuilt 3D mesh primitives to create most of the resources except the bowling pins and directional arrow. We will be going to download textures from the internet for the bowling alley. You can use your own resources if you want.
Create a spheremesh for the bowling ball and some plane meshes to create the bowling alley. Apply Textures to them and align them so they look something more like a Bowling Alley. Position and Align the Bowling Pins on the Alley Floor. You can also add water to the floor to make it shiny and to create reflections.
Now add a new behaviour move object by physics engine to all the bowling pins. To make this process faster aplly physics behaviour to one pin and adjust physics settings like bodytype = Box , density, size etc, then copy behaviours of that pin and paste them to other pins. So that you don't have to adjust the physics settings for each pin.
Now add physics to the bowling ball this time change the bodytype to sphere instead of box. It is advided that you use the same density for pins and bowling ball.
I have used dynamic materials for all the textures in this tutorial but if you want to use static lights then you can skip this step. Otherwise add few point lights to your Scene to make it more beautiful.
To detect that how many pins have been fallen on the ground, we will be going to use proximity behavior/ We will add dummy cubemesh to interact with that proximity behaviour.
First of all create a dummy cubemesh and make it child node of a pin. Disable collision for this cubemesh and adjust its position so that it will stay on top of the pin as shown in the picture below.
Remember to use "black" transparent texture for the cubemesh. Do same thing with all the other pins.
Now create a plane mesh and scale it up so that it can cover all the pins. Adjust its position, so that it will stay on top of the pins but in between the cubemesh. Now add behavior on proximity do something to this planemesh. You have to add 10 instances of this behaviour because there are 10 Pins in our game.
adjust proximity size according to your game. And change "near to what" to a scenenode and choose a cubemesh which we have created in the above step. Change "trigerred when" to leave radius.
Now execute an action, set or change a variable.
variable name= pinfall
operation = Add value(+)
valuetype = value
value = 1
Do same thing with all remaining 9 proximity behaviours each time use a diffrent cubemesh as a near to which scenenode.
It is known that we can not move an object controlled by phsyics with keyboard keys.
So to make our Bowling Ball moves, we will be going to add a FPS camera and then use the fps player to make the ball move.
Lets create a Fps camera and adjust its position so that it will stay just behind the ball each time the game starts. Now when we press Up key to make our fps player move forward, it will collide with the ball and ball will start moving.
Download any arrow 3d model from internet and import it in the game adjust its postion and rotation so that it will stay in the center of the game pointing toward the Pins.
Now add new behavior every few seconds do something and change the time to 1ms.
var Fpscam = ccbGetSceneNodeFromName("Camera1");
var rotation = ccbGetSceneNodeProperty(Fpscam, "Rotation");
var Arrow = ccbGetSceneNodeFromName("arrow");
ccbSetSceneNodeProperty(Arrow, "Rotation", 270,-rotation.y,0);
change "arrow" and "camera1" according to the name of your camera and name of you 3d Arrow.
To stop the movement of the camera once the ball starts moving and to make it not fall from the alley we will be going to block the movement by colliding the camera with planesmeshes.
create 3 vertical planemesh and position them to left right and back of fps camera mesh.
so that it can move into the forward direction only, when the user press any other movement keys then it will collide with the planemesh and will stay on its position.
Always remember to use transparent mesh for all the colliding/blocking or dummy meshes in your scene.
Create 2D overlays to show the number of how many pins fall and to show if it is an strike or not.
I will leave this step on to You because it may vary from person to Person what he want to show on 2D overlays
To show the number of pin falls. you can use the variable $pinfall$ we created in Step 5.
Hurrah!! we just completed creating our first physics based game in Coppercube 3D engine. In this tutorial I have skipped a lot of details. but i have tried to cover all the major parts, and have also provided a link to a the ccb file which may clear more doubts.