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
#1
Hello, python world.
I'm studying python using the book called 'Python Crash Course'.
There's a portion of the book making a game using Pygame and I'm at the part to code bullet module for a ship to fire a bullet.
Here's a bit of the codes I'm confused about.
def __init__(self, ai_game):
    --snip--
    # Create a bullet rect at (0, 0) and then set correct position.
    self.rect = pygame.Rect(0, 0, self.settings.bullet_width,
        self.settings.bullet_height)
    self.rect.midtop = ai_game.ship.rect.midtop
    --snip--
def update(self):
    """Move the bullet up the screen."""
    # Update the decimal position of the bullet.
    self.y -= self.settings.bullet_speed
and, the last line "self.y -= self.settings.bullet_speed",
Why minus? the bullet's starting position is at the bottom and it's supposed to go up along the y-axis. what am i missing?
Reply


Messages In This Thread
moving bullets up the screen using y-coordinate - by allusernametaken - Nov-09-2019, 01:33 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,069 Apr-30-2023, 10:11 PM
Last Post: deanhystad
  [PyGame] pygame.draw.rect function stretches across the screen instead of moving BubblesTheGiraffe 2 3,725 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