forked from ZippyCodeYT/Zippy_Codes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2DShooting.py
49 lines (41 loc) · 1.12 KB
/
2DShooting.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
from ursina import *
app = Ursina()
bg = Entity(model='quad', texture='assets\BG', scale=36, z=1)
window.fullscreen = True
player = Animation('assets\player', collider='box', y=5)
fly = Entity(model='cube', texture='assets\\fly1', collider='box',
scale=2, x=20, y=-10)
flies = []
def newFly():
new = duplicate(fly,y=-5+(5124*time.dt)%15)
flies.append(new)
invoke(newFly, delay=1)
newFly()
camera.orthographic = True
camera.fov = 20
def update():
player.y += held_keys['w']*6*time.dt
player.y -= held_keys['s'] *6* time.dt
a = held_keys['w']*-20
b = held_keys['s'] *20
if a != 0:
player.rotation_z = a
else:
player.rotation_z = b
for fly in flies:
fly.x -= 4*time.dt
touch = fly.intersects()
if touch.hit:
flies.remove(fly)
destroy(fly)
destroy(touch.entity)
t = player.intersects()
if t.hit and t.entity.scale==2:
quit()
def input(key):
if key == 'space':
e = Entity(y=player.y, x=player.x+1, model='cube', scale=1,
texture='assets\Bullet', collider='cube')
e.animate_x(30,duration=2,curve=curve.linear)
invoke(destroy, e, delay=2)
app.run()