Real beginners tutorial

Where can I find a real tutorial to make my first games, using Python ?
I’ve found out how to do the basic stuff, but is there a good python gameblender tutorial for beginners ?
I’ve had a look at the list in this forum, but most of the links don’t exist anymore !

do you know python in the first place?

beyond that it pretty much is learning the api and techniques

which I could probably describe a lot of here:

python scripts are only run when their controller is pulsed. I believe even false pulses will run a python script.

python scripts can only access sensors and actuators to which it is linked to

each sensor and actuator has its own functions (which are documented pretty well in the gamekit. For blender 2.23 I have a lot of the calls [for all of blender, gameblender stuff at end] at http://www.geocities.com/z3r0_d/blenderDoc.html )


# code you will probably need to do anything
import GameLogic

cont = GameLogic.getCurrentController() # get the controller, thorough which I can get sensors and actuators
obj = cont.getOwner() # object containing controller through which I can get properties

sense = cont.getSensor("sense") # getting a sensor by name
# or alternatively, you can get all sensors
sense 2 = cont.getSensors()[1]

# you can get the object any logicbrick is used in, logic brick links can go between objects
# this gets an object through its actuator by name [of the actuator]
otherobject = cont.getActuator("act").getOwner()

# getting an actuator by name
act = cont.getActuator("act2")

# sending a true pulse to an actuator to make it do its thing
GameLogic.addActiveActuator(act, 1)
# alternatively a false pulse would have a 0 in that line

#### accessing object properties
# all object properties can be accesed through the obj, the owner of the logicbrick
obj.Text = "MOO!"
otherobject.boolprop = 0

### more advanced
# for objects that need to be kept as python objects (not as primitives) 
# it is common for them to be appended to the GameLogic module

# test if I have appended it yet
try:
    GameLogic.someadditionalprop
except:
    GameLogic.someadditionalprop = [] # make it an empty list

GameLogic.someadditionalprop.append("don't do this every frame")

z3r0 d, umm…

# test if I have appended it yet 
try: 
    GameLogic.someadditionalprop 
catch: 
    GameLogic.someadditionalprop = [] # make it an empty list

Should be:

# test if I have appended it yet 
try: 
    GameLogic.someadditionalprop 
except: 
    GameLogic.someadditionalprop = [] # make it an empty list 

Catch is the C++ term, Python uses except.

… yeah, updated

this is one reason I am glad I don’t work on any huge c/c++ applications, I wouldn’t know for several minutes when trying to run if I had any syntax errors probably

(with java I would know as I wrote it, eclipse is nice)

things goes around when you can many program languages :smiley:

In fact, I don’t know very much about Python, so I d’ont actually understand a thing to your answers…

What I really wanted to know, was if there is a tutorial that explains, let’s say, how to do a simple rally game or a little First person shooter or something, starting at the beginning (after modelling), and explaining all the programming.

I tried downloading example games, but when the files are oppened in Blender, I then can’t edit it and see all the programming behind it.

You probably can see all the programming behind it if it used python script. Just open up the text window and click to see what scripts were used. You might have to click around to find what script is linked to which object, etc.

I’m very much in the same position as you right now. Since you don’t know python. I suggest you learn it. If you have any prior experience with any programming language like C++ just go to the main python site and read up on the commands and stuff. If not, go to this site http://rupert.honors.montana.edu/~jjc/easytut/easytut/ written by Josh Cogliati. A programming tutorial in python for non-programmers.

If you want to a tutorial on creating a game from start to finish, there’s hardly any of those kinds of indepth tutorials around. Hmm there is this tutorial on a maze game in Blender. Honestly I have to yet try to do that. There is however a tutorial that comes pretty close to making a full game. It’s pretty much complete, but it’s lacking in creation of levels (anything that will make the game bigger). It contains all the essential things along with python coding for simple AI. Here’s the elysiun post to the tutorial made by Snailrose https://blenderartists.org/forum/viewtopic.php?t=22674&highlight=.

Jason Lin

Thank you very much for those links. I’ve had a quick and it seems to be just what I was looking for :smiley:

the GameLogic module is automatically loaded when you start the game, so you don’t need to import it…

Pooba