Source

Fat x Fast / FatxFast / tilemap / maze / mazecell.py

Full commit

# This file is part of FatxFast.
#
#    FatxFast is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    FatxFast 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 General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with FatxFast.  If not, see <http://www.gnu.org/licenses/>.

# Versioning based on: 
# http://en.wikipedia.org/wiki/Versioning#Designating_development_stage
__author__ = "dryatu (c) 2013"
__version__ = "1.2.5"

import pygame
from FatxFast.objects.entity import GameEntity
from FatxFast.tilemap.editor import tile


# Cell type IDs. Used to identify cell types while generating
CELL_ID = 50
STARTCELL_ID = 51
ENDCELL_ID = 52
WEAVE_ID = 53

class MazeStruct(GameEntity):
    def __init__(self, x=0, y=0, **kwargs):
        self.x = x
        self.y = y
        super(MazeStruct, self).__init__(x=x*tile.TILEWIDTH, 
            y=y*tile.TILEHEIGHT, **kwargs)

class MazeCell(MazeStruct):
    def __init__(self, x=0, y=0, **kwargs):
        super(MazeCell, self).__init__(x=x, y=y, entity_id=CELL_ID, **kwargs)
        self.solution = True
        self.visited = False

class RectMazeCell(MazeCell):
    
    """This is a primary maze unit.
    
    Attributes
    column - tile x coordinate in maze
    row - tile y coordinate in maze
    rect - real coordinate position, coordinate size
    solution - whether cell is part of the solution route
    visited - whether maze generation visited the cell
    special - 
        "weave" - cell under which weaving has occured
        "start" - indicates it's a starting cell
        "end" - indicates it's an end cell
    walls - container of wall values
    image - actual image of the tile

    """
    def __init__(self, x=0, y=0, column=0, row=0, **kwargs):
        super(RectMazeCell, self).__init__(x=x, y=y, 
            **kwargs)
        self.column = column
        self.row = row