The most important and difficult part of any game development is getting the desired resources for the game idea, you will need texutures, sprites, soundFX, background music and lot more. Thats why i choose MARIO as base for this tutorial. You can get the resources easily on the net. Just google mario game rsources and you will be provided with bunch of resources. To get started faster i have listed my favourite site for getting the game resources, You can also download the resources directly by going to the google drive link provided below.
3D Models Resources
Direct link to download resources for this Tutorial
While working with a 3D game, I spend lot of hours deciding what I want to import first NPC'S, Main Character or Backgrounds etc. But as we are working on 2D game, what we need is to import all the textures or png resources. we don't recquire to import anything else.
We have our textures imported now we have to convert them into real asset to use in our 2D game.
First of all we need to know the resolution of the texture of the item we are going to add in our 2D game. The enemy Goomba for example has a resolution of 16X16.
So what we gonna do is to create a plane mesh of height 16 and with a width 16 too and then we have to apply the texture for enemy Goomba to the planemesh. Rename the planemesh to Goomba.
Do the same thing for other characters or backgrounds. Select the texture, get the resolution and create planemesh according to that resolution, apply the texture and rename it.
Do not create more than one instance of an object, for example there are total of 16 Goomba's in Mario World 1-1 but we need to create only one Goomba.
Once we are done with converting textures into meshes. we are going to place the background objects to their position. we are not going to place game objects which affects the gameplay. we are going to place static object like clouds, floor, plants and stone walls, which have nothing to do with the gameplay.
To place the objects into the right positions we are going to create fake (Dummy) asset.
To create a dummy of the level all you have to do is to create a planemesh of the same resolution of the provided texture for dummy. and position it to (0,0,0) now select the object you want to place into the game. For example select the cloud and drag it to the same position as you see on the dummy world. Do the same thing with other background objects plants,bushes and stones.
We have placed the background objects, we are ready with our enemies, character, bricks and item meshes, now we need to animate our meshes.
To animate our meshes we are going to use an inbuilt Coppercube behavior ANIMATE A TEXTURE.
Select the enemy Goomba mesh and click on add behavior choose effect behavior and select Animate A Texture. Now select both of the enemy texture Goomba walk1 and Goomba_walk2 for the texture in the behavior setting. you will instantly see your enemy animation. Do the same for other objects,except the Player object as he is going to have multiple animations.
We have our assets ready with textures and animations now all we need is assigning Collision and Behaviors to them. Let's create a cube mesh of size 16 (size is according to the resolution), copy the position of the enemy Goomba and paste that position to cubemesh and make the cube mesh child node of that Goomba. change the material of cubemesh to Transparent Add and assign a black texture to it. rename the cubemesh to Collision_enemy.
Now add a planemesh of 16X16 and adjust it position to match the position of Goomba. Assign the same material settings as Cubemesh to it. and rename it to Collision_death. Position the planemesh such that it will be on top of the cubemesh. and make it child node of the Goomba.
Now add a new behavior to the Collision_death "On Proximity Do Something".
Test Area = Box
Size = 16,16,16
Near to what = a scenenode
Near to Which Scenenode = Player
And in Action to do add a clone behavior of the death of Goomba node relative to the original goomba.
add play sound action and play the kick sound.
add a change variable behavior and add 100 value to that variable.(create any variable you like ,e.g. Score)
add scripted behavior do something later.
and Choose 100ms add action to execute delete scenenode Goomba.
This is how you can add behaviors for and collision for other objects too.
Now we are ready with behaviors of our npc's. Its time to have our player in the game.
First of all create a cubemesh of size same as the resolution of player.
e.g. Small mario has resolution of 16x16. now we will create a cube mesh of 16 size and rename it to "Player". and will assign a tranparent add black material to it.
now create Four diffrent meshes for our player as we have done in step 3.
each of the mesh will have diffrent animation.
one will have run animation, second will have jump, third will have idle and fourth will be going to death animation.
make all the four meshes children of the player cubemesh.
We will add a collide when moved behavior to our mesh and adjust the sphere according to the player mesh.
And we will add simple 2D jump and run behavior to make the character move and we will add different key pressed behaviours to switch between animations of the player. e.g. if a keypressed "SPACE" then hide all the other children nodes and show only jump node of the playermesh.
I have also edited the behavior jump and run so that the player won't move if up and down arrow keys are pressed.
Earlier we have placed backgrounds objects like clouds and plants now we are going to place our enemies, bricks and item blocks. we will do same as we have done before we will use the dummy mesh to position objects. but we will need to clone objects first so clone all the instances of an object you want in your game.
e.g. clone Enemy Goomba 16 times. and place them according to the dummy. Sameway place all other objects. Also adjust their Behaviors.
For the movement of the enemies we will be going to use change position of a scnenode behavior which will be relative to a scenenode. most of the time we will make them relative to the pipes. Also we need to add that behavior before starting the scene.
Add a 3rd person camera to your scene and choose player as object to follow. change the target height if you wanted to and assign follow from behind fixed rotation. You can also add a clonemesh of player without collision and jump set to zero then set it as target for camera to do correct camera tracking.
Hurrah!! we just completed cloning the Mario game. In this tutorial I have skipped a lot of details. but i have tried to cover all the major parts, and have also provided the link to a ccb file which may clear more doubts.
CCB file doesn't contain the complete level. it covers all the major part. e.g. killing enemy, picking up coins, etc.