Sprites, yesterday and today. Refactoring the Content design, because Sprites. You may be forgiven for not recalling that dungeon content items used to be drawn by drawing textures in a rectangle at the appropriate coordinates: class ContentPainter: error_texture = ':resources:images/items/star.png' def __init__(self, resource, scale=0.5): self.scale = scale try: self.shape = arcade.load_texture(resource) except (FileNotFoundError, AttributeError): self.shape = arcade.load_texture(self.error_texture) def draw(self, cx, cy, cell_size): texture = self.shape scale = scale_texture(texture, self.scale) arcade.draw_texture_rect( texture, arcade.XYWH(cx, cy, texture.width, texture.height).scale(scale) ) ContentPainter is yesterday’s Method Object that allows all the different types of Content to avoid duplicating those two methods, instead relying on a ContentPainter to do the job for them. But that was the morning. In the afternoon I had a little time and converted the ContentPainter to use…
No comments yet. Log in to reply on the Fediverse. Comments will appear here.