This commit is contained in:
deckensteuerung
2018-10-21 15:19:51 +02:00
parent 27fa6f7c63
commit 6c7d81ed49
6 changed files with 130 additions and 88 deletions

View File

@@ -9,8 +9,8 @@ import random
PADDLE_LEN = 6
Nx = int(sys.argv[1])
Ny = int(sys.argv[2])
Ny = int(sys.argv[1])
Nx = int(sys.argv[2])
param = sys.argv[3]
speed = 1.0
@@ -21,8 +21,10 @@ except:
pygame.init()
pygame.joystick.init()
j = pygame.joystick.Joystick(0)
j.init()
j1 = pygame.joystick.Joystick(0)
j2 = pygame.joystick.Joystick(1)
j1.init()
j2.init()
numbers = [
int("0b111101101101111", 2),
@@ -69,14 +71,14 @@ while True:
time.sleep(0.016)
if j.get_axis(0) > 0 and player1+PADDLE_LEN < Nx:
if j1.get_axis(0) > 0.2 and player1+PADDLE_LEN < Nx:
player1 += 1
if j.get_axis(0) < 0 and player1 > 0 :
if j1.get_axis(0) < -0.2 and player1 > 0 :
player1 -= 1
if j.get_axis(1) > 0 and player2+PADDLE_LEN < Nx:
if j2.get_axis(0) > 0.2 and player2+PADDLE_LEN < Nx:
player2 += 1
if j.get_axis(1) < 0 and player2 > 0 :
if j2.get_axis(0) < -0.2 and player2 > 0 :
player2 -= 1
x += dx
@@ -114,7 +116,7 @@ while True:
buffer = bytearray(b"\x00"*(3*Nx*Ny))
def SetPixel(x, y, r, g, b):
idx = 3*(x+Nx*y)
idx = 3*(y+Ny*x)
buffer[idx+0] = r
buffer[idx+1] = g
buffer[idx+2] = b