Python Forum
moving bullets up the screen using y-coordinate
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
moving bullets up the screen using y-coordinate
#2
We are used to the origin in a coordinate system (0, 0) being in the bottom-left corner of a grid. In Pygame, and in many graphical frameworks, the origin is at the top left corner. So on a 1200x800 game window, the top left corner is (0, 0), and the bottom left corner is (0, 800). If you want to move up from the screen, you steadily decrease the y-value.

The origin is placed at the top because the top of a window is typically static on a screen. When people resize their windows, they typically drag the bottom of the screen, and any overflow happens at the bottom.

If you're curious to see the actual coordinates of any game object, you can throw a line into the _update_screen() method like this:

print(f"Ship coordinates: {ship.rect.x} {ship.rect.y}")
Reply


Messages In This Thread
RE: moving bullets up the screen using y-coordinate - by ehmatthes - Nov-09-2019, 02:08 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] When I hit the space bar from the home screen, it sends me to the game over screen JesusisKing 1 1,083 Apr-30-2023, 10:11 PM
Last Post: deanhystad
  [PyGame] pygame.draw.rect function stretches across the screen instead of moving BubblesTheGiraffe 2 3,733 Jun-11-2019, 08:32 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

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