-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
74 lines (66 loc) · 1.5 KB
/
app.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
from typing import Sized
from ursina import *
from ursina import texture
from ursina import collider
from ursina import curve
app = Ursina()
me = Animation('assets/animation',collider='box',x=-12,y=5,scale=5)
Sky()
camera.orthographic = True
camera.fov = 20
Entity(model='quad',texture='assets/bg',scale=37,z=1)
fly = Entity(
model='cube',
texture='assets/enemy',
collider='box',
scale=2,
x=20,
y=-10
)
flies = []
def newFly():
new = duplicate(
fly,
y=-5+(5214*time.dt)%15
)
flies.append(new)
invoke(newFly, delay=1)
newFly()
def update():
for fly in flies:
fly.x -= 4*time.dt
me.y += held_keys['w']*6*time.dt
me.y -= held_keys['s']*6*time.dt
me.x += held_keys['d']*6*time.dt
me.x -= held_keys['a']*6*time.dt
a = held_keys['w']*-20
b = held_keys['s']*20
if a != 0:
me.rotation_z = a
else :
me.rotation_z = b
for fly in flies:
fly.x -= 4*time.dt
touch = fly.intersects()
if touch.hit:
flies.remove(fly)
destroy(fly)
t = me.intersects()
if t.hit and t.entity.scale==2:
quit()
def input(key):
if key == 'space':
e = Entity(
y = me.y,
x = me.x+4,
model='cube',
texture='assets/ammo',
collider='cube'
)
e.animate_x(
30,
duration=2,
curve=curve.linear
)
invoke(destroy, e, delay=2)
app.run()