'Stuck on how to make text appear as "assets" enter circle
Making a small game through pygame zero. trying to get text to appear on "assets" as they enter the circle. Have tried different methods with rect but end up with errors. This is apart of my code. Have been using Pygame-zero to try and work through my problem. Any help would be greatly appreciated.
def update():
global score
global v
global radius
global b
#to move robot
if keyboard.right:
v = v + 0.1
if keyboard.left:
v = v - 0.1
if keyboard.up:
radius = radius + 10
if keyboard.down:
radius = radius - 10
robot.right += v
if robot.right > 400 + radius:
robot.left = 400 - radius
if keyboard.a:
robot.right += -b
if keyboard.l:
robot.right += b
#to drop asssets
for asset in assets:
asset.y += 1.2
for asset in assets:
if asset.colliderect(robot):
score += 150
assets.remove(asset)
#to calculate distance between robot and asset
# elif keyboard.k_1:
# bias = bias + 0.1
# elif keyboard.k_0:
# bias = bias - 0.1
def draw():
screen.fill((BLACK))
screen.draw.circle((400,600),radius,(220,20,60))
for asset in assets:
asset.draw()
robot.draw()
drawScore()
pgzrun.go()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
