mirror of
https://github.com/izzy2lost/cpython.git
synced 2026-06-19 01:16:18 -07:00
Xbox one loads fine libraries, WIndows not, double underscore for sdl2
This commit is contained in:
@@ -252,6 +252,17 @@ def main(winstyle=0):
|
||||
bestdepth = pg.display.mode_ok(SCREENRECT.size, winstyle, 32)
|
||||
screen = pg.display.set_mode(SCREENRECT.size, winstyle, bestdepth)
|
||||
|
||||
# joystick setup
|
||||
pg.joystick.init()
|
||||
|
||||
try:
|
||||
j = pg.joystick.Joystick(0) # create a joystick instance
|
||||
j.init() # init instance
|
||||
print ("Enabled joystick: {0}".format(j.get_name()))
|
||||
except pg.error:
|
||||
print ("no joystick found.")
|
||||
pass
|
||||
|
||||
# Load images, assign to sprite classes
|
||||
# (do this before the classes are used, after screen setup)
|
||||
img = load_image("player1.gif")
|
||||
@@ -314,6 +325,10 @@ def main(winstyle=0):
|
||||
# Run our main loop whilst the player is alive.
|
||||
while player.alive():
|
||||
|
||||
joystick_input = False
|
||||
joystick_direction = 0
|
||||
joystick_button = False
|
||||
|
||||
# get input
|
||||
for event in pg.event.get():
|
||||
if event.type == pg.QUIT:
|
||||
@@ -338,6 +353,18 @@ def main(winstyle=0):
|
||||
screen.blit(screen_backup, (0, 0))
|
||||
pg.display.flip()
|
||||
fullscreen = not fullscreen
|
||||
elif event.type == pg.JOYAXISMOTION: # Joystick
|
||||
if j.get_axis(0) >= 0.5:
|
||||
joystick_input = True
|
||||
joystick_direction = 1
|
||||
if j.get_axis(0) <= -1:
|
||||
joystick_input = True
|
||||
joystick_direction = -1
|
||||
|
||||
elif event.type == pg.JOYBUTTONDOWN:
|
||||
joystick_input = True
|
||||
joystick_button = True
|
||||
|
||||
|
||||
keystate = pg.key.get_pressed()
|
||||
|
||||
@@ -347,10 +374,18 @@ def main(winstyle=0):
|
||||
# update all the sprites
|
||||
all.update()
|
||||
|
||||
# handle player input
|
||||
direction = keystate[pg.K_RIGHT] - keystate[pg.K_LEFT]
|
||||
# handle player input
|
||||
if joystick_input:
|
||||
direction = joystick_direction
|
||||
|
||||
player.move(direction)
|
||||
|
||||
firing = keystate[pg.K_SPACE]
|
||||
|
||||
if joystick_input:
|
||||
firing = joystick_button
|
||||
|
||||
if not player.reloading and firing and len(shots) < MAX_SHOTS:
|
||||
Shot(player.gunpos())
|
||||
if pg.mixer:
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
|
||||
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
|
||||
<ProjectName>_sdl2</ProjectName>
|
||||
<ProjectName>__sdl2</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
|
||||
@@ -224,7 +224,7 @@ void PyShell::StartInterpreter()
|
||||
last_was_stderr = false;
|
||||
|
||||
Py_Initialize();
|
||||
PyEval_InitThreads();
|
||||
//PyEval_InitThreads();
|
||||
|
||||
/* boot interactive shell */
|
||||
metrosetup = PyImport_ImportModule("metrosetup");
|
||||
@@ -232,12 +232,12 @@ void PyShell::StartInterpreter()
|
||||
PyErr_Print();
|
||||
}
|
||||
|
||||
PyEval_ReleaseThread(PyThreadState_Get());
|
||||
//PyEval_ReleaseThread(PyThreadState_Get());
|
||||
}
|
||||
|
||||
void PyShell::StopInterpreter()
|
||||
{
|
||||
PyGILState_STATE s = PyGILState_Ensure();
|
||||
//PyGILState_STATE s = PyGILState_Ensure();
|
||||
Py_Finalize();
|
||||
this->textBlock1->Blocks->Clear();
|
||||
}
|
||||
@@ -303,7 +303,7 @@ void PyShell::disable_input()
|
||||
|
||||
PyObject* PyShell::try_compile()
|
||||
{
|
||||
PyGILState_STATE s = PyGILState_Ensure();
|
||||
//PyGILState_STATE s = PyGILState_Ensure();
|
||||
PyObject *code = PyObject_CallMethod(metrosetup, "compile", "u", command->Data());
|
||||
if (code == NULL) {
|
||||
PyErr_Print();
|
||||
@@ -317,13 +317,13 @@ PyObject* PyShell::try_compile()
|
||||
}
|
||||
else
|
||||
_prompt = 0;
|
||||
PyGILState_Release(s);
|
||||
//PyGILState_Release(s);
|
||||
return code;
|
||||
}
|
||||
|
||||
void PyShell::run_code()
|
||||
{
|
||||
PyGILState_STATE s = PyGILState_Ensure();
|
||||
//PyGILState_STATE s = PyGILState_Ensure();
|
||||
PyObject *result = PyObject_CallMethod(metrosetup, "eval", "O", current_code);
|
||||
if (result == NULL) {
|
||||
PyErr_Print();
|
||||
@@ -334,7 +334,7 @@ void PyShell::run_code()
|
||||
Py_CLEAR(current_code);
|
||||
_prompt = 1;
|
||||
command = "";
|
||||
PyGILState_Release(s);
|
||||
//PyGILState_Release(s);
|
||||
if (exited) {
|
||||
//Window::Current->Close();
|
||||
StopInterpreter();
|
||||
@@ -448,9 +448,9 @@ void python34app::PyShell::do_restart(Platform::Object^ sender, Windows::UI::Xam
|
||||
|
||||
void PyShell::run_simple_string()
|
||||
{
|
||||
PyGILState_STATE s = PyGILState_Ensure();
|
||||
//PyGILState_STATE s = PyGILState_Ensure();
|
||||
PyRun_SimpleString((char*)simple_string->Data);
|
||||
PyGILState_Release(s);
|
||||
//PyGILState_Release(s);
|
||||
}
|
||||
|
||||
void python34app::PyShell::run_file(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
||||
|
||||
Binary file not shown.
@@ -7,7 +7,7 @@ def unbulk_dyn_load_package_name(module_name, package_name, extension_name):
|
||||
sys.modules[module_name] = foo
|
||||
return foo
|
||||
|
||||
sdl2 = unbulk_dyn_load_package_name("_sdl2.sdl2", "_sdl2.sdl2", "_sdl2.pyd")
|
||||
sdl2 = unbulk_dyn_load_package_name("_sdl2.sdl2", "_sdl2.sdl2", "__sdl2.pyd")
|
||||
video = unbulk_dyn_load_package_name("_sdl2.video", "_sdl2.video", "_video.pyd")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user