Tryed it: after moving all blue as far as possible , the red ones could be moved âŚ!!!
But (when not seen) I got these error message:
Traceback (most recent call last):
File âgameLogicâ, line 36, in <module>
File âgameLogicâ, line 33, in main
IndexError: tuple index out of range
several times.
With this changes it works !!!???
import bge
def main():
cont = bge.logic.getCurrentController()
mouse = bge.logic.mouse
scene = bge.logic.getCurrentScene()
objects = scene.objects
playerA = (objects['red.1'], objects['red.2'], objects['red.3'], objects['red.4'])
playerB = (objects['blue.1'], objects['blue.2'], objects['blue.3'], objects['blue.4'])
commonFields = ((-6.5, 1, 0), (-5.5, 1, 0), (-4.5, 1, 0), (-3.5, 1, 0), (-2.5, 1, 0), (-1.3, 1.1, 0), (-0.6, 1.8, 0), (0.6, 1.8, 0), (1.3, 1.1, 0), (2.5, 1, 0), (3.5, 1, 0), (4.5, 1, 0), (5.5, 1, 0), (6.5, 1, 0), (6.5, 0, 0), (6.5, -1, 0), (5.5, -1, 0), (4.5, -1, 0), (3.5, -1, 0), (2.5, -1, 0), (1.3, -1.1, 0), (0.6, -1.8, 0), (-0.6, -1.8, 0), (-1.3, -1.1, 0), (-2.5, -1, 0), (-3.5, -1, 0), (-4.5, -1, 0), (-5.5, -1, 0), (-6.5, -1, 0), (-6.5, 0, 0))
lanes = {'commonFields':commonFields}
wp = ''
for piece in playerA:
if 'location' not in piece:
piece['lane'] = 'commonFields'
piece['location'] = 15
wp = "playerA"
for piece in playerB:
if 'location' not in piece:
piece['lane'] = 'commonFields'
piece['location'] = 0
wp="playerB"
die = 1
if bge.logic.KX_INPUT_JUST_ACTIVATED == mouse.events[bge.events.LEFTMOUSE]:
piece = cont.sensors["MouseOverAny"].hitObject
if piece in playerA or piece in playerB:
curPos = piece['location']
newPos = curPos + die
print("newPos and player = ", newPos, wp)
piece.position = lanes[piece['lane']][newPos]
piece['location'] = newPos
main()
But after a time:
File âgameLogicâ, line 36, in main
IndexError: tuple index out of range
newPos and player = 4
newPos and player = 16
newPos and player = 16
newPos and player = 17
newPos and player = 17
newPos and player = 16
newPos and player = 17
newPos and player = 18
newPos and player = 18
newPos and player = 19
newPos and player = 20
newPos and player = 30
Python script error - object âgameLogicâ, controller âPythonâ:
Traceback (most recent call last):
File âgameLogicâ, line 39, in <module>
File âgameLogicâ, line 36, in main
IndexError: tuple index out of range
newPos and player = 30
Python script error - object âgameLogicâ, controller âPythonâ:
Traceback (most recent call last):
File âgameLogicâ, line 39, in <module>
File âgameLogicâ, line 36, in main
IndexError: tuple index out of range
Strange, wp is not printed???