from Mind import Orientation, Existence import pygame pygame.init() screen = pygame.display.set_mode((400, 400)) pygame.display.set_caption('test, arrows for moving') gravity = Existence.gravity(0.1, 5) def down(self, cld, obj): self.move(0, -cld) self.fy = 0 collision = Existence.collider([None, down, None, None, None], "wall") player = Existence.mov_type(None, pygame.image.load("player.png"), logic=Existence.Subject + Existence.opt_size + gravity + collision) Map = Orientation.tiled_map('first_level', [{}, {}, {"player": player}]) p = Map.clone_obj("player") running = True while running: for event in pygame.event.get():
from Mind import Orientation, Existence import pygame pygame.init() screen = pygame.display.set_mode((400, 400)) pygame.display.set_caption('test, arrows for moving') player = Existence.mov_type(None, pygame.font.SysFont(None, 50).render('A', 1, (255, 0, 0)), logic=Existence.Subject) Map = Orientation.tiled_map('first_level', [{}, {}, {"player": player}]) p = Map.clone_obj("player") running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False elif event.type == pygame.KEYDOWN: if event.key == pygame.K_UP: p.move(0, -10) if event.key == pygame.K_RIGHT: p.move(10, 0) if event.key == pygame.K_DOWN: p.move(0, 10) if event.key == pygame.K_LEFT: p.move(-10, 0) screen.fill((255, 255, 255)) Map.blit()
from Mind import Orientation, Existence import pygame pygame.init() screen = pygame.display.set_mode((400, 400)) pygame.display.set_caption('test, arrows for moving') gravity = Existence.gravity(0.1, 5) def down(self, cld, obj): self.move(0, -cld) self.fy = 0 collision = Existence.collider([None, down, down, None, None], "wall") player = Existence.mov_type(None, pygame.font.SysFont(None, 50).render('A', 1, (255, 0, 0)), logic=Existence.Subject+gravity+collision) Map = Orientation.tiled_map('first_level', [{}, {}, {"player": player}]) p = Map.clone_obj("player") Clock = pygame.time.Clock() running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False elif event.type == pygame.KEYDOWN:
from Mind import Orientation, Existence import pygame pygame.init() screen = pygame.display.set_mode((400, 400)) pygame.display.set_caption('test, arrows for moving') gravity = Existence.gravity(0.1, 5) def down(self, cld, obj): self.move(0, -cld) self.fy = 0 collision = Existence.collider([None, down, None, None, None], "wall") player = Existence.mov_type(None, pygame.image.load("player.png"), logic=Existence.Subject+Existence.opt_size+gravity+collision) Map = Orientation.tiled_map('first_level', [{}, {}, {"player": player}]) p = Map.clone_obj("player") running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False elif event.type == pygame.KEYDOWN: if event.key == pygame.K_UP: p.jump()
from Mind import Orientation, Existence import pygame pygame.init() screen = pygame.display.set_mode((400, 400)) pygame.display.set_caption('test, arrows for moving') gravity = Existence.gravity(0.1, 5) player = Existence.mov_type(None, pygame.font.SysFont(None, 50).render('A', 1, (255, 0, 0)), logic=Existence.Subject+gravity) Map = Orientation.tiled_map('first_level', [{}, {}, {"player": player}]) p = Map.clone_obj("player") running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False elif event.type == pygame.KEYDOWN: if event.key == pygame.K_UP: p.jump() if event.key == pygame.K_RIGHT: p.move(10, 0) if event.key == pygame.K_DOWN: p.move(0, 10) if event.key == pygame.K_LEFT: p.move(-10, 0)
from Mind import Orientation, Existence import pygame pygame.init() screen = pygame.display.set_mode((400, 400)) pygame.display.set_caption('test, arrows for moving') gravity = Existence.gravity(0.1, 5) player = Existence.mov_type(None, pygame.font.SysFont(None, 50).render( 'A', 1, (255, 0, 0)), logic=Existence.Subject + gravity) Map = Orientation.tiled_map('first_level', [{}, {}, {"player": player}]) p = Map.clone_obj("player") running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False elif event.type == pygame.KEYDOWN: if event.key == pygame.K_UP: p.jump() if event.key == pygame.K_RIGHT: p.move(10, 0) if event.key == pygame.K_DOWN:
def __init__(self, game): self.game = game self.screen = self.game.screen self.keyboard = self.game.keyboard self.important = {"game": self.game, "keyboard": self.keyboard} pl_pics = [pygame.image.load("doc/art/player/s.png"), pygame.image.load("doc/art/player/m.png"), pygame.image.load("doc/art/player/b.png")] ch_pics = [pygame.image.load("doc/art/chev/s.png"), pygame.image.load("doc/art/chev/m.png"), pygame.image.load("doc/art/chev/b.png")] ent_pics = [pygame.image.load("doc/art/enter/s.png"), pygame.image.load("doc/art/enter/m.png"), pygame.image.load("doc/art/enter/b.png")] tab_pics = [pygame.image.load("doc/art/tab/s.png"), pygame.image.load("doc/art/tab/m.png"), pygame.image.load("doc/art/tab/b.png")] self.Map = Orientation.visual_map(self.WIDTH, self.HEIGHT, path="doc/art", decode=[{}, {}, { "player": Existence.mov_type(None, pl_pics, props=self.important, logic=Existence.Subject + entity.Entity + entity.Player), "chev": Existence.mov_type(None, ch_pics, props=self.important, logic=entity.Entity), "enter": Existence.mov_type(None, ent_pics, props=self.important, logic=entity.Entity), "tab": Existence.mov_type(None, tab_pics, props=self.important, logic=entity.Entity) }], tilesize=(10, 10), size_in_tiles=True) self.Map.create_tileset("map/wall.bmp", "wall") self.Map.create_layer("walls") self.rooms = [] self.Map.rooms = self.rooms self.bridges = [] self.bridgesA = [] self.bridgesB = [] self.bridgesC = [] self.fill = 0 for x in range(self.ROOMS): w = random.randint(5, 10) h = random.randint(5, 10) self.rooms.append(generate.Room(random.randrange(self.WIDTH - w + 1), random.randrange(self.HEIGHT - h + 1), w, h, self.Map)) if x: bridge = generate.Bridge(self.rooms[-2], self.rooms[-1], 3, self.Map) self.bridges.append(bridge) self.bridgesA.append(bridge) self.rooms[-2].connect(bridge) self.rooms[-1].connect(bridge) self.rooms_n = self.ROOMS self.A_n = self.ROOMS - 1 for x in range(self.B_BRIDGES): room1 = random.choice(self.rooms) room2 = random.choice(self.rooms) while room1 == room2: room2 = random.choice(self.rooms) bridge = generate.Bridge(room1, room2, 2, self.Map) self.bridges.append(bridge) self.bridgesB.append(bridge) room1.connect(bridge) room2.connect(bridge) self.B_n = self.B_BRIDGES for x in range(self.C_BRIDGES): room1 = random.choice(self.rooms) room2 = random.choice(self.rooms) while room1 == room2: room2 = random.choice(self.rooms) bridge = generate.Bridge(room1, room2, 1, self.Map) self.bridges.append(bridge) self.bridgesC.append(bridge) room1.connect(bridge) room2.connect(bridge) self.C_n = self.C_BRIDGES X, Y = random.choice(list(random.choice(self.rooms).tiles())) self.Map.create_objectgroup("live") o1 = self.Map.decode[2]["player"](X*10, Y*10, "player", Map=self.Map) self.Map.assign_object("live", o1) X, Y = random.choice(list(random.choice(self.rooms).tiles())) o = self.Map.decode[2]["chev"](X*10, Y*10, "chev", Map=self.Map) self.Map.assign_object("live", o) X, Y = random.choice(list(random.choice(self.rooms).tiles())) o = self.Map.decode[2]["enter"](X*10, Y*10, "enter", Map=self.Map) self.Map.assign_object("live", o) X, Y = random.choice(list(random.choice(self.rooms).tiles())) o = self.Map.decode[2]["tab"](X*10, Y*10, "tab", Map=self.Map) self.Map.assign_object("live", o) self.up_layer = self.Map.layers[0] self.background = pygame.Surface((self.WIDTH * 10, self.HEIGHT * 10)) self.background.fill((0, 0, 50)) self.Map.images[0].screen = self.background self.up_layer.set_pos(0, 0) self.up_layer.get_tiles = self.get_tiles self.up_layer.blit() self.Map.layers[0] = FakeLayer(0, 0, self.background, self.screen) o1.move(0, 0) for bridge in self.bridges: bridge.check() self.rooms[0].set_centre(self)