Mar-25-2020, 04:00 AM
I'm facing great frustration with making a minimap/radar that follows the player. It's an open space game and I really need to implement one.
Everything in the game has a vector position, and I keep the player in the middle of the screen by subtracting the it's velocity from everything else. I've made a map by just scaling everything down, but my attempts to center and follow the player on the map are just a mess.
Google hasn't yielded any examples I can follow. Here is what I have now after gutting it. It's not working (at all) but it shows what I've been trying.
the
Everything in the game has a vector position, and I keep the player in the middle of the screen by subtracting the it's velocity from everything else. I've made a map by just scaling everything down, but my attempts to center and follow the player on the map are just a mess.
Google hasn't yielded any examples I can follow. Here is what I have now after gutting it. It's not working (at all) but it shows what I've been trying.
the
map_pos
is the just the sprites position divided 10 for a start. class Mini_map(pg.sprite.Sprite): def __init__(self, game, screen): pg.sprite.Sprite.__init__(self) self.surface = pg.Surface((200, 200)) self.surface.fill((0, 0, 0)) self.rect = self.surface.get_rect() self.game = game self.screen = screen self.image = self.surface def update(self): self.image = self.surface.copy() for sprite in self.game.objects: sprite.map_pos -= self.game.player.velocity / 10 pg.draw.circle(self.image, (200, 200, 200), (round(sprite.map_pos.x), round(sprite.map_pos.y)), 1) self.game.player.map_pos + self.game.player.velocity / 10 pg.draw.circle(self.image, (200, 0, 200), self.rect.center, 1) #this is to represent #the playerThe frustration is that this should be easy lol. Could someone point out an example to look at or suggest what numbers I should be working with. Thanks.