Commits

illume committed e32e3e6

Added Hero images and start of sprite

Comments (0)

Files changed (5)

 ====
 
 
-* duck flying across
 * hero
 * baddy
 * hole in the floor
 DONE
 ====
 
+* duck flying across
 * floor moving
 * create status indicator
 * start basic classes for each object needed.

outofdesert/data/hero-duck.png

Added
New image

outofdesert/data/hero.png

Added
New image

outofdesert/data/hero.xcf

Binary file added.

outofdesert/main.py

 WIDTH, HEIGHT = 640,480
 
 
+def load_image(name, colorkey=None):
+    fullname = data_dir(name)
+    try:
+        image = pygame.image.load(fullname)
+    except pygame.error:
+        print ('Cannot load image:', fullname)
+        raise SystemExit(str(geterror()))
+    #image = image.convert()
+    if colorkey is not None:
+        if colorkey is -1:
+            colorkey = image.get_at((0,0))
+        image.set_colorkey(colorkey, RLEACCEL)
+    return image
+
+
+
 class Sprite(pygame.sprite.DirtySprite):
     def start(self):
         self.image = None
         self.duck.add(self)
         self.duck.fly()
 
+        self.hero = Hero().start()
+        self.hero.add(self)
+
+
         return self
 
 
 class Hero(Sprite):
+
     def start(self):
-        pass
+        self.images = {}
+        self.images['stand'] = load_image(data_dir("hero.png"))
+        self.images['duck'] = load_image(data_dir("duck.png"))
+        self.image = self.images['stand']
+        self.rect = Rect(int(WIDTH / 2), HEIGHT - (40 + self.image.get_height()), 64, 128)
+        self.dy = 0
+        self.count = 0
+        self.dirty = 1
+        return self
+
+    def fly(self):
+        self.dx = -1
+    def stop(self):
+        self.dx = 0
+    def update(self, *args):
+        self.count += 1
+        #self.rect.x += self.dx
+        #self.dirty = 1
+
+
+
+
 
 class Baddy(Sprite):
     def start(self):
 
     def start(self):
         self.rect = Rect(WIDTH + 32, HEIGHT - 200, 32, 32)
-        self.image = pygame.image.load(data_dir("duck.png"))
-
+        self.rect = Rect(WIDTH + 2, HEIGHT - 200, 32, 32)
+        #self.image = load_image(data_dir("duck.png"), (255,255,255))
+        self.image = load_image(data_dir("duck.png"))
         self.dy = 0
         self.count = 0
         return self
         self.count += 1
         #where is duck?
         self.rect.x += self.dx
-
         self.dirty = 1