harfang3d / dogfight-sandbox-hg1

Air to air combat game, created in Python 3 using HARFANG 3D.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

local variable 'pp' referenced before assignment

muraatozbek opened this issue · comments

Getting error when running the main.py and when i click "space" it gives error
any solution for that?

File "main.py", line 1477, in
game_phase = game_phase(plus, delta_t)
File "main.py", line 1284, in main_phase
Main.p1_aircraft.stabilize(dts, pk & pp, yk & yp, rk & rp)
UnboundLocalError: local variable 'pp' referenced before assignment

Hi,

it seems there is a missing else, in case no gamepad is plugged on the computer.
Could you try this fix and tell me if it works :

    pk, rk, yk = control_aircraft_keyboard(dts, Main.p1_aircraft)
    if Main.controller is not None:
        pp, rp, yp = control_aircraft_paddle(dts, Main.p1_aircraft)
    else:
        pp, rp, yp = True, True, True

    Main.p1_aircraft.stabilize(dts, pk & pp, yk & yp, rk & rp)

Thanks, it worked properly :)

OK, Great. Feel free to submit a pull request including this fix.