axis id; sound init vernum
This commit is contained in:
parent
615f9c0d18
commit
41b4df6326
|
@ -127,6 +127,8 @@ class Configuration(RawConfigParser):
|
|||
set_option(section, "select", "6", False)
|
||||
set_option(section, "single-xy", "no", False)
|
||||
set_option(section, "delay-axis", "0", False)
|
||||
set_option(section, "vertical-axis", "1", False)
|
||||
set_option(section, "horizontal-axis", "0", False)
|
||||
section = "event"
|
||||
add_section(section)
|
||||
set_option(section, "user-event-id", "USEREVENT", False)
|
||||
|
@ -415,7 +417,8 @@ class TypeDeclarations(dict):
|
|||
|
||||
"keys": {"list": ["up", "right", "down", "left"]},
|
||||
|
||||
"joy": {"int": ["advance", "pause", "select"],
|
||||
"joy": {"int": ["advance", "pause", "select", "vertical-axis",
|
||||
"horizontal-axis"],
|
||||
|
||||
"float": "delay-axis",
|
||||
|
||||
|
|
|
@ -115,14 +115,14 @@ class Input(GameChild):
|
|||
elif direction == "left" and self.joystick.is_direction_pressed(Joystick.right):
|
||||
command = "right"
|
||||
else:
|
||||
if axis == 1:
|
||||
if axis == self.get_configuration("joy", "vertical-axis"):
|
||||
if value < 0:
|
||||
if not single_xy or not self.joystick.is_direction_pressed(Joystick.down):
|
||||
command = "up"
|
||||
elif value > 0:
|
||||
if not single_xy or not self.joystick.is_direction_pressed(Joystick.up):
|
||||
command = "down"
|
||||
else:
|
||||
elif axis == self.get_configuration("joy", "horizontal-axis"):
|
||||
if value > 0:
|
||||
if not single_xy or not self.joystick.is_direction_pressed(Joystick.left):
|
||||
command = "right"
|
||||
|
|
|
@ -2,13 +2,16 @@ from random import randint
|
|||
from math import sin, log, pi
|
||||
from array import array
|
||||
|
||||
from pygame.mixer import Sound, get_init
|
||||
from pygame.mixer import Sound, get_init, version
|
||||
|
||||
class Samples(Sound):
|
||||
|
||||
def __init__(self):
|
||||
self.set_amplitude()
|
||||
Sound.__init__(self, buffer=self.build())
|
||||
if version.vernum < (1, 9, 2):
|
||||
Sound.__init__(self, self.build())
|
||||
else:
|
||||
Sound.__init__(self, buffer=self.build())
|
||||
|
||||
def set_amplitude(self):
|
||||
self.amplitude = (1 << (self.get_sample_width() * 8 - 1)) - 1
|
||||
|
|
Loading…
Reference in New Issue