-
Notifications
You must be signed in to change notification settings - Fork 1
/
home.py
93 lines (79 loc) · 2.95 KB
/
home.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import flet as ft
import time
#Func play game start in level 1
class Home(ft.UserControl):
def __init__(self, func):
super().__init__()
self.on_play= func
self.running=True
self.c=ft.Container(
on_hover=self.on_hover,
on_click=self.on_play,
width=80,
height=50,
bgcolor=ft.colors.PINK_ACCENT,
border_radius=15,
scale=ft.transform.Scale(scale=1),
animate_scale=ft.animation.Animation(600, ft.AnimationCurve.BOUNCE_OUT),
content=ft.Text(
"Play",
color=ft.colors.WHITE,
size=25,
weight=ft.FontWeight.BOLD,
),
alignment=ft.alignment.center,
)
def did_mount(self):
while self.running:
if self.c.scale==1:
self.c.scale=1.1
else:
self.c.scale=1
self.update()
time.sleep(1)
def on_hover(self, e):
e.control.bgcolor = "blue" if e.data == "true" else "pinkaccent"
e.control.update()
def build(self):
self.home = ft.Stack(
width=950,
height=700,
controls=[
ft.Container(image_src="assets/background.png", image_fit=ft.ImageFit.COVER),
ft.Container(
width=300,
height=300,
bgcolor=ft.colors.TEAL_300,
border_radius=15,
content=ft.Column(
[
ft.Text(
"Fruit Crush",
size=40,
weight=ft.FontWeight.BOLD,
color=ft.colors.WHITE70,
),
ft.Image(src="assets/avatar.png", width=100, height=100),
self.c,
],
alignment=ft.MainAxisAlignment.CENTER,
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
),
alignment=ft.alignment.center,
top=200,
left=300,
),
],
)
return self.home
"""
def main(page: ft.Page):
page.padding = 0
page.window_height = 700
page.window_width = 950
page.window_resizable = False
def play_game(e):
print("go Game")
page.add(Home(play_game))
ft.app(target=main)
"""