Python Forum
[Pyglet] Space ships movements
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pyglet] Space ships movements
#2
The math is pretty simple
import math
def get_direction(angle):
    rad = math.radians(angle)
    return math.cos(rad), math.sin(rad)
You might have to adjust angle for math to work as expected. Like 90, 180, -90.
No more thinking up is up. It is now forward. You have to add to x and y for up and down.
Up.
direction = get_direction(angle)
x += direction[0] * dt * 100
y += direction[1] * dt * 100
99 percent of computer problems exists between chair and keyboard.
Reply


Messages In This Thread
Space ships movements - by pierrem13 - Nov-29-2017, 03:08 AM
RE: Space ships movements - by Windspar - Nov-29-2017, 04:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Battleships Program must display how many ships are left after each turn FnaticPutin 1 3,168 Oct-24-2017, 03:21 PM
Last Post: Windspar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020