-
-
Notifications
You must be signed in to change notification settings - Fork 326
/
platformer.py
40 lines (31 loc) · 1.46 KB
/
platformer.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 time
# t = time.time()
from ursina import *
from ursina.prefabs.platformer_controller_2d import PlatformerController2d
# window.vsync = False
window.borderless = False
app = Ursina()
window.color = color.light_gray
camera.orthographic = True
camera.fov = 20
ground = Entity(model='cube', color=color.olive.tint(-.4), z=-.1, y=-1, origin_y=.5, scale=(1000,100,10), collider='box', ignore=True)
random.seed(4)
for i in range(10):
Entity(model='cube', color=color.dark_gray, collider='box', ignore=True, position=(random.randint(-20,20), random.randint(0,10)), scale=(random.randint(1,20), random.randint(2,5), 10))
# ground = Entity(model='cube', color=color.white33, origin_y=.5, scale=(20, 10, 1), collider='box')
# wall = Entity(model='cube', color=color.azure, origin=(-.5,.5), scale=(5,10), x=10, y=.5, collider='box')
# ceiling = Entity(model='cube', color=color.white33, origin_y=.5, scale=(10, 1, 1), y=4, collider='box')
player = PlatformerController2d()
player.x=1
player.y = raycast(player.world_position, player.down).world_point[1] + .01
camera.add_script(SmoothFollow(target=player, offset=[0,5,-30], speed=4))
input_handler.bind('right arrow', 'd')
input_handler.bind('left arrow', 'a')
input_handler.bind('up arrow', 'space')
input_handler.bind('gamepad dpad right', 'd')
input_handler.bind('gamepad dpad left', 'a')
input_handler.bind('gamepad a', 'space')
# test
from ursina.scripts.noclip_mode import NoclipMode2d
player.add_script(NoclipMode2d())
app.run()