change to ugame buttons in the main code and movement_transparent_sprite example
This commit is contained in:
parent
101e919517
commit
730e6eeed1
2 changed files with 14 additions and 15 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import board
|
||||
import displayio
|
||||
import adafruit_imageload
|
||||
from tilegame_assets.controls_helper import controls
|
||||
import ugame
|
||||
|
||||
display = board.DISPLAY
|
||||
player_loc = {"x":4, "y":3}
|
||||
|
|
@ -69,18 +69,18 @@ sprite.y = 16 * player_loc["y"]
|
|||
# Add the Group to the Display
|
||||
display.show(group)
|
||||
|
||||
prev_btn_vals = controls.button
|
||||
prev_btn_vals = ugame.buttons.get_pressed()
|
||||
|
||||
while True:
|
||||
cur_btn_vals = controls.button
|
||||
if not prev_btn_vals.up and cur_btn_vals.up:
|
||||
cur_btn_vals = ugame.buttons.get_pressed()
|
||||
if not prev_btn_vals & ugame.K_UP and cur_btn_vals & ugame.K_UP:
|
||||
player_loc["y"] = max(1, player_loc["y"]-1)
|
||||
if not prev_btn_vals.down and cur_btn_vals.down:
|
||||
if not prev_btn_vals & ugame.K_DOWN and cur_btn_vals & ugame.K_DOWN:
|
||||
player_loc["y"] = min(6, player_loc["y"]+1)
|
||||
|
||||
if not prev_btn_vals.right and cur_btn_vals.right:
|
||||
if not prev_btn_vals & ugame.K_RIGHT and cur_btn_vals & ugame.K_RIGHT:
|
||||
player_loc["x"] = min(8, player_loc["x"]+1)
|
||||
if not prev_btn_vals.left and cur_btn_vals.left:
|
||||
if not prev_btn_vals & ugame.K_LEFT and cur_btn_vals & ugame.K_LEFT:
|
||||
player_loc["x"] = max(1, player_loc["x"]-1)
|
||||
|
||||
# update the the player sprite position
|
||||
|
|
|
|||
|
|
@ -5,10 +5,9 @@ import board
|
|||
import displayio
|
||||
import adafruit_imageload
|
||||
from displayio import Palette
|
||||
|
||||
import ugame
|
||||
import terminalio
|
||||
from adafruit_display_text import label
|
||||
from tilegame_assets.controls_helper import controls
|
||||
from tilegame_assets.tiles import TILES
|
||||
from tilegame_assets.tiles import take_item
|
||||
from tilegame_assets.states import *
|
||||
|
|
@ -433,12 +432,12 @@ with open(
|
|||
# main loop
|
||||
while True:
|
||||
# set the current button values into variables
|
||||
cur_btn_vals = controls.button
|
||||
cur_up = cur_btn_vals.up
|
||||
cur_down = cur_btn_vals.down
|
||||
cur_right = cur_btn_vals.right
|
||||
cur_left = cur_btn_vals.left
|
||||
cur_a = cur_btn_vals.a
|
||||
cur_btn_vals = ugame.buttons.get_pressed()
|
||||
cur_up = cur_btn_vals & ugame.K_UP
|
||||
cur_down = cur_btn_vals & ugame.K_DOWN
|
||||
cur_right = cur_btn_vals & ugame.K_RIGHT
|
||||
cur_left = cur_btn_vals & ugame.K_LEFT
|
||||
cur_a = cur_btn_vals & ugame.K_O
|
||||
|
||||
if GAME_STATE["STATE"] == STATE_WAITING:
|
||||
print(cur_a)
|
||||
|
|
|
|||
Loading…
Reference in a new issue