[Tutorial] Making a game part 1

Moderators: Yodaman921, Gabriel

[Tutorial] Making a game part 1

Postby hydra_skillz » Mon Feb 23, 2009 8:06 pm

This is part 1 of a tutorial on the Blender Game Engine in 2.48a. The reader should have basic modeling skills and know how to navigate Blender. Tell me if I don't explain something well and if I should continue with follow up tutorials about scoring, menus, glsl, etc.

We will be making a game where the player (a cube) has to push a ball onto a goal (exciting!). First, add a plane and scale it 2 on the x axis and 5 on the y axis. You can press N to bring up the Transform Properties dialog. Here you can easily enter in numbers for scale, location, and rotation. Move the cube up so that it is sitting on the plane and at the back of the plane like so:
getut1_1.jpg
getut1_1.jpg (146.1 KiB) Viewed 8792 times


Now go to the Logic panel (F4 or the pacman icon). Click bounds and change it to box. Change static to dynamic and change Damp and RotDamp to 0.8. This makes it so our cube can have sliding motion. The greater the damp value, the more slowed down our cube is from friction. In 2.49 a value of 1 makes it so the cube cannot move.
getut1_2.jpg
getut1_2.jpg (36.19 KiB) Viewed 8787 times


Make sure our cube is selected and next to it's name click Add. These are input sensors, and we want a keyboard sensor, so click Always and change it to Keyboard. Click the Key field and press up arrow, then rename the sensor to 'up' (don't type the 's).
getut1_3.jpg
getut1_3.jpg (16.39 KiB) Viewed 8786 times


Now add a Controller, the next item to the right. Leave it as AND and name it to 'up pressed'. Next add an actuator, the last item. Here is a breakdown of the motion actuator:
motion_actu.jpg
motion_actu.jpg (97.77 KiB) Viewed 8783 times


Set the LinV in the local y direction to 2.5 and rename the actuator to 'move forward'. Now click one of the gold circles and drag the mouse to connect them like so:
getut1_4.jpg
getut1_4.jpg (52 KiB) Viewed 8778 times


Now to add our ball. Add a Uvsphere with 8 segments and 8 rings, and make sure it is above the plane. In the Editing panel (F9) you can set it smooth to make it look prettier. In the Logic panel, change it from static to Rigid body and set the Damp and Rot Damp to 1.
getut1_5.jpg
getut1_5.jpg (149.55 KiB) Viewed 8775 times


Now to set up the camera. Select the default camera and press alr + r and alt + g to move it back to the origin. Set it's x rotation to 60, y location to -7, and it's z location to 5. Then parent the camera to the cube by typing Cube in the Par: field in the Transform Properties window.
getut1_6.jpg
getut1_6.jpg (149.26 KiB) Viewed 8777 times


You can go to camera view (numpad 0) and press p to try out the game. Let's add a second level and a jump pad for the ball. Using extrude, I editing the plane like this:
getut1_7.jpg
getut1_7.jpg (151.56 KiB) Viewed 8768 times


Add another plane, scale it to 1.2, and move it to the base of the ledge.
getut1_8.jpg
getut1_8.jpg (143.23 KiB) Viewed 8772 times


Go to the logic panel and add a sensor, controller, and an actuator. Make the sensor Collision and set the property field to 'ball'. Change the actuator to Message, set the To: field to Sphere and Subject: to jump. Now connect the gold circles. Select our ball and add a property (by clicking Add Property) and name it ball. Now add a sensor, controller, and actuator. Change the sensor to Message and set the Subject field to jump. Leave the motion actuator, but change the LinV to 2 in the y and 12 in the z and click add.
getut1_9.jpg
getut1_9.jpg (67.53 KiB) Viewed 8760 times


If you play the game now, you should be able to push the ball onto the jump pad and it should jump up to the next level. Now let's modify it so the player can be jumped too. Select the cube and add a property named player. Select the jump pad and add another sensor, make it Collision and set it's property to player. Add a controller and connect the sensor to it. Add a Message actuator and set the To: to Cube and the Subject to jump.
getut1_10.jpg
getut1_10.jpg (56.47 KiB) Viewed 8752 times


Select the player and add a message sensor with subject jump. Add a controller and motion actuator. Set the LinV to 10 on the local z and click add.
getut1_11.jpg
getut1_11.jpg (88.97 KiB) Viewed 8741 times


Now for the goal that ends the level. Add a plane and position like so:
getut1_12.jpg
getut1_12.jpg (129.91 KiB) Viewed 8746 times


Add a collision sensor, set the property to ball, and connect it to a controller and scene actuator. Change Restart to Set Scene.
getut1_13.jpg
getut1_13.jpg (36.73 KiB) Viewed 8730 times


Now we need to add another scene. Name the current scene level 1 and the new one (make it empty) level 2. Set the scene actuator to level 2.
getut1_14.jpg
getut1_14.jpg (37.59 KiB) Viewed 8727 times


Select the camera and cube and press ctrl + l → to scene → level 2. This makes it so the player cube and camera will be in the next scene, exactly as they are in this one. If we move them in any scene they are linked to, the change happens in all scenes they are linked to. Go to scene level 2 and add a plane and position it under the player (so he doesn't fall when he gets there).
getut1_15.jpg
getut1_15.jpg (35.92 KiB) Viewed 8723 times


Go back to level 1 into camera view and try out the game.

Here is the .blend file I made. Note: I added colors and adjusted the lighting, which is not mentioned in the tutorial.
Attachments
GETut1.blend
(151.05 KiB) Downloaded 490 times
Last edited by hydra_skillz on Tue Jun 09, 2009 8:22 am, edited 1 time in total.
GE API <- reference for game engine scripting
User avatar
hydra_skillz

Premium Member
 
Posts: 1321
Joined: Mon Dec 15, 2008 5:22 pm
Location: North Carolina

Re: [Tutorial] Making a game part 1

Postby loist » Tue Feb 24, 2009 1:46 pm

something new in game tutorial section. :D i thought it will be a boring maze :D but not :D nice, i like your tutorial. :) keep doing that :) waiting your next game tutorials :)
...creation is the way to create something...

sorry for my bad speech, i'm lithuanian
Image
Image
User avatar
loist

Member
 
Posts: 461
Joined: Thu Apr 03, 2008 11:16 am
Location: Kaunas - Šiauliai, Lithuania

Re: [Tutorial] Making a game part 1

Postby hydra_skillz » Tue Feb 24, 2009 2:25 pm

What should I add in the next one? I was thinking about making a more complex level with more interactive objects and adding death and respawning.
GE API <- reference for game engine scripting
User avatar
hydra_skillz

Premium Member
 
Posts: 1321
Joined: Mon Dec 15, 2008 5:22 pm
Location: North Carolina

Re: [Tutorial] Making a game part 1

Postby loist » Tue Feb 24, 2009 2:48 pm

hydra_skillz wrote:What should I add in the next one? I was thinking about making a more complex level with more interactive objects and adding death and respawning.



it would be great :) i can't wait to read your next tutorial :)
...creation is the way to create something...

sorry for my bad speech, i'm lithuanian
Image
Image
User avatar
loist

Member
 
Posts: 461
Joined: Thu Apr 03, 2008 11:16 am
Location: Kaunas - Šiauliai, Lithuania

Re: [Tutorial] Making a game part 1

Postby Da red fox » Tue Feb 24, 2009 4:59 pm

very nice, i wish i had had this tut when i started

one thing you could do just to reduce the amount of logic bricks is

instead of this:
1.PNG
1.PNG (15.26 KiB) Viewed 8673 times



you could use this:
2.PNG
2.PNG (12.01 KiB) Viewed 8676 times


it just changes it so it doesnt send a message to a particular object, it just sends a message with the
subject jump, so it does the exact same thing, just with 2 less logic bricks.

just a suggestion though :D
Image
Da red fox

Member
 
Posts: 161
Joined: Sat Dec 20, 2008 11:54 am

Re: [Tutorial] Making a game part 1

Postby hydra_skillz » Tue Feb 24, 2009 7:28 pm

Yes, I know, but I wanted to explain the To: part of the message actuator.

Edit: Also it would make the ball AND player jump, not just one by itself.
GE API <- reference for game engine scripting
User avatar
hydra_skillz

Premium Member
 
Posts: 1321
Joined: Mon Dec 15, 2008 5:22 pm
Location: North Carolina

Re: [Tutorial] Making a game part 1

Postby artic0m3ga » Wed Feb 25, 2009 6:26 pm

yay go hydra. Good tutorial. Next ya should do like level design and with pretty much a basic door and fun stuff.
-Artic
User avatar
artic0m3ga

Member
 
Posts: 381
Joined: Mon Sep 22, 2008 6:59 pm

Re: [Tutorial] Making a game part 1

Postby Da red fox » Thu Feb 26, 2009 12:02 am

hydra_skillz wrote: Also it would make the ball AND player jump, not just one by itself.


good point
Image
Da red fox

Member
 
Posts: 161
Joined: Sat Dec 20, 2008 11:54 am

Re: [Tutorial] Making a game part 1

Postby hydra_skillz » Fri Mar 06, 2009 10:12 pm

I'm almost done with the second part. Just a few more things to explain, and then adding/editing the screenshots (50+).
GE API <- reference for game engine scripting
User avatar
hydra_skillz

Premium Member
 
Posts: 1321
Joined: Mon Dec 15, 2008 5:22 pm
Location: North Carolina

Re: [Tutorial] Making a game part 1

Postby Yodaman921 » Fri Mar 06, 2009 10:38 pm

Hydra_skillz, you are the game master. I can't wait for the new part of the tutorial. Is any of your tutorials going to get into basic python scripting for games?
Image
See my tutorials Here.
User avatar
Yodaman921

Site Admin
 
Posts: 2624
Joined: Sat May 17, 2008 8:49 pm
Location: University of Michigan
Next

Return to User Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest