@jajoosam/

playdemo

Pygame

A simple demo game using Python Play: https://github.com/replit/play

fork
loading
Files
  • main.py
  • nohup.out
  • requirements.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import play

play.set_backdrop(play.random_color())

box = play.new_box(color=play.random_color())
box.start_physics()
box.is_being_dragged = False

circle = play.new_circle(color=play.random_color())
circle.start_physics()
circle.is_being_dragged = False

@play.repeat_forever
async def do():
  circle.color = play.random_color()
  box.color = play.random_color()
  play.set_backdrop(play.random_color())
  await play.timer(seconds=0.5)

@box.when_clicked
def do():
    box.is_being_dragged = True

@circle.when_clicked
def do():
    circle.is_being_dragged = True

@play.mouse.when_click_released
def do():
    box.is_being_dragged = False
    circle.is_being_dragged = False

@play.repeat_forever
def do():
    if box.is_being_dragged:
        box.go_to(play.mouse)
    if circle.is_being_dragged:
        circle.go_to(play.mouse)

play.start_program()