Hey, still a beginner in Python. I was wondering if anybody could help me out with all this info.
Im planning to make an actual game, but first i have to get classes/methods etc.
I thought maybe this would be some good classes:
Trainer, Pokemon, Moves, Stats, Type, Pokeball, Pokedex
There is so much stuff to incorporate i dont know what to put where.
any help would be great

Member Avatar for Mouche

The Pokemon game involves a lot of different things -- wandering around a map, talking to NPCs, battling Pokemon, managing your inventory, etc. I would pick one thing to start working on and grow the game from there.

For example, you might start with a Pokemon battle. You would need Pokemon with stats and several attacks and have a system where each Pokemon takes turns using an ability until one faints. Once you have that working, you could add in a Trainer who can swap between multiple Pokemon. From there, you might consider what happens when the battle ends. At that point, you would need to develop the Pokemon class to understand leveling and gaining new abilities and improved stats at certain levels. From there, you can add in items (e.g. Pokeballs, potions).

Before you make any game using python or any programming language you need to first map out the game, how you want to make it look, the characters and the fight scenes. From there making an oop game with class should be easy.

I have some extremely simple code for player sprite. Its over coded i think, still in process.
Anyway, I have a problem. Im loading a png image (spritesheet, col=2, row=4) and use the 1st column for the up/down/left/right orientation of the sprite. The 2nd column is the image in a walking position. I need to use that 2nd column to make the sprite look like he's walking. I was thinking to set all 8 images in the file beforehand and use it that way. Im using coordinates to cut parts and reassigning/updating rect. Now heres the problem. No matter how hard i try/think, i cant figure out how to switch between images. ..... constantly. Im saying that i need to switch the image with key.get_pressed (up down etc) respectively. For example, the coordinates for sprite facing down is (0,0) and the walking image of that is (0,64). Now i need to switch between these two while the down key is held.
Help plz!!

# File Name: player.py
# Description: Demonstrates how to implement animated sprites
#########################################
import pygame
pygame.init()

HEIGHT = 480
WIDTH  = 640
screen=pygame.display.set_mode((WIDTH,HEIGHT))
BLACK = (   0,   0,   0)

STEP = 16
BACKWARD = -STEP
FORWARD = STEP

up = False
down = False
left = False
right = False


#---------------------------------------#
#   classes                             #
#---------------------------------------#
class AnimatedSprite(pygame.sprite.Sprite):
    """ (fileName, int, int)
        Sequence of 2D images, assembled in rows.
        Inherits Sprite to use its Rect property.
        See Sprite documentation here: 
        http://www.pygame.org/docs/ref/sprite.html#pygame.sprite.Sprite
    """    
    def __init__(self, spritesheet, columns, rows):
        pygame.sprite.Sprite.__init__(self)
        self.x = 0
        self.y = 0
        self.visible = False
        self.columns = columns
        self.rows = rows
        self.numImages = columns * rows # number of images in the file

        self.spritesheet = pygame.image.load(spritesheet)
        self.spritesheet = self.blend_image(spritesheet)
        sheetrect = self.spritesheet.get_rect()     
        self.width,self.height = sheetrect.width, sheetrect.height
        self.width = self.width/columns
        self.height = self.height/rows
        self.rect = pygame.Rect(self.x, self.y, self.width, self.height)
        down = True
        self.orientation_down()

    def spawn(self, x, y):
        """ Assign coordinates to the object and make it visible.
        """
        self.x, self.y = x,y
        self.rect = pygame.Rect(self.x, self.y, self.width, self.height)
        self.visible = True

    def draw(self, surface):
        surface.blit(self.image, self.rect)

    def blend_image(self, spritesheet):
        """ Remove background colour of an image.
            Need to use it when a picture is stored in BMP or JPG format, with opaque background.
        """
        image_surface = pygame.image.load(spritesheet)
        image_surface = image_surface.convert() 
        colorkey = image_surface.get_at((0,0))  
        image_surface.set_colorkey(colorkey)    
        return image_surface

    def activate_up(self):          # set of bool values designed as a
        up = True                   # orientation detection
        down = False
        left = False                # purpose is for user interface, using
        right = False               # arrow keys; when another key is pressed
    def activate_down(self):        # while one is already being held down,
        down = True             # it will cancel out the held and assign new
        up = False
        left = False
        right = False
    def activate_left(self):
        left = True
        up = False
        down = False
        right = False
    def activate_right(self):
        right = True
        up = False
        down = False
        left = False

    def orientation_up(self):
        """ Clip-out one image from the spritesheet (as per the index),
            and assign it as the current image.
        """
        up = True
        self.spritesheet.set_clip(0, 64, self.width, self.height)
        self.image = self.spritesheet.subsurface(self.spritesheet.get_clip())
    def orientation_down(self):
        down = True   
        self.spritesheet.set_clip(0, 0, self.width, self.height)
        self.image = self.spritesheet.subsurface(self.spritesheet.get_clip())
    def orientation_left(self):
        left = True
        self.spritesheet.set_clip(0, 128, self.width, self.height)
        self.image = self.spritesheet.subsurface(self.spritesheet.get_clip())
    def orientation_right(self):
        right = True
        self.spritesheet.set_clip(0, 192, self.width, self.height)
        self.image = self.spritesheet.subsurface(self.spritesheet.get_clip())


    def walking_up(self,step):
        if step<0:
            self.orientation_up() 
        self.y = self.y + step
        self.rect = pygame.Rect(self.x, self.y, self.width, self.height)
##        self.image = pygame.transform.flip(self.image, True, False)
    def walking_down(self,step):
        if step>0:
            self.orientation_down()
        self.y = self.y + step
        self.rect = pygame.Rect(self.x, self.y, self.width, self.height)
    def walking_left(self,step):
        if step<0:
            self.orientation_left()
        self.x = self.x + step
        self.rect = pygame.Rect(self.x, self.y, self.width, self.height)
    def walking_right(self,step):
        if step>0:
            self.orientation_right()
        self.x = self.x + step
        self.rect = pygame.Rect(self.x, self.y, self.width, self.height)


#---------------------------------------#
#   functions                           #
#---------------------------------------#
def redraw_screen():
    screen.fill(BLACK)
    if player.visible:
        player.draw(screen)
    pygame.display.update()

#---------------------------------------#
# main program starts here              #
#---------------------------------------#     
player = AnimatedSprite("sprites/player.png",2,4)
player.spawn(100,400)

clock = pygame.time.Clock()
FPS = 10
inPlay = True  

while inPlay:
    clock.tick(FPS)

    pygame.event.get()                  
    keys = pygame.key.get_pressed()                                         
    if keys[pygame.K_ESCAPE]:           
        inPlay = False
    if keys[pygame.K_UP]:
        player.walking_up(BACKWARD)
    if keys[pygame.K_DOWN]:
        player.walking_down(FORWARD)
    if keys[pygame.K_LEFT]:
        player.walking_left(BACKWARD)
    if keys[pygame.K_RIGHT]:
        player.walking_right(FORWARD)
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_UP:
                if not player.walking_up(BACKWARD):
                    if up == False:           
                        player.activate_up()
                        player.orientation_up()
            if event.key == pygame.K_DOWN:
                if down == False:
                    player.activate_down()
                    player.orientation_down()
            if event.key == pygame.K_LEFT:
                if not player.walking_left(BACKWARD):
                    if left == False:
                        player.activate_left()
                        player.orientation_left()
            if event.key == pygame.K_RIGHT:
                if not player.walking_right(FORWARD):
                    if right == False:
                        player.activate_right()
                        player.orientation_right()


    redraw_screen()
#---------------------------------------#     
pygame.quit()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.