mruane 0 Junior Poster in Training

I am trying to use binascii to convert this:

town1 = """
++++++++++++++++++++++++++++++++++++
+-------------------------------------------------------------+
+----------H-----------H----------H---------H--------------+
+----------&---------------&---------------------------------+
+------------------------------------------------------------>+
+----------------@-------------------------------------------+
++++++++++++++++++++++++++++++++++++
"""

into the type of graphics used in PyMike's PixelMan 3, found at pygame.org. I looked at the document on python.org telling about binascii and a little bit about how to use it, but since it wasn't presented in a matter that was directed towards gaming, I found it hard to understand. If anyone could, give me a break down of how I would convert town1 as well as the text-mode representations of H (for a house), @ for the player, and & for an NPC into pixel based graphics using binascii. I have the source code for PixelMan 3, and am working with that, but do not understand much of PyMike's code, and it is not very documented (no comments.) here is the PixelMan 3 code, if somebody could insert comments telling me what each section does I would greatly appreciate it.

#! /usr/bin/env python

# Pixelman 3 - PyMike's Entry for Ludum Dare 11
# Copyright (C) 2007  PyMike
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# -------------------------------------
# Controls:
# -------------------------------------
# Move            -  Arrow Keys
# Jump            -  Space, Up, Z
# Back out        -  Escape
# Choose option   -  Enter/Return
# Scroll options  -  Up and Down Arrows
# Warp to level   -  1-5
# -------------------------------------

import pygame, sys, os
from pygame.locals import *

import binascii
from cStringIO import StringIO

level1 = """
++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++
+---++++++----+++++++-----++++++++++++++
------------------------------++++++++++
----------------------------------------
----------------------------------------
------oo--------------------------------
------oo-------------------------oo-----
-------------oooo----------------oo-----
------++-----oooo-----------------------
P---++++-------G-----------------++----+
++++++++--++++++++++--+------+--++++-+++
++++++++--++++++++++--+--oo--+++++++-+++
++++++++SS++++++++++SS+SS++SS+++++++S+++
"""

level2 = """
++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++---+++++++++++++++----++++
+++++++++++++++----------+++++++++++-----------+
-----++++---------------------+++++-------------
--------------------------------++--------------
------------------------------------------------
------------------------------------------------
------------------------------------------------
P-----------------------------------------------
+-------oo------------o-----G-----o--oo---------
+-------oo---------+--+-----------+--oo---------
++++--------++---+++--+o--------oo+--------++---
++++++SS++--++-+++++--++oooo--+++++--++++++++---
++++++++++SS++S+++++SS++++++SS+++++SS+++++++++++
"""

level3 = """
++++++++++++++++++++++++++++++++++++++++++++++++
+++-++++++++++++++++++++++++++++++++++++++++++++
++---++++++++++++++++++++++++++++++----+++++++++
+------++++------+++++++++++++++----------++++++
+-------------------+++++++++------------------+
+-----------------------------------G----------+
+----------------oooo--------------------------+
++P---oooo-------++++-------+++----------------+
++++++++++SSS++++++++++SSS++++++++ooo+SS++-----+
++++++++++++++++++++++++++++++++++++++++++----++
-----------------ooo--------------------------++
-----------------ooo--------------------------++
-----------------+++-----ooo---ooo------------++
-------------++++++++++SS+++SS++++--------ooo+++
-------++++SS++++++++++++++++++++++++SSS++++++++
---+++++++++++++++++++++++++++++++++++++++++++++
+o-++++++---------------------------------------
+o-++++-----------o-----------------------------
+o----------------+o--------G------------------o
+o----------------++o---------------++--------o+
+o-----ooo--oooo+++++o-----o---o----+++oooo--o++
++-----+++SS++++++++++++SSS+SSS+SSS++++++++SS+++
+++SS+++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++
"""

level4 = """
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
-P--------------------------------------------------------------------------------------------------
-+--------------------------------------------------------------------------------------------------
-+++----+o--------------------------------------------------oo--------------------------------------
---+++--+o--------------------------------------------------oo--------------------------------------
--------+ooo-----------o+-------------------------ooo-----------------------------------------------
--------++++--+--+--+--o+-------------G-----------ooo-------++-----------------------G--------------
----------------------oo+------------------+--------------+-----------------------------------------
----------------------+++--+------+---------------+++-----+---------------+--ooo--------------------
---------------------------++++---------+----+ooo------++++---------------+--+++--+--+--+--+oooooooo
------------------------------+------+-------++++----------------ooo---++++----------------+++++++++
-----------------------------------------------------------------+++--------------------------------
"""

level5 = """
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
--------------------------------------------------oooo++---------------------------------------
-----------------------------------------o--------oooo++---------------------------------------
-----------------------------------------o--------oooo++---------------------------------------
---------G----oo-----------------------o-o-o------ooo+++---------------------------------------
P-------------oo---oo-------------------ooo-------oo++++---------------------------------------
++-----------------oo--------------------o-------++++++----------------------------------------
++oooo--------++------------------------------++++++++-----------------------------------------
++++++--+--+--+++--++-------G------ooo++---+++++++++-------------------------------------------
--++++--------++++++++-----------oo++++--------------------------------------------------------
--------------------++-----------o++++---------------------------------------------------------
---------------------++----------++------------------------------------------------------------
----------------------+++--+--+--+--------------------------------------o---------------G------
-----------------------------------------------------------------------o+----------------------
-----------------------------------------------------------o---------oo++--------oo------oooooo
-----------------------------------------o-----o-----o--o--+--o-----o++++SS++----oo--++--++++++
-----------------------------------------+--o--+--o--+--+-----+-----+++++++++++-----+++SS++++++
--------------------------------------------+-----+--------------o--------+++++++SS++++++++++++
-----------------------------------------------------------------+-------------++++++--++++----
"""

player_anim0 = """
------+++++-----
----+++++++++---
---+++++++++++--
--+++++++++++++-
--++++--+++--++-
-+++++--+++--++-
+++++++++++++++-
++++++++++++++++
++++++++++++++++
++++++-+++++-+++
+++++++-----++++
+-++++++++++++++
--++++++++++++-+
---++++++++++---
---++-----++----
--+++++--+++++--
"""
player_anim1 = """
------+++++-----
----+++++++++---
---+++++++++++--
--+++++++++++++-
--++++--+++--++-
-+++++--+++--++-
+++++++++++++++-
++++++++++++++++
++++++++++++++++
++++++-+++++-+++
+++++++-----++++
+-++++++++++++++
--++++++++++++-+
---++++++++++---
--+++++---++----
---------+++++--
"""
player_anim2 = """
------+++++-----
----+++++++++---
---+++++++++++--
--+++++++++++++-
--++++--+++--++-
-+++++--+++--++-
+++++++++++++++-
++++++++++++++++
++++++++++++++++
++++++-+++++-+++
+++++++-----++++
+-++++++++++++++
--++++++++++++-+
---++++++++++---
---++----+++++--
--+++++---------
"""
spikes_img = """
--+---+---+---+-
--+---+---+---+-
--+---+---+---+-
--+---+---+---+-
-+++-+++-+++-+++
-+++-+++-+++-+++
-+++-+++-+++-+++
-+++-+++-+++-+++
-+++-+++-+++-+++
-+++-+++-+++-+++
-+++-+++-+++-+++
-+++-+++-+++-+++
++++++++++++++++
++++++++++++++++
++++++++++++++++
++++++++++++++++
"""

ghostie_img = """
------+++++-----
----+++++++++---
---+++++++++++--
--+++++++++++++-
-+++++--+++--++-
+++++++--+--++++
++++++++-+-+++++
++++++++++++++++
-++++-+++++++-++
--++++--+++--++-
---+++++---++++-
----++++++++++--
-----++++++++---
-------++++-----
"""

jump_sound = 'T2dnUwACAAAAAAAAAAAyJQAAAAAAAISM3SsBHgF2b3JiaXMAAAAAAUSsAAAAAAAAAHcBAAAAAAC4AU9nZ1MAAAAAAAAAAAAAMiUAAAEAAABGnEibEC3//////////////////8kDdm9yYmlzHQAAAFhpcGguT3JnIGxpYlZvcmJpcyBJIDIwMDQwNjI5AAAAAAEFdm9yYmlzKUJDVgEACAAAADFMIMWA0JBVAAAQAABgJCkOk2ZJKaWUoSh5mJRISSmllMUwiZiUicUYY4wxxhhjjDHGGGOMIDRkFQAABACAKAmOo+ZJas45ZxgnjnKgOWlOOKcgB4pR4DkJwvUmY26mtKZrbs4pJQgNWQUAAAIAQEghhRRSSCGFFGKIIYYYYoghhxxyyCGnnHIKKqigggoyyCCDTD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lTwlqpnolfg5/2+B0gP/wWxjfQA/Kh8s06UKADcgFsWX/A8Qw9Iomc2JbOCwyTrXcgLlB9WV6SxdUCvG7HZIA62VF/YRyADJPdIPgWaoZKsdDUD6SwF1wpf0jZ7Q9BJAjI4/RMGogbNr8xF1rr7VC0kg6hrQ9MDmfy+AqV74X0dULrjxBsG7e3wOuBOoJfssJWSu0QW6FEiU811QSUPgEcCX/IeL53XWiCf+LM8MIGssUaTdTzejspKy6HeCUSXzO53eGThZPZqn2wfUUB8CMCU7LnGA6QNB9un3hZA/wAd0+expDQhPB4H/O+wKQcu7PNPMsaty+I+Vz4/Gjoy9DbY520TMuP2mlFlVhFykVWg3oB\n'


def load_sound(string):
    sound_string = binascii.a2b_base64(string)
    f = StringIO(sound_string)
    sound = pygame.mixer.Sound(f)
    sound.set_volume(0.5)
    return sound

LEVELS = [level1, level2, level3, level4, level5]
ONFULLSCREEN = 0

def imagetostring(filename):
    img = pygame.image.load(filename)
    new = ""
    for y in range(img.get_height()):
        for x in range(img.get_width()):
            pixel = img.get_at((x, y))
            if pixel == (0, 0, 0, 255):
                new += "+"
            elif pixel == (255, 255, 0, 255):
                new += "o"
            elif pixel == (255, 0, 0, 255):
                new += "P"
            elif pixel == (0, 0, 255, 255):
                new += "S"
            elif pixel == (0, 255, 0, 255):
                new += "G"
            else:
                new += "-"
        new += "\n"
    return new

def image(color, shape="block", pixelstring=None):
    img = pygame.Surface((16, 16))
    if shape == "block":
        img.fill(Color(color))
    if shape == "circle":
        pygame.draw.ellipse(img, Color(color), (1, 1, 14, 14))
        img.set_colorkey((0, 0, 0), RLEACCEL)
    if pixelstring:
        img.set_colorkey((0, 0, 0), RLEACCEL)
        x=0
        y=-1
        for line in pixelstring.split("\n"):
            for char in line:
                if char == "+":
                    img.fill(Color(color), (x, y, 1, 1))
                x += 1
            y += 1
            x = 0
    return img

def speed_to_side(dx,dy):
    if abs(dx) > abs(dy): dy = 0
    else: dx = 0
    if dy < 0: return 0
    elif dx > 0: return 1
    elif dy > 0: return 2
    elif dx < 0: return 3
    else: return 0, 0

class Sprite(pygame.sprite.Sprite):

    def __init__(self, img, pos):
        pygame.sprite.Sprite.__init__(self, self.containers)
        self.image = img
        self.rect = self.image.get_rect(topleft = pos)
        self.r = Rect(self.rect[0]*100, self.rect[1]*100, self.rect[2]*100, self.rect[3]*100)
        self.collision_groups = []

    def set_pos(self, x, y):
        self.r.left = x*100
        self.r.top = y*100

    def update_rect(self):
        self.rect.top = self.r.top/100
        self.rect.left = self.r.left/100

    def add_collision_group(self, group):
        self.collision_groups.append(group)

    def move(self, dx, dy, collide=True):
        if collide:
            if dx!=0:
                dx, dummy = self.__move(dx*100, 0)
            if dy!=0:
                dummy, dy = self.__move(0, dy*100)
        else:
            self.r.move_ip(dx*100, dy*100)
        return dx, dy

    def __move(self, dx, dy):
        oldr = self.r
        self.r.move_ip(dx, dy)
        side = speed_to_side(dx, dy)

        for group in self.collision_groups:
            for spr in group:
                if spr.r.colliderect(self.r):
                    if side == 0:
                        self.r.top = spr.r.bottom
                    if side == 1:
                        self.r.right = spr.r.left
                    if side == 2:
                        self.jumping = False
                        self.jump_speed = 0
                        self.r.bottom = spr.r.top
                    if side == 3:
                        self.r.left = spr.r.right
        return self.r.left-oldr.left,self.r.top-oldr.top


class Player(Sprite):

    def __init__(self, pos):

        Sprite.__init__(self, image("#010101", pixelstring=player_anim0, shape=None), pos)
        self.images = [image("#010101", pixelstring=player_anim2, shape=None),
                       image("#010101", pixelstring=player_anim1, shape=None),
                       image("#010101", pixelstring=player_anim0, shape=None)]
        self.rightimgs = self.images
        self.leftimgs = []
        for i in self.images:
            self.leftimgs.append(pygame.transform.flip(i, 1, 0))
        self.jump_speed = 0
        self.fall_speed = 0.4
        self.jumping = False

        self.speed = 0
        self.accel_speed = 0.25
        self.max_speed = 3.5
        self.facing = 1
        self.frame = 0
        self.keys = [K_SPACE, K_UP, K_z]
        self.jump_sound = load_sound(jump_sound)

    def jump(self):
        if not self.jumping:
            self.jump_sound.play()
            self.jumping = True
            self.jump_speed = -6

    def update(self):
        if self.jump_speed > 1:
            self.jumping = True
        moving = 0
        key = pygame.key.get_pressed()
        if self.rect.left < 0:
            self.set_pos(0, self.rect.top)
        if key[K_LEFT]:
            self.facing = -1
            moving = -1
            if self.speed > -self.max_speed:
                self.speed -= self.accel_speed
        elif key[K_RIGHT]:
            self.facing = 1
            moving = 1
            if self.speed < self.max_speed:
                self.speed += self.accel_speed
        else:
            if self.speed > 0:
                self.speed -= self.accel_speed
            if self.speed < 0:
                self.speed += self.accel_speed
        if self.jump_speed < 5:
            if key[self.keys[0]] or key[self.keys[1]] or key[self.keys[2]]:
                self.jump_speed += self.fall_speed
            else:
                self.jump_speed += self.fall_speed+0.3
        self.move(self.speed, self.jump_speed)

        self.frame += 1
        if self.facing > 0:
            self.image = self.rightimgs[2]
        if self.facing < 0:
            self.image = self.leftimgs[2]
        if moving > 0:
            self.image = self.rightimgs[self.frame/4%2]
        if moving < 0:
            self.image = self.leftimgs[self.frame/4%2]

class Ghostie(Sprite):

    def __init__(self, pos):

        Sprite.__init__(self, image("#010101", shape=None, pixelstring=ghostie_img), pos)

        self.leftimg = pygame.transform.flip(image("#010101", shape=None, pixelstring=ghostie_img), 1, 0)
        self.rightimg = image("#010101", shape=None, pixelstring=ghostie_img)

        self.frame = 0
        self.speed = 1
        self.orgcenter = self.rect.centerx
        self.y = self.rect.centery

    def update(self):

        if self.speed > 0:
            self.image = self.rightimg
        if self.speed < 0:
            self.image = self.leftimg
            
        self.move(self.speed, 0)
        self.frame += 1

        if self.frame <= 12:
            self.move(0, 0.25)
        else:
            self.move(0, -0.25)
        self.rect.centery = self.y
        if self.frame >= 24:
            self.frame = 0
        if self.rect.right >= self.orgcenter + 50:
            self.speed = -1
        if self.rect.left <= self.orgcenter - 50:
            self.speed = 1

class Block(Sprite):

    def __init__(self, pos):
        Sprite.__init__(self, image("#890000"), pos)

class Spikes(Sprite):

    def __init__(self, pos):
        Sprite.__init__(self, image("#010101", shape=None, pixelstring=spikes_img), pos)

class Coin(Sprite):

    def __init__(self, pos):
        Sprite.__init__(self, image("#ffff00", "circle"), pos)
        self.images = [image("#ffff00", "circle"),
                       image("#f4f400", "circle"),
                       image("#e9e900", "circle"),
                       image("#f4f400", "circle")]
        self.frame = 0
        self.alpha = 255
        self.dead = False
        self.coin_sound = load_sound(coin_sound)
    def kill(self):
        self.dead = True
    def update(self):
        self.frame += 1
        self.image = self.images[self.frame/4%4]
        if self.dead:
            self.alpha -= 75
        if self.alpha <= 0:
            self.coin_sound.play()
            pygame.sprite.Sprite.kill(self)
        self.image.set_alpha(self.alpha)

class Camera(object):

    def __init__(self, screen, sprite_to_center_on, world_size):
        self.sprite = sprite_to_center_on
        self.rect = screen.get_rect()
        self.world_rect = Rect(0, 0, world_size[0], world_size[1])

    def update(self):
        if self.sprite.rect.centerx > self.rect.centerx + 25:
            self.rect.centerx = self.sprite.rect.centerx - 25
        if self.sprite.rect.centerx < self.rect.centerx - 25:
            self.rect.centerx = self.sprite.rect.centerx + 25
        if self.sprite.rect.centery > self.rect.centery + 25:
            self.rect.centery = self.sprite.rect.centery - 25
        if self.sprite.rect.centery < self.rect.centery - 25:
            self.rect.centery = self.sprite.rect.centery + 25
        self.rect.clamp_ip(self.world_rect)
        
    def draw_group(self, surface, group):
        for sprite in group.sprites():
            if sprite.rect.left <= self.rect.right and sprite.rect.right >= self.rect.left:
                if sprite.rect.top <= self.rect.bottom and sprite.rect.bottom >= self.rect.top:
                    surface.blit(sprite.image, self.sprite_rect(sprite))
            
    def update_group(self, group):
        for sprite in group.sprites():
            if sprite.rect.left <= self.rect.right and sprite.rect.right >= self.rect.left:
                if sprite.rect.top <= self.rect.bottom and sprite.rect.bottom >= self.rect.top:
                    sprite.update()
                    sprite.update_rect()

    def sprite_rect(self, actor):
        return pygame.Rect(actor.rect.x - self.rect.x, actor.rect.y - self.rect.y, actor.rect.w, actor.rect.h)

class Level:

    def __init__(self, level=level1):
        self.level = level
        self.x = 0
        self.y = -16
        for line in self.level.split("\n"):
            for char in line:
                if char == "+":
                    Block((self.x, self.y))
                if char == "P":
                    self.player = Player((self.x, self.y))
                if char == "o":
                    Coin((self.x, self.y))
                if char == "S":
                    Spikes((self.x, self.y))
                if char == "G":
                    Ghostie((self.x, self.y))
                self.x += 16
            self.y += 16
            self.x = 0

    def get_size(self):
        lines = self.level.split("\n")
        line = lines[1]
        width = (len(line))*16
        height = (len(lines)-2)*16
        return [width, height]

def next_level(levelnum):
    try:
        levelnum += 1
        lvl = LEVELS[levelnum-1]
    except:
        return None
    level = Level(lvl)
    return level, levelnum


def Menu(screen):

    screen = screen
    font = pygame.font.SysFont("courier", 32, bold=True)
    font2 = pygame.font.SysFont("courier", 20, bold=True)
    font3 = pygame.font.SysFont("courier", 12, bold=True)

    player = image("#010101", shape=None, pixelstring=player_anim0)
    player = pygame.transform.scale(player, [player.get_width()*6, player.get_height()*6])
    cursor = image("#010101", shape="circle")
    cursorpos = 150
    option = 1
    sound = load_sound(blip_sound)
    clock = pygame.time.Clock()
    global ONFULLSCREEN

    while 1:

        clock.tick(30)
        for e in pygame.event.get():
            if e.type == QUIT:
                pygame.quit()
                sys.exit()
            if e.type == KEYDOWN:
                if e.key == K_ESCAPE:
                    pygame.quit()
                    sys.exit()
                if e.key == K_DOWN:
                    sound.play()
                    option = 2
                if e.key == K_UP:
                    sound.play()
                    option = 1
                if e.key == K_RETURN:
                    sound.play()
                    if option == 1:
                        Intro(screen)
                        game = Game(screen)
                        game.main_loop()
                    if option == 2:
                        pygame.quit()
                        return
                if e.key == K_f:
                    ONFULLSCREEN ^= 1
                    if ONFULLSCREEN:
                        pygame.display.set_mode((320, 240), FULLSCREEN)
                    else:
                        pygame.display.set_mode((320, 240))

        if option == 1:
            cursorpos = 150
        else:
            cursorpos = 170

        screen.fill(Color("#c1c1c1"))
        pygame.draw.rect(screen, Color("#890000"), (55, 25, 210, 45), 5)
        pygame.draw.rect(screen, Color("#890000"), (0, 227, 320, 32))
        ren = font.render("Pixelman 3", 1, Color("#000000"))
        screen.blit(ren, (161-ren.get_width()/2, 31))
        ren = font.render("Pixelman 3", 1, Color("#ffffff"))
        screen.blit(ren, (160-ren.get_width()/2, 30))

        ren = font3.render("Copyright (C) 2008", 1, Color("#000000"))
        screen.blit(ren, (160-ren.get_width()/2, 85))
        ren = font3.render("Created by PyMike for LD XI", 1, Color("#000000"))
        screen.blit(ren, (160-ren.get_width()/2, 100))

        ren = font2.render("New Game", 1, Color("#000000"))
        screen.blit(ren, (140, 145))
        ren = font2.render("Quit Game", 1, Color("#000000"))
        screen.blit(ren, (140, 165))
        screen.blit(player, (10, 132))
        screen.blit(cursor, (120, cursorpos))
        pygame.display.flip()


def Intro(screen):

    screen = screen
    font = pygame.font.SysFont("courier", 32, bold=True)
    font2 = pygame.font.SysFont("courier", 16, bold=True)
    font3 = pygame.font.SysFont("courier", 12, bold=True)

    player = image("#010101", shape=None, pixelstring=player_anim0)
    player = pygame.transform.scale(player, [player.get_width()*6, player.get_height()*6])
    cursor = image("#010101", shape="circle")
    option = 1
    sound = load_sound(blip_sound)
    clock = pygame.time.Clock()
    ypos = 240
    global ONFULLSCREEN
    text = ["Oh noes! Pixelman is not",
            "drawing pixels fast enough!",
            "Help Pixelman speed through",
            "the levels before his owner",
            "discards the computer monitor",
            "for being a minimalist!"]

    while 1:

        clock.tick(60)
        for e in pygame.event.get():
            if e.type == QUIT:
                pygame.quit()
                sys.exit()
            if e.type == KEYDOWN:
                if e.key == K_ESCAPE:
                    return
                if e.key == K_RETURN:
                    sound.play()
                    return
                if e.key == K_f:
                    ONFULLSCREEN ^= 1
                    if ONFULLSCREEN:
                        pygame.display.set_mode((320, 240), FULLSCREEN)
                    else:
                        pygame.display.set_mode((320, 240))

        screen.fill(Color("#c1c1c1"))
        ren = font.render("Prologue", 1, Color("#000000"))
        screen.blit(ren, (160-ren.get_width()/2, 20))
        ypos = 75
        for line in text:
            ren = font2.render(line, 1, (0, 0, 0))
            screen.blit(ren, (160-ren.get_width()/2, ypos))
            ypos += font2.get_height()
        ren = font3.render("Press Enter To Start", 1, Color("#000000"))
        screen.blit(ren, (160-ren.get_width()/2, 210))
        pygame.display.flip()

def Outro(screen, final_score=0):

    screen = screen
    font = pygame.font.SysFont("courier", 32, bold=True)
    font2 = pygame.font.SysFont("courier", 16, bold=True)
    font3 = pygame.font.SysFont("courier", 12, bold=True)

    player = image("#010101", shape=None, pixelstring=player_anim0)
    player = pygame.transform.scale(player, [player.get_width()*6, player.get_height()*6])
    cursor = image("#010101", shape="circle")
    option = 1
    sound = load_sound(blip_sound)
    clock = pygame.time.Clock()
    ypos = 240
    global ONFULLSCREEN
    text = ["Hurray! You saved Pixelman",
            "from being scrapped!",
            "Nice work!",
            "",
            "Final Score:",
            "%09d" % final_score]

    while 1:

        clock.tick(60)
        for e in pygame.event.get():
            if e.type == QUIT:
                pygame.quit()
                sys.exit()
            if e.type == KEYDOWN:
                if e.key == K_ESCAPE:
                    return
                if e.key == K_RETURN:
                    sound.play()
                    return
                if e.key == K_f:
                    ONFULLSCREEN ^= 1
                    if ONFULLSCREEN:
                        pygame.display.set_mode((320, 240), FULLSCREEN)
                    else:
                        pygame.display.set_mode((320, 240))

        screen.fill(Color("#c1c1c1"))
        ren = font.render("You won!", 1, Color("#000000"))
        screen.blit(ren, (160-ren.get_width()/2, 20))
        ypos = 75
        for line in text:
            ren = font2.render(line, 1, (0, 0, 0))
            screen.blit(ren, (160-ren.get_width()/2, ypos))
            ypos += font2.get_height()
        ren = font3.render("Press Enter to Exit to Title Screen", 1, Color("#000000"))
        screen.blit(ren, (160-ren.get_width()/2, 210))
        pygame.display.flip()


class Game:

    def __init__(self, screen):

        self.screen = screen
        self.all = pygame.sprite.RenderUpdates()
        self.blocks = pygame.sprite.Group()
        self.coins = pygame.sprite.Group()
        self.spikes = pygame.sprite.Group()
        self.ghosties = pygame.sprite.Group()

        Player.containers = self.all
        Block.containers = self.all, self.blocks
        Coin.containers = self.all, self.coins
        Spikes.containers = self.all, self.spikes
        Ghostie.containers = self.all, self.ghosties

        self.clock = pygame.time.Clock()
        self.level = Level()
        self.player = self.level.player
        self.player.add_collision_group(self.blocks)
        self.camera = Camera(self.screen, self.player, self.level.get_size())
        self.lvl = 1
        self.font = pygame.font.SysFont("courier", 12, bold=True)
        self.font2 = pygame.font.SysFont("courier", 32, bold=True)
        self.score = 0
        self.lives = 5
        self.done = False
        self.coin_sound = load_sound(coin_sound)
        self.highscore = 0
        self.paused = False
        self.time = 0
        self.final_score = 0

    def draw(self):
        self.screen.fill(Color("#c1c1c1"))
        self.camera.draw_group(self.screen, self.all)
        ren1 = self.font.render("FPS: %d/60" % self.clock.get_fps(), 1, Color("#000000"))
        ren2 = self.font.render("FPS: %d/60" % self.clock.get_fps(), 1, Color("#ffffff"))
        self.screen.blit(ren1, (6, 221))
        self.screen.blit(ren2, (5, 220))
        ren1 = self.font.render("Score: %d" % self.score, 1, Color("#000000"))
        ren2 = self.font.render("Score: %d" % self.score, 1, Color("#ffffff"))
        self.screen.blit(ren1, (11, 6))
        self.screen.blit(ren2, (10, 5))
        ren1 = self.font.render("Level: %d" % self.lvl, 1, Color("#000000"))
        ren2 = self.font.render("Level: %d" % self.lvl, 1, Color("#ffffff"))
        self.screen.blit(ren1, (246, 6))
        self.screen.blit(ren2, (245, 5))
        ren1 = self.font.render("Lives x%d" % self.lives, 1, Color("#000000"))
        ren2 = self.font.render("Lives x%d" % self.lives, 1, Color("#ffffff"))
        self.screen.blit(ren1, (131, 6))
        self.screen.blit(ren2, (130, 5))
        ren1 = self.font.render("Time: %d" % self.time, 1, Color("#000000"))
        ren2 = self.font.render("Time: %d" % self.time, 1, Color("#ffffff"))
        self.screen.blit(ren1, (11, 21))
        self.screen.blit(ren2, (10, 20))
        self.final_score = (self.score - int(self.time))*self.lives
        if self.lives <= 0 and not self.player.alive() and not self.done:
            ren1 = self.font2.render("Game Over!", 1, Color("#000000"))
            ren2 = self.font2.render("Game Over!", 1, Color("#ffffff"))
            self.screen.blit(ren1, (160-ren1.get_width()/2 + 2, 120-ren1.get_height()/2 + 2))
            self.screen.blit(ren2, (160-ren2.get_width()/2, 120-ren2.get_height()/2))                

    def hit_screen(self):
        self.draw()
        ren1 = self.font2.render("You Crashed!", 1, Color("#000000"))
        ren2 = self.font2.render("You Crashed!", 1, Color("#ffffff"))
        self.screen.blit(ren1, (160-ren1.get_width()/2 + 2, 120-ren1.get_height()/2 + 2))
        self.screen.blit(ren2, (160-ren2.get_width()/2, 120-ren2.get_height()/2))                
        pygame.display.flip()
        pygame.time.wait(1000)

    def main_loop(self):

        global ONFULLSCREEN
        while 1:

            self.clock.tick(60)
            if self.player.alive():
                self.time += 0.015
            for e in pygame.event.get():
                if e.type == QUIT:
                    pygame.quit()
                    sys.exit()
                if e.type == KEYDOWN:
                    if e.key == K_ESCAPE:
                        return
                    if e.key in self.player.keys:
                        self.player.jump()
                    if e.key == K_1:
                        self.lvl = 0
                        self.next_level()
                    if e.key == K_2:
                        self.lvl = 1
                        self.next_level()
                    if e.key == K_3:
                        self.lvl = 2
                        self.next_level()
                    if e.key == K_4:
                        self.lvl = 3
                        self.next_level()
                    if e.key == K_5:
                        self.lvl = 4
                        self.next_level()
                    if e.key == K_p:
                        self.paused ^= 1
                    if e.key == K_f:
                        ONFULLSCREEN ^= 1
                        if ONFULLSCREEN:
                            pygame.display.set_mode((320, 240), FULLSCREEN)
                        else:
                            pygame.display.set_mode((320, 240))
                        pygame.time.wait(1500)
            while self.paused:
                self.clock.tick(20)
                for e in pygame.event.get():
                    if e.type == QUIT:
                        pygame.quit()
                        return
                    if e.type == KEYDOWN:
                        if e.key == K_ESCAPE:
                            return
                        if e.key == K_p:
                            self.paused ^= 1

            for sprite in self.all.sprites():
                if isinstance(sprite, Coin):
                    sprite.update()
                if sprite.rect.left <= self.camera.rect.right and sprite.rect.right >= self.camera.rect.left:
                    if sprite.rect.top <= self.camera.rect.bottom and sprite.rect.bottom >= self.camera.rect.top:
                        if not isinstance(sprite, Coin):
                            sprite.update()
                        sprite.update_rect()
                        if isinstance(sprite, Coin):
                            if self.player.rect.colliderect(sprite.rect) and not sprite.dead:
                                sprite.kill()
                                self.score += 25
                        if isinstance(sprite, Spikes):
                            if self.player.rect.colliderect(sprite.rect):
                                self.player.kill()
                        if isinstance(sprite, Ghostie):
                            if self.player.rect.colliderect(sprite.rect):
                                self.player.kill()

            if self.score > self.highscore:
                self.highscore = self.score
            if not self.player.alive() and self.lives > 0 and not self.done:
                self.hit_screen()
                self.score = 0
                self.lvl -= 1
                self.lives -= 1
                self.next_level()
            if self.player.rect.right >= self.level.get_size()[0] and not self.done:
                self.player.kill()
                self.next_level()
            if self.player.rect.top >= self.level.get_size()[1]:
                self.player.kill()
            if self.done:
                Outro(self.screen, self.final_score)
                return
            self.camera.update()
            self.draw()
            pygame.display.flip()

    def next_level(self):
        lvl = next_level(self.lvl)
        if lvl == None:
            self.done = True
        else:
            self.clear_sprites()
            self.level, self.lvl = next_level(self.lvl)
            self.player = self.level.player
            self.player.add_collision_group(self.blocks)
            self.camera = Camera(self.screen, self.player, self.level.get_size())            

    def clear_sprites(self):
        for sprite in self.all.sprites():
            pygame.sprite.Sprite.kill(sprite)

def main():
    if sys.platform in ("win32", "win64"):
        os.environ["SDL_VIDEO_CENTERED"] = "1"
    pygame.init()
    pygame.display.set_caption("Pixelman 3 - PyMike LD48")
    pygame.mouse.set_visible(0)
    screen = pygame.display.set_mode((320, 240))
    Menu(screen)

if __name__ == "__main__":
    main()

thanks ahead of time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.