Hello members of the forum. I’m relative new to BGE, and totally neophyte to Python. Already read some about introduction to programming and to Python.
My difficulty now starts with the Blender API, and how to make what I did with logic bricks with Python. If any one can help me with this, will be a first step to understand better how to call objects, properties, sensors, etc with Python under Blender. (I read the API on web, but felt lost).
What I would like to do by code is:
if
prop (bomb_num > 0) # number of bombs available are greater than 0
and
collision (ground) # player is colliding with ‘ground’ property (of ground), means player not in the air
and
keyboard (space_key) # send possitive pulse when SPACE is pressed
and
prop (bo_type_a = true) # bo_type_a = true (they are 3 type of bomb, you can only have one active)
then
add object (bomb_a) # spawn the object named bomb_a
if
prop (bomb_num > 0)
and
collision (ground)
and
keyboard (space_key)
and
prop (bo_type_b = true)
then
add object (bomb_b)
if
prop (bomb_num > 0)
and
collision (ground)
and
keyboard (space_key)
and
prop (bo_type_c = true)
then
add object (bomb_c)
As you can see, they are parts repeat same conditions (bomb_num>0 ; collide with ground ; press SPACE) and only change what kind of bomb you have… but making in a code would be no sense to repeat the same part many times…
Could be this made with a list, tuple or bucle for? what you need to put at start to import the sensors and objects? (bombs objects are in an inactive layer).
Really wish someone can help me, cause tried couple times but can’t make it work, so guess my code is no sense for Python, hehe. (shame on me).
What I wanna do in a pic (cause an image speaks more than a thousand words). Thanks for any help.