Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to fly straight up #73

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,10 @@ def get_motion_vector(self):
dy = 0.0
dx = math.cos(x_angle)
dz = math.sin(x_angle)
elif self.flying and not self.dy == 0:
dx = 0.0
dy = self.dy
dz = 0.0
else:
dy = 0.0
dx = 0.0
Expand Down Expand Up @@ -721,7 +725,9 @@ def on_key_press(self, symbol, modifiers):
elif symbol == key.D:
self.strafe[1] += 1
elif symbol == key.SPACE:
if self.dy == 0:
if self.flying:
self.dy = 0.5 * JUMP_SPEED
elif self.dy == 0:
self.dy = JUMP_SPEED
elif symbol == key.ESCAPE:
self.set_exclusive_mouse(False)
Expand Down Expand Up @@ -751,6 +757,8 @@ def on_key_release(self, symbol, modifiers):
self.strafe[1] += 1
elif symbol == key.D:
self.strafe[1] -= 1
elif symbol == key.SPACE:
self.dy = 0

def on_resize(self, width, height):
""" Called when the window is resized to a new `width` and `height`.
Expand Down