Sunday, 2 October 2016

Python Links

I am doing some Python coding.
I like python but is suffers from lack of maturity in library and documentation.

Interesting blog on python http://love-python.blogspot.com.au/

Code I am working on
just want to publish to see how it is done:

Used the link http://codeformatter.blogspot.com.au/
to format the code in to highlighted source code.
Now just need to work out how to add key words and tags

 import pygame  
 #Predefined Colours  
 MyColor = pygame.Color(46,139,87)  
 Black = pygame.Color(0, 0, 0)  
 class BaseSprite(pygame.sprite.Sprite):  
   def __init__(self, aimage, aposition):  
     # Call the parent class (Sprite) constructor  
     super(BaseSprite,self).__init__()  
     #This is initilisation  
     self.image = pygame.image.load(aimage)  
     self.rect = pygame.Rect(self.image.get_rect())  
     self.rect.topleft = aposition  
   def move(self,distance):  
     self.rect = self.rect.move(distance)  
   def update(self):  
     #intent determine what to do  
     distance = [0,0]  
     #exicute   
     self.rect = self.rect.move(distance)  
 class StaticSprite(BaseSprite):  
   def __init__(self, aimage, aposition):  
     # Call the parent class (Sprite) constructor  
     BaseSprite.__init__(self, aimage, aposition)  
     #This is initilisation  
 class ActorSprite(BaseSprite):  
   def __init__(self, aimage, aposition):  
     # Call the parent class (Sprite) constructor  
     BaseSprite.__init__(self, aimage, aposition)  
     #This is initilisation  
   def update(self):  
     #intent determine what to do  
     distance = [1,1]  
     #exicute   
     self.rect = self.rect.move(distance)  

No comments:

Post a Comment