import os current_path = os.path.dirname(os.path.realpath(__file__)) # import from one level up sys.path.append(os.path.split(current_path)[0]) import pygame from rapidpg import ImageLoader from rapidpg.levelmgr.collision import LevelManager from rapidpg import Player pygame.init() a = pygame.display.set_mode((800, 600)) loader = ImageLoader(current_path) surfs = loader.load_frames(["geometry"], 4, True) # load player images geometry = Player(surfs, 50) # make player manager = LevelManager(current_path, geometry) manager.load_level(["collision_level"]) # load level manager.next_level() clock = pygame.time.Clock() movement_dict = {"up": False, "down": False, "left": False, "right": False} while True: movement_dict['up'] = False for e in pygame.event.get(): if e.type == pygame.QUIT: pygame.quit() raise SystemExit elif e.type == pygame.KEYDOWN: if e.key == pygame.K_UP: movement_dict['up'] = True if e.key == pygame.K_DOWN:
This demo is made to showcase how the collision level manager interprets the level into rectangles. """ import sys import os from random import randrange current_path = os.path.dirname(os.path.realpath(__file__)) # import from one level up sys.path.append(os.path.split(current_path)[0]) import pygame from rapidpg.levelmgr.collision import LevelManager pygame.init() a = pygame.display.set_mode((800, 600)) mgr = LevelManager(current_path, None) mgr.load_level(["collision_level"]) mgr.next_level() for rect in mgr.current_level.interpreted: color = (randrange(0, 256), randrange(0, 256), randrange(0, 256)) a.fill(pygame.Color(color[0], color[1], color[2]), rect) color = (randrange(0, 256), randrange(0, 256), randrange(0, 256)) a.fill(pygame.Color(color[0], color[1], color[2]), mgr.current_level.exit) pygame.display.update() while True: for e in pygame.event.get(): if e.type == pygame.QUIT: pygame.quit() raise SystemExit