-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Изменил героя, добавил немного реалистичного поведения и смертельные …
…блоки сделал чуть меньше
- Loading branch information
bvs
committed
Nov 29, 2013
1 parent
5be9174
commit a74c8f9
Showing
2 changed files
with
255 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
Oops, something went wrong.