Beispiel #1
0
 def __init__(self):
     os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (250, 60)
     pg.init()
     # 1000/650 good resolution
     self.size = (WIDTH, HEIGHT)
     self.screen = pg.display.set_mode(self.size)
     pg.display.set_caption('pokemon maybe')
     self.running = True
     self.keys = [False] * 500
     self.lastTime = 0
     self.delta = 0
     self.fps = 60
     self.frameTime = 1 / self.fps
     self.level = Level(30, 30)
     self.editor = LevelEditor(self.level.tileManager)
     self.editor.save('hello123', self.level.tile_id_map)
Beispiel #2
0
class Game:
    def __init__(self):
        os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (250, 60)
        pg.init()
        # 1000/650 good resolution
        self.size = (WIDTH, HEIGHT)
        self.screen = pg.display.set_mode(self.size)
        pg.display.set_caption('pokemon maybe')
        self.running = True
        self.keys = [False] * 500
        self.lastTime = 0
        self.delta = 0
        self.fps = 60
        self.frameTime = 1 / self.fps
        self.level = Level(30, 30)
        self.editor = LevelEditor(self.level.tileManager)
        self.editor.save('hello123', self.level.tile_id_map)

    def render(self):
        draw.rect(self.screen, (0, 0, 0), Rect(0, 0, self.size[0],
                                               self.size[1]))
        self.level.render(self.screen)
        self.editor.render(self.screen)
        pg.display.update()

    def update(self):
        self.level.update()
        self.editor.update(self.level)

    def timer(self):
        self.delta += time.clock() - self.lastTime
        if self.delta >= self.frameTime:
            self.delta = 0
            self.lastTime = time.clock()
            return True
        return False

    def loop(self):
        while self.running:
            for event in pg.event.get():
                if event.type == pg.QUIT:
                    self.running = False
                if event.type == pg.KEYDOWN:
                    self.keys[event.key] = True
                if event.type == pg.KEYUP:
                    self.keys[event.key] = False

            if self.timer():
                self.update()
                self.render()
            else:
                self.render()

        pg.quit()
        sys.exit()
Beispiel #3
0
def initialize():
    import LevelEditor
    if len(sys.argv) < 3:
        print "The level editor should be run as:"
        print "\t python main.py [definition file path] [map file path]"
        sys.exit(1)
    def_file = sys.argv[1]
    map_file = sys.argv[2]
    if not os.path.isfile(def_file):
        print '"' + def_file + '" is not a valid file path.'
        sys.exit(1200)
    create_map_file(map_file)
    pygame.init()
    pygame.display.set_caption('The Crazy Six - Level Editor')
    Globals.WIDTH = 1200
    Globals.HEIGHT = 750
    Globals.SCREEN = pygame.display.set_mode((Globals.WIDTH, Globals.HEIGHT))
    Globals.STATE = LevelEditor.LevelEditor(def_file, map_file)
    load_settings()
    init_events()
Beispiel #4
0
##      ** N/A
##      *** Code from last update deemed unnecessary
##
##      07/27/2011 - Zachary Cummings - ZJC
##      ** N/A
##      *** Added an array that will be accessed from MergeProject UI
##      *** and LevelEditorUIBase. It will store a list of any merges or
##      *** imports that occur so we can adjust the nameing conventions later.
##
##
##############################################################################

import LevelEditor
import sys, datetime
from Logger import *

sys.stdout = Logger('LevelEditor.log')
sys.stderr = sys.stdout

print '**************************************************'
print datetime.datetime.now()

base.le = LevelEditor.LevelEditor()
# You should define LevelEditor instance as
# base.le so it can be reached in global scope

## #ZJC - 07/29/2011: Code below determined not necessary
## base.le.prefixImportMerge = []# ZJC - 07/27/2011: When a library is imported, add prefix to the list

run()
from direct.showbase.ShowBaseGlobal import *
import LevelEditor
l = LevelEditor.LevelEditor()
Beispiel #6
0
import pygame as pg
import game
import const
import LevelEditor
import level_selection

if __name__ == '__main__':
    screen = const.screen
    framerate = 60
    g = game.Game(screen)
    le = LevelEditor.LevelEditor(screen)
    le_select = level_selection.LevelSelection(screen)
    while True:
        if const.mode == "playing":
            pg.key.set_repeat(10, 100)
            g.running = True
            g.load_level(const.level)
            g.main(framerate)
        elif const.mode == "editing":
            pg.key.set_repeat(100, 50)
            le.running = True
            le.load_level(const.level)
            le.main(framerate)
        elif const.mode == 'level_selection':
            pg.key.set_repeat(1, 10)
            le_select.running = True
            le_select.main(framerate)

        screen.fill((0, 0, 0))