Python Forum
How to make an image move in relation to another in PYGAME
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make an image move in relation to another in PYGAME
#1
I'm trying to make a boat in pygame. I have two image: a boat and a tiller. The tiller can rotate around an axis at the back of the boat using the button left and right and the boat can move around the screen and rotate. My problem is that the two are separate(i load one image and then the other). Is it possible to make an object(oop) of a boat that when I call and rotate the two image act as one? If so how?
Reply
#2
Set the tiller offset to a fixed point off the boat. Then move the boat around. This can be done by creating a boat class. Which will make it a lot easier to pass data back and forth.

Psuedocode...
boat_rect = boatimage.get_rect()
Tillerrect = boat_rect.center() #modify center to specific locations
Move boat_rect coordinates and the tiller will move too
Recommended Tutorials:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question [PyGame] my pygame car wont move Erio85 1 1,085 Apr-24-2023, 04:52 PM
Last Post: Erio85
  [PyGame] pygame-manu : using controller buttons to move around menu mlw19mlw91 2 1,631 Mar-12-2023, 01:55 PM
Last Post: deanhystad
  Pygame Zero - no actor image toiling_away 2 1,808 Oct-14-2022, 12:16 AM
Last Post: toiling_away
  How to make enemy chase me in pygame? Jan_97 3 4,414 Nov-23-2021, 05:08 PM
Last Post: Jan_97
  cant make a door automatically close a few seconds after i open it in pygame cooImanreebro 2 2,263 Dec-15-2020, 08:40 PM
Last Post: michael1789
  Getting a ship to move in pygame djwilson0495 2 3,629 Dec-09-2020, 11:03 AM
Last Post: djwilson0495
  [PyGame] how to make objects move at a precise amount of time? Zhaleh 2 2,614 Aug-02-2020, 02:52 PM
Last Post: Zhaleh
  Trying to make boundries for the pygame bluewing101 2 2,043 Mar-23-2020, 01:35 AM
Last Post: Windspar
  open cv ->pygame: turn image into location Gamedeveloper 1 2,068 Jan-20-2020, 05:00 PM
Last Post: michael1789
  How can I make all of the background move as opposed to just one platform? HelpMEE 6 2,948 Dec-28-2019, 11:04 PM
Last Post: HelpMEE

Forum Jump:

User Panel Messages

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