From: Skullheadx <704277@pdsb.net> Date: Tue, 12 Jul 2022 18:44:38 +0000 (-0400) Subject: FIXED crash when using multiple layers X-Git-Url: http://git.skullheadx.com/links.html?a=commitdiff_plain;h=5dadc01fe055da2701f73e404d483d294895b465;p=Pygame-Jam.git FIXED crash when using multiple layers --- diff --git a/Assets/skeleton/skeleton_king_hearts.gif b/Assets/skeleton/skeleton_king_hearts.gif new file mode 100644 index 0000000..43193f5 Binary files /dev/null and b/Assets/skeleton/skeleton_king_hearts.gif differ diff --git a/Assets/skeleton/skeleton_king_idle.gif b/Assets/skeleton/skeleton_king_idle.gif new file mode 100644 index 0000000..40fa436 Binary files /dev/null and b/Assets/skeleton/skeleton_king_idle.gif differ diff --git a/Assets/skeleton/skeleton_king_summon.gif b/Assets/skeleton/skeleton_king_summon.gif new file mode 100644 index 0000000..adaacb8 Binary files /dev/null and b/Assets/skeleton/skeleton_king_summon.gif differ diff --git a/Assets/world/blocks/BOTTOMGRASS.png b/Assets/world/blocks/BOTTOMGRASS.png new file mode 100644 index 0000000..9274726 Binary files /dev/null and b/Assets/world/blocks/BOTTOMGRASS.png differ diff --git a/Assets/world/blocks/BOTTOMSIDEDIRT.png b/Assets/world/blocks/BOTTOMSIDEDIRT.png new file mode 100644 index 0000000..e25990f Binary files /dev/null and b/Assets/world/blocks/BOTTOMSIDEDIRT.png differ diff --git a/Assets/world/blocks/LEFTCORNERDIRT.png b/Assets/world/blocks/LEFTCORNERDIRT.png new file mode 100644 index 0000000..4a72b20 Binary files /dev/null and b/Assets/world/blocks/LEFTCORNERDIRT.png differ diff --git a/Assets/world/blocks/LEFTCORNERGRASS.png b/Assets/world/blocks/LEFTCORNERGRASS.png new file mode 100644 index 0000000..56c8fb2 Binary files /dev/null and b/Assets/world/blocks/LEFTCORNERGRASS.png differ diff --git a/Assets/world/blocks/LEFTGRASS.png b/Assets/world/blocks/LEFTGRASS.png new file mode 100644 index 0000000..fcc166b Binary files /dev/null and b/Assets/world/blocks/LEFTGRASS.png differ diff --git a/Assets/world/blocks/LEFTSIDEDIRT.png b/Assets/world/blocks/LEFTSIDEDIRT.png new file mode 100644 index 0000000..21ccfb6 Binary files /dev/null and b/Assets/world/blocks/LEFTSIDEDIRT.png differ diff --git a/Assets/world/blocks/LEFTSTONEDIRTCORNER.png b/Assets/world/blocks/LEFTSTONEDIRTCORNER.png new file mode 100644 index 0000000..c2ff32d Binary files /dev/null and b/Assets/world/blocks/LEFTSTONEDIRTCORNER.png differ diff --git a/Assets/world/blocks/RIGHTGRASS.png b/Assets/world/blocks/RIGHTGRASS.png new file mode 100644 index 0000000..799002c Binary files /dev/null and b/Assets/world/blocks/RIGHTGRASS.png differ diff --git a/Assets/world/decor/ROCK.png b/Assets/world/decor/ROCK.png new file mode 100644 index 0000000..2fc6f98 Binary files /dev/null and b/Assets/world/decor/ROCK.png differ diff --git a/Game.py b/Game.py index 3948fc9..f4eb4f0 100644 --- a/Game.py +++ b/Game.py @@ -145,7 +145,7 @@ class Game: spike.draw(surf) if (self.level == 1): - self.dialogue.draw(surf, self.enemies[0], "enemy dialogue") + # self.dialogue.draw(surf, self.enemies[0], "enemy dialogue") self.dialogue.draw(surf, self.player, "player dialogue") try: diff --git a/LevelCreator.py b/LevelCreator.py index 3110fdd..667f2b9 100644 --- a/LevelCreator.py +++ b/LevelCreator.py @@ -16,6 +16,10 @@ class LevelCreator: textures.append(file[:file.index(".")]) def __init__(self): + self.mode = "MOVE" + self.pos1 = pg.Vector2(0,0) + self.pos2 = pg.Vector2(0,0) + self.blocks = {"none": [[] for _ in range(self.canvas_layers)], "world": [[] for _ in range(self.canvas_layers)]} @@ -117,7 +121,7 @@ class LevelCreator: if p == "": break x, y = p.split(',') - self.add_block(self.apply_transformations((float(x), float(y))), self.blocks[l], t, i) + self.add_block(self.apply_transformations((float(x), float(y))), self.blocks[l], t, i//3) def toggle_collidable(self): if self.collision_layer == "none": @@ -216,7 +220,15 @@ class LevelCreator: for event in pg.event.get((pg.MOUSEBUTTONDOWN, pg.MOUSEWHEEL, pg.KEYUP)): if event.type == pg.MOUSEBUTTONDOWN: if event.button == 1: - pg.mouse.get_rel() + if pg.key.get_pressed()[pg.K_LSHIFT]: + self.mode = "SELECT" + self.pos1 = self.fit_to_grid(pg.mouse.get_pos(), True) + else: + self.mode = "MOVE" + pg.mouse.get_rel() + elif event.button == 3: + if self.mode == "SELECT": + pg.mouse.get_rel() if event.type == pg.MOUSEWHEEL: if event.y < 0: current_frame_zoom *= 0.75 @@ -234,10 +246,23 @@ class LevelCreator: mouse_pressed = pg.mouse.get_pressed(3) if mouse_pressed[0]: - mouse_rel = pg.mouse.get_rel() - self.total_offset += pg.Vector2(mouse_rel[0] / self.zoom, mouse_rel[1] / self.zoom) + if self.mode == "MOVE": + mouse_rel = pg.mouse.get_rel() + self.total_offset += pg.Vector2(mouse_rel[0] / self.zoom, mouse_rel[1] / self.zoom) + elif self.mode == "SELECT": + self.pos2 = self.fit_to_grid(pg.mouse.get_pos(), True) if mouse_pressed[2]: - self.add_block(pg.mouse.get_pos(), self.blocks[self.collision_layer], self.textures[self.current_texture], + if self.mode == "SELECT": + mouse_rel = pg.Vector2(pg.mouse.get_rel()) + self.pos1 += mouse_rel + self.pos2 += mouse_rel + # self.pos2 = self.fit_to_grid(self.pos2) + # for mask in self.blocks.values(): + # for layer in mask: + # for block in layer: + # block.position + elif self.mode == "MOVE": + self.add_block(pg.mouse.get_pos(), self.blocks[self.collision_layer], self.textures[self.current_texture], self.current_layer) self.translation_matrix = np.array([[1, 0, self.total_offset.x], @@ -296,10 +321,15 @@ class LevelCreator: display_img.set_alpha(200) surf.blit(pg.transform.scale(display_img, self.apply_rect_transformations(display_img.get_rect()).size), self.apply_transformations(self.fit_to_grid(pg.mouse.get_pos(), use_floor=True))) + + if self.mode == "SELECT": + pg.draw.rect(surf,(255,0,0),self.apply_rect_transformations(pg.Rect(self.pos1, self.pos2-self.pos1)),3) + for button in self.buttons: button.draw(surf) + class Grid: thickness = 2 colour = (100, 100, 100) diff --git a/Levels/Level1.txt b/Levels/Level1.txt new file mode 100644 index 0000000..a546c33 --- /dev/null +++ b/Levels/Level1.txt @@ -0,0 +1,15 @@ + + + + + + +none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world +1350.0,1950.0|1300.0,1950.0|1250.0,1950.0|1200.0,1950.0|1150.0,1950.0|1100.0,1950.0|1050.0,1950.0|1000.0,1950.0|950.0,1950.0|900.0,1950.0|850.0,1950.0|800.0,1950.0|750.0,1950.0|400.0,1950.0|450.0,1950.0|500.0,1950.0|550.0,1950.0|600.0,1950.0|650.0,1950.0|700.0,1950.0|500.0,2000.0|400.0,2000.0|450.0,2000.0|550.0,2000.0|600.0,2000.0|650.0,2000.0|700.0,2000.0|950.0,2000.0|1000.0,2000.0|1050.0,2000.0|1100.0,2000.0|1150.0,2000.0|1200.0,2000.0|1250.0,2000.0|1300.0,2000.0|0.0,1900.0|0.0,1850.0|0.0,1800.0|0.0,1750.0|0.0,1700.0|0.0,1650.0|0.0,1600.0|50.0,1600.0|100.0,1600.0|100.0,1550.0|150.0,1550.0|200.0,1550.0|250.0,1600.0|350.0,1550.0|250.0,1550.0|300.0,1550.0|300.0,1600.0|350.0,1600.0|350.0,1650.0|300.0,1650.0|250.0,1650.0|200.0,1650.0|150.0,1650.0|200.0,1600.0|150.0,1600.0|100.0,1650.0|100.0,1700.0|150.0,1700.0|200.0,1700.0|300.0,1700.0|250.0,1700.0|50.0,1650.0|50.0,1700.0|50.0,1900.0|50.0,1850.0|50.0,1750.0|50.0,1800.0|100.0,1750.0|100.0,1800.0|100.0,1850.0|150.0,1750.0|150.0,1800.0|150.0,1850.0|200.0,1900.0|200.0,1850.0|200.0,1800.0|200.0,1750.0|250.0,1750.0|350.0,1700.0|350.0,1750.0|350.0,1800.0|350.0,1850.0|350.0,1900.0|300.0,1850.0|300.0,1800.0|300.0,1750.0|250.0,1800.0|250.0,1850.0|300.0,1900.0|350.0,1950.0|300.0,1950.0|250.0,1900.0|50.0,1550.0|0.0,1550.0|0.0,1950.0|50.0,1950.0|200.0,1950.0|250.0,2000.0|300.0,2000.0|350.0,2050.0|400.0,2050.0|450.0,2050.0|500.0,2050.0|550.0,2050.0|600.0,2050.0|650.0,2050.0|700.0,2050.0|750.0,2050.0|800.0,2000.0|850.0,2000.0|900.0,2050.0|950.0,2050.0|1000.0,2050.0|1050.0,2050.0|1100.0,2050.0|1150.0,2050.0|1200.0,2050.0|1250.0,2050.0|1300.0,2050.0|1350.0,2050.0|1450.0,2000.0|1500.0,2000.0|1550.0,2000.0|1600.0,2000.0|1650.0,2000.0|1750.0,1950.0|1800.0,1950.0|1850.0,1950.0|750.0,2000.0|900.0,2000.0|350.0,2000.0|250.0,1950.0|150.0,1900.0|100.0,1900.0|200.0,2000.0|150.0,2000.0|100.0,2000.0|150.0,2050.0|200.0,2050.0|250.0,2050.0|300.0,2050.0|50.0,2000.0|0.0,2000.0|0.0,2050.0|50.0,2050.0|100.0,2050.0|0.0,2100.0|50.0,2100.0|100.0,2100.0|150.0,2100.0|200.0,2100.0|250.0,2100.0|300.0,2100.0|350.0,2100.0|400.0,2100.0|450.0,2100.0|500.0,2100.0|550.0,2100.0|600.0,2100.0|650.0,2100.0|700.0,2100.0|750.0,2100.0|800.0,2100.0|800.0,2050.0|850.0,2050.0|850.0,2100.0|900.0,2100.0|950.0,2100.0|1000.0,2100.0|1050.0,2100.0|1100.0,2100.0|1150.0,2100.0|1200.0,2100.0|1250.0,2100.0|1300.0,2100.0|1350.0,2100.0|1400.0,2100.0|1400.0,2050.0|1450.0,2050.0|1450.0,2100.0|1350.0,2000.0|1700.0,1950.0|1900.0,1950.0|1700.0,2000.0|1750.0,2000.0|1800.0,2000.0|1850.0,2000.0|1900.0,2000.0|1900.0,2050.0|1850.0,2050.0|1800.0,2050.0|1750.0,2050.0|1700.0,2050.0|1650.0,2050.0|1600.0,2050.0|1550.0,2050.0|1500.0,2050.0|1500.0,2100.0|1550.0,2100.0|1600.0,2100.0|1650.0,2100.0|1700.0,2100.0|1750.0,2100.0|1800.0,2100.0|1850.0,2100.0|1900.0,2100.0|2050.0,1850.0|1400.0,1950.0|1450.0,1950.0|1400.0,1900.0|1450.0,1900.0|1500.0,1900.0|1500.0,1950.0|1550.0,1950.0|1600.0,1950.0|1650.0,1950.0|1650.0,1900.0|1600.0,1900.0|1550.0,1900.0|1700.0,1900.0|1750.0,1900.0|1800.0,1900.0|1850.0,1900.0|1900.0,1900.0|1950.0,1900.0|2000.0,1900.0|2050.0,1900.0|2050.0,1950.0|2000.0,1950.0|1950.0,1950.0|1400.0,2000.0|150.0,1950.0|100.0,1950.0|400.0,1900.0|2100.0,1700.0|2100.0,1750.0|2100.0,1800.0|2100.0,1850.0|2100.0,1900.0|2100.0,1950.0|2150.0,1700.0|2150.0,1750.0|2150.0,1800.0|2150.0,1900.0|2150.0,1850.0|2200.0,1850.0|2200.0,1800.0|2200.0,1750.0|2200.0,1700.0|2250.0,1700.0|2250.0,1750.0|2250.0,1800.0|2300.0,1800.0|2400.0,1750.0|2400.0,1800.0|2350.0,1800.0|2350.0,1750.0|2300.0,1750.0|2300.0,1700.0|2350.0,1700.0|2400.0,1700.0|2450.0,1700.0|2450.0,1750.0|2450.0,1800.0|2500.0,1700.0|2500.0,1750.0|2500.0,1800.0|2550.0,1800.0|2550.0,1750.0|2550.0,1700.0|2600.0,1650.0|2200.0,1950.0|2250.0,1900.0|2350.0,1850.0|2400.0,1850.0|2450.0,1850.0|2500.0,1850.0|2550.0,1850.0|1950.0,2000.0|2000.0,2000.0|2050.0,2000.0|2100.0,2000.0|2150.0,1950.0|2200.0,1900.0|2300.0,1850.0|2250.0,1850.0|2350.0,1900.0|2400.0,1900.0|2450.0,1900.0|2500.0,1900.0|2550.0,1900.0|2550.0,1950.0|2500.0,1950.0|2450.0,1950.0|2400.0,1950.0|2350.0,1950.0|2300.0,1900.0|2300.0,1950.0|2250.0,1950.0|2250.0,2000.0|2200.0,2000.0|2150.0,2000.0|2100.0,2050.0|2050.0,2050.0|2000.0,2050.0|1950.0,2050.0|1950.0,2100.0|2000.0,2100.0|2050.0,2100.0|2100.0,2100.0|2150.0,2100.0|2150.0,2050.0|2200.0,2050.0|2250.0,2050.0|2300.0,2050.0|2300.0,2000.0|2350.0,2000.0|2400.0,2000.0|2450.0,2000.0|2500.0,2000.0|2550.0,2000.0|2550.0,2050.0|2500.0,2050.0|2450.0,2050.0|2400.0,2050.0|2350.0,2050.0|2200.0,2100.0|2250.0,2100.0|2300.0,2100.0|2350.0,2100.0|2400.0,2100.0|2450.0,2100.0|2500.0,2100.0|2550.0,2100.0|500.0,1900.0|550.0,1900.0|600.0,1900.0|650.0,1900.0|700.0,1900.0|750.0,1900.0|800.0,1900.0|850.0,1900.0|900.0,1900.0|950.0,1900.0|1000.0,1900.0|1050.0,1900.0|1100.0,1900.0|1150.0,1900.0|1200.0,1900.0|1250.0,1900.0|1300.0,1900.0|1350.0,1900.0|650.0,1750.0|400.0,1850.0|400.0,1800.0|400.0,1750.0|400.0,1700.0|400.0,1650.0|400.0,1600.0|400.0,1550.0|350.0,1500.0|300.0,1500.0|250.0,1500.0|200.0,1500.0|150.0,1500.0|100.0,1500.0|50.0,1500.0|0.0,1500.0|400.0,1500.0|450.0,1900.0|1450.0,1850.0|1500.0,1850.0|1550.0,1850.0|1600.0,1850.0|1650.0,1850.0|1700.0,1850.0|1750.0,1850.0|1800.0,1850.0|1850.0,1850.0|1900.0,1850.0|1950.0,1850.0|2000.0,1850.0|2100.0,1650.0|2150.0,1650.0|2200.0,1650.0|2250.0,1650.0|2300.0,1650.0|2350.0,1650.0|2400.0,1650.0|2450.0,1650.0|2500.0,1650.0|2550.0,1650.0|1400.0,1850.0|2050.0,1650.0 +DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|LEFTSTONEDIRTCORNER|STONEDIRTCORNER|STONEDIRTCORNER|STONEDIRTCORNER|STONEDIRTCORNER|LEFTSTONEDIRTCORNER|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|LEFTSTONEDIRTCORNER|LEFTSTONEDIRTCORNER|STONEDIRTCORNER|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|CORNERGRASS|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|STONEDIRT|STONE|STONE|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|DIRT|CORNERGRASS|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|STONEDIRT|LEFTSTONEDIRTCORNER|LEFTSTONEDIRTCORNER|LEFTSTONEDIRTCORNER|DIRT|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|STONE|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|PLAYER|SIDEDIRT|SIDEDIRT|SIDEDIRT|SIDEDIRT|SIDEDIRT|SIDEDIRT|SIDEDIRT|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|CORNERGRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|GRASS|LEFTCORNERGRASS|LEFTCORNERGRASS + + + + + + diff --git a/main.py b/main.py index 690e91b..6a78bb3 100644 --- a/main.py +++ b/main.py @@ -13,7 +13,7 @@ delta = 1000//fps # scene = TransitionScene() scene = DevLevelSelect() old_level = 0 -level = 2 +level = 0 next_level = 0 while Setup.is_running: