-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfc777d
commit 8d387c2
Showing
1 changed file
with
15 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,34 @@ | ||
""" | ||
Some game controllers have different inputs and some are not be compatible so don'tbe surprised if this doesnt quite work properly! Use joystick_tester.py to test yours. | ||
Raylib has a game controller API that is a bit different from Pygame's | ||
TODO for Richard: Might simplify this a bit more | ||
""" | ||
from richlib import * | ||
|
||
import pygame | ||
|
||
joystick = pygame.joystick.Joystick(0) | ||
joystick.init() | ||
|
||
alien = Actor('trooper') | ||
alien.size = (20,20,20) | ||
alien.size = (20, 20, 20) | ||
alien.pos = (0, 10, 10) | ||
|
||
|
||
def draw(): | ||
clear() | ||
alien.draw() | ||
|
||
|
||
def update(): | ||
print(joystick.get_axis(0)) | ||
# if pyray.is_gamepad_available(0): | ||
# print(pyray.is_gamepad_button_down(0,0)) | ||
# cd = pyray.get_gamepad_name(0) | ||
#print(ffi.string(cd)) | ||
|
||
# print(pyray.get_gamepad_axis_movement(0, 0)) | ||
if (keyboard.right): | ||
alien.x = alien.x + 1 | ||
elif (keyboard.left): | ||
alien.x = alien.x - 1 | ||
|
||
run() | ||
if pyray.is_gamepad_available(0): | ||
if pyray.is_gamepad_button_down(0, rl.GAMEPAD_BUTTON_LEFT_FACE_UP): | ||
print("up") | ||
if pyray.is_gamepad_button_down(0, rl.GAMEPAD_BUTTON_RIGHT_FACE_UP): | ||
print("Y") | ||
if pyray.get_gamepad_axis_movement(0, rl.GAMEPAD_AXIS_LEFT_X) > 0.3: | ||
alien.x = alien.x + 1 | ||
elif pyray.get_gamepad_axis_movement(0, rl.GAMEPAD_AXIS_LEFT_X) < -0.3: | ||
alien.x = alien.x - 1 | ||
|
||
|
||
|
||
run() | ||
|
||
"""TODO | ||
make the alien move up and down as well as left and right | ||
make the alien move up/down and forward/back as well as left/right | ||
""" |