Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Pygame player class design

Author
Message
mrpeed
10
Years of Service
User Offline
Joined: 23rd Feb 2014
Location:
Posted: 23rd Feb 2014 02:57
Hello,
I'm fairly new to PyGame, what is the proper way to
define a player class? Right now it inherits from Rect
and it stores images as variables. Is this way OK?
Should I use spiriting? Thanks!

class Player(pygame.Rect):
def __init__(self, cords, size, current_image,
up_image_1, up_image_2,
down_image_1, down_image_2,
left_image_1, left_image_2,
right_image_1, right_image_2,
action):

super().__init__(cords, size)

self.current_image = current_image
self.up_image_1 = up_image_1
self.up_image_2 = up_image_2
self.down_image_1 = down_image_1
self.down_image_2 = down_image_2
self.left_image_1 = left_image_1
self.left_image_2 = left_image_2
self.right_image_1 = right_image_1
self.right_image_2 = right_image_2

self.action = action

Login to post a reply

Server time is: 2024-02-23 20:05:46
Your offset time is: 2024-02-23 20:05:46