Advertisement
Guest User

stack

a guest
Mar 5th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.01 KB | None | 0 0
  1. import pygame # Import library of functions called 'pygame'
  2. import random
  3. import time
  4. import itertools
  5. import pygame, os
  6.  
  7. os.environ['SDL_VIDEO_CENTERED'] = '1'
  8.  
  9. class Digimon(pygame.sprite.Sprite):
  10.     def __init__(self):
  11.         pygame.sprite.Sprite.__init__(self,age,weight,strength,defence,speed,intelligence, image)
  12.         self.age = age  
  13.         self.weight = weight    
  14.         self.strength = strength
  15.         self.defence = defence  
  16.         self.speed = speed  
  17.         self.intelligence = intelligence
  18.         self.image = image
  19.  
  20. ############################################
  21.  
  22. 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") ] )
  23.  
  24. Player_sprites = itertools.cycle(Player.image)
  25.  
  26. ############################################
  27.  
  28. 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
  29.  
  30. Egg_sprites = itertools.cycle(Egg.image)
  31.  
  32. ########################################
  33.  
  34. 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
  35.  
  36. Ghost_sprites = itertools.cycle(Ghost.image)
  37.  
  38. ##################################################
  39.  
  40.  
  41. ##################################################
  42. pygame.init() # initialise game engine
  43.  
  44. screen_width=400
  45. screen_height=150
  46. screen = pygame.display.set_mode([screen_width,screen_height])
  47.  
  48. pygame.display.set_caption("Digimon Simulator 1")
  49.  
  50. black = (  0,  0,  0) # defines colours for ease of use
  51. white = (255,255,255)
  52. green = (  0, 255, 0) # Red, Green, Blue
  53. red   = (  255, 0, 0)
  54. blue =  (  0, 0, 255)
  55.  
  56. clock = pygame.time.Clock() # controls how fast the game runs
  57.  
  58. font = pygame.font.Font(None, 15)
  59.  
  60. counter = 0
  61.  
  62. done = False # loop control
  63.  
  64. # -------- Main Program Loop -----------
  65. while not done:
  66.     # ALL EVENT PROCESSING SHOULD GO BELOW THIS COMMENT
  67.     for event in pygame.event.get():    # User did something
  68.         if event.type == pygame.QUIT: # If user clicked close
  69.             done = True # Flag that we are done so we exit this loop
  70.         if event.type == pygame.MOUSEBUTTONDOWN:
  71.             # Set the x, y postions of the mouse click
  72.             x,y = event.pos
  73.             if ( x  in range(250,270)) and \
  74.                ( y in range(10,30)):
  75.            
  76.                 Player.age += 1
  77.                 ## if mouse is pressed get position of cursor ##
  78.     # ALL EVENT PROCESSING SHOULD GO ABOVE THIS COMMENT
  79.    
  80.     screen.fill(white)
  81.     # ALL GAME LOGIC SHOULD GO BELOW THIS COMMENT
  82.    
  83.     if  counter <= 100:
  84.    
  85.         Egg_sprites_next = Egg_sprites.next()
  86.         screen.blit((Egg_sprites_next), (189,119))
  87.         screen.blit((Egg_sprites_next), (189,119))
  88.         screen.blit((Egg_sprites_next), (189,119))
  89.         counter += 10
  90.    
  91.     else:
  92.        
  93.         Ghost_sprites_next = Ghost_sprites.next()
  94.         screen.blit((Ghost_sprites_next), (189,119))
  95.         screen.blit((Ghost_sprites_next), (189,119))
  96.         screen.blit((Ghost_sprites_next), (189,119))
  97.  
  98.         # 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
  99.            
  100.     if Player.age == 10:
  101.         for i in range(1,2):
  102.             print "hello"
  103.        
  104.    
  105.            
  106.        
  107.     # ALL GAME LOGIC SHOULD GO ABOVE THIS COMMENT
  108.  
  109.     # ALL CODE TO DRAW SHOULD GO BELOW THIS COMMENT
  110.    
  111.     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.
  112.    
  113.    
  114.    
  115.     counter_text = font.render("Counter: " + str(counter), True, black) # font uses the font fuction above, (what to draw, anti-alias, colour)
  116.    
  117.     screen.blit(counter_text, [10, 50]  )
  118.    
  119.     counter_text = font.render("Player Age " + str(Player.age), True, black) # font uses the font fuction above, (what to draw, anti-alias, colour)
  120.    
  121.     screen.blit(counter_text, [10, 10]  )
  122.    
  123.     pygame.display.flip() # shows screen fill.
  124.    
  125.     # ALL CODE TO DRAW SHOULD GO ABOVE THIS COMMENT
  126.     clock.tick(5) # Limit to 5 frames per second
  127.    
  128. pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement