Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame # Import library of functions called 'pygame'
- import random
- import time
- import itertools
- import pygame, os
- os.environ['SDL_VIDEO_CENTERED'] = '1'
- class Digimon(pygame.sprite.Sprite):
- def __init__(self):
- pygame.sprite.Sprite.__init__(self,age,weight,strength,defence,speed,intelligence, image)
- self.age = age
- self.weight = weight
- self.strength = strength
- self.defence = defence
- self.speed = speed
- self.intelligence = intelligence
- self.image = image
- ############################################
- Player = Digimon(0,2,0,0,0,0, [pygame.image.load("images/koro_1.png"), pygame.image.load("images/koro_2.png"), pygame.image.load("images/koro_3.png") ] )
- Player_sprites = itertools.cycle(Player.image)
- ############################################
- Egg = Digimon(0,2,0,0,0,0, [pygame.image.load("images/egg_1.png"), pygame.image.load("images/egg_2.png"), pygame.image.load("images/egg_3.png") ]) # egg object
- Egg_sprites = itertools.cycle(Egg.image)
- ########################################
- Ghost = Digimon(0,2,0,0,0,10, [pygame.image.load("images/51.png"), pygame.image.load("images/51.png"), pygame.image.load("images/51.png") ]) # egg object
- Ghost_sprites = itertools.cycle(Ghost.image)
- ##################################################
- ##################################################
- pygame.init() # initialise game engine
- screen_width=400
- screen_height=150
- screen = pygame.display.set_mode([screen_width,screen_height])
- pygame.display.set_caption("Digimon Simulator 1")
- black = ( 0, 0, 0) # defines colours for ease of use
- white = (255,255,255)
- green = ( 0, 255, 0) # Red, Green, Blue
- red = ( 255, 0, 0)
- blue = ( 0, 0, 255)
- clock = pygame.time.Clock() # controls how fast the game runs
- font = pygame.font.Font(None, 15)
- counter = 0
- done = False # loop control
- # -------- Main Program Loop -----------
- while not done:
- # ALL EVENT PROCESSING SHOULD GO BELOW THIS COMMENT
- for event in pygame.event.get(): # User did something
- if event.type == pygame.QUIT: # If user clicked close
- done = True # Flag that we are done so we exit this loop
- if event.type == pygame.MOUSEBUTTONDOWN:
- # Set the x, y postions of the mouse click
- x,y = event.pos
- if ( x in range(250,270)) and \
- ( y in range(10,30)):
- Player.age += 1
- ## if mouse is pressed get position of cursor ##
- # ALL EVENT PROCESSING SHOULD GO ABOVE THIS COMMENT
- screen.fill(white)
- # ALL GAME LOGIC SHOULD GO BELOW THIS COMMENT
- if counter <= 100:
- Egg_sprites_next = Egg_sprites.next()
- screen.blit((Egg_sprites_next), (189,119))
- screen.blit((Egg_sprites_next), (189,119))
- screen.blit((Egg_sprites_next), (189,119))
- counter += 10
- else:
- Ghost_sprites_next = Ghost_sprites.next()
- screen.blit((Ghost_sprites_next), (189,119))
- screen.blit((Ghost_sprites_next), (189,119))
- screen.blit((Ghost_sprites_next), (189,119))
- # tomorrow I have to make some button that adds str, etc. Then do if Player.stats(whatever) == Koromon: then do the things below; change sprite
- if Player.age == 10:
- for i in range(1,2):
- print "hello"
- # ALL GAME LOGIC SHOULD GO ABOVE THIS COMMENT
- # ALL CODE TO DRAW SHOULD GO BELOW THIS COMMENT
- Age_button = pygame.draw.rect(screen, black, [250,10, 20,20], 0) # [x,y top left point, width, height], how wide the line around the rectangle is. If 0, rect is filled.
- counter_text = font.render("Counter: " + str(counter), True, black) # font uses the font fuction above, (what to draw, anti-alias, colour)
- screen.blit(counter_text, [10, 50] )
- counter_text = font.render("Player Age " + str(Player.age), True, black) # font uses the font fuction above, (what to draw, anti-alias, colour)
- screen.blit(counter_text, [10, 10] )
- pygame.display.flip() # shows screen fill.
- # ALL CODE TO DRAW SHOULD GO ABOVE THIS COMMENT
- clock.tick(5) # Limit to 5 frames per second
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement