Skip to content

Commit

Permalink
Изменил героя, добавил немного реалистичного поведения и смертельные …
Browse files Browse the repository at this point in the history
…блоки сделал чуть меньше
  • Loading branch information
bvs committed Nov 29, 2013
1 parent 5be9174 commit a74c8f9
Show file tree
Hide file tree
Showing 2 changed files with 255 additions and 230 deletions.
125 changes: 63 additions & 62 deletions blocks.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,64 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pygame import *
import os
import pyganim

PLATFORM_WIDTH = 32
PLATFORM_HEIGHT = 32
PLATFORM_COLOR = "#000000"
ICON_DIR = os.path.dirname(__file__) # Полный путь к каталогу с файлами

ANIMATION_BLOCKTELEPORT = [
('%s/blocks/portal2.png' % ICON_DIR),
('%s/blocks/portal1.png' % ICON_DIR)]

ANIMATION_PRINCESS = [
('%s/blocks/princess_l.png' % ICON_DIR),
('%s/blocks/princess_r.png' % ICON_DIR)]


class Platform(sprite.Sprite):
def __init__(self, x, y):
sprite.Sprite.__init__(self)
self.image = Surface((PLATFORM_WIDTH, PLATFORM_HEIGHT))
self.image.fill(Color(PLATFORM_COLOR))
self.image = image.load("%s/blocks/platform.png" % ICON_DIR)
self.image.set_colorkey(Color(PLATFORM_COLOR))
self.rect = Rect(x, y, PLATFORM_WIDTH, PLATFORM_HEIGHT)

class BlockDie(Platform):
def __init__(self, x, y):
Platform.__init__(self, x, y)
self.image = image.load("%s/blocks/dieBlock.png" % ICON_DIR)

class BlockTeleport(Platform):
def __init__(self, x, y, goX,goY):
Platform.__init__(self, x, y)
self.goX = goX # координаты назначения перемещения
self.goY = goY # координаты назначения перемещения
boltAnim = []
for anim in ANIMATION_BLOCKTELEPORT:
boltAnim.append((anim, 0.3))
self.boltAnim = pyganim.PygAnimation(boltAnim)
self.boltAnim.play()

def update(self):
self.image.fill(Color(PLATFORM_COLOR))
self.boltAnim.blit(self.image, (0, 0))


class Princess(Platform):
def __init__(self, x, y):
Platform.__init__(self, x,y)
boltAnim = []
for anim in ANIMATION_PRINCESS:
boltAnim.append((anim, 0.8))
self.boltAnim = pyganim.PygAnimation(boltAnim)
self.boltAnim.play()

def update(self):
self.image.fill(Color(PLATFORM_COLOR))
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pygame import *
import os
import pyganim

PLATFORM_WIDTH = 32
PLATFORM_HEIGHT = 32
PLATFORM_COLOR = "#000000"
ICON_DIR = os.path.dirname(__file__) # Полный путь к каталогу с файлами

ANIMATION_BLOCKTELEPORT = [
('%s/blocks/portal2.png' % ICON_DIR),
('%s/blocks/portal1.png' % ICON_DIR)]

ANIMATION_PRINCESS = [
('%s/blocks/princess_l.png' % ICON_DIR),
('%s/blocks/princess_r.png' % ICON_DIR)]


class Platform(sprite.Sprite):
def __init__(self, x, y):
sprite.Sprite.__init__(self)
self.image = Surface((PLATFORM_WIDTH, PLATFORM_HEIGHT))
self.image.fill(Color(PLATFORM_COLOR))
self.image = image.load("%s/blocks/platform.png" % ICON_DIR)
self.image.set_colorkey(Color(PLATFORM_COLOR))
self.rect = Rect(x, y, PLATFORM_WIDTH, PLATFORM_HEIGHT)

class BlockDie(Platform):
def __init__(self, x, y):
Platform.__init__(self, x, y)
self.image = image.load("%s/blocks/dieBlock.png" % ICON_DIR)
self.rect = Rect(x + PLATFORM_WIDTH / 4, y + PLATFORM_HEIGHT / 4, PLATFORM_WIDTH - PLATFORM_WIDTH / 2, PLATFORM_HEIGHT - PLATFORM_HEIGHT / 2)

class BlockTeleport(Platform):
def __init__(self, x, y, goX,goY):
Platform.__init__(self, x, y)
self.goX = goX # координаты назначения перемещения
self.goY = goY # координаты назначения перемещения
boltAnim = []
for anim in ANIMATION_BLOCKTELEPORT:
boltAnim.append((anim, 0.3))
self.boltAnim = pyganim.PygAnimation(boltAnim)
self.boltAnim.play()

def update(self):
self.image.fill(Color(PLATFORM_COLOR))
self.boltAnim.blit(self.image, (0, 0))


class Princess(Platform):
def __init__(self, x, y):
Platform.__init__(self, x,y)
boltAnim = []
for anim in ANIMATION_PRINCESS:
boltAnim.append((anim, 0.8))
self.boltAnim = pyganim.PygAnimation(boltAnim)
self.boltAnim.play()

def update(self):
self.image.fill(Color(PLATFORM_COLOR))
self.boltAnim.blit(self.image, (0, 0))
Loading

0 comments on commit a74c8f9

Please sign in to comment.