mirror of
https://github.com/OMGeeky/pytiled_parser.git
synced 2025-12-31 16:44:26 +01:00
rf: change line length to 88 chars
This commit is contained in:
@@ -8,8 +8,8 @@ SCREEN_HEIGHT = 600
|
||||
SPRITE_SCALING = 1
|
||||
GRAVITY = 1.1
|
||||
|
||||
class BasicTestWindow(arcade.Window):
|
||||
|
||||
class BasicTestWindow(arcade.Window):
|
||||
def __init__(self, width, height, title, map_name):
|
||||
super().__init__(width, height, title)
|
||||
file_path = os.path.dirname(os.path.abspath(__file__))
|
||||
@@ -18,14 +18,18 @@ class BasicTestWindow(arcade.Window):
|
||||
self.layers = []
|
||||
my_map = arcade.tiled.read_tiled_map(map_name, 1)
|
||||
for layer in my_map.layers:
|
||||
self.layers.append(arcade.tiled.generate_sprites(
|
||||
my_map, layer, 1, "../arcade/arcade/examples/"))
|
||||
self.layers.append(
|
||||
arcade.tiled.generate_sprites(
|
||||
my_map, layer, 1, "../arcade/arcade/examples/"
|
||||
)
|
||||
)
|
||||
|
||||
def on_draw(self):
|
||||
arcade.start_render()
|
||||
for layer in self.layers:
|
||||
layer.draw()
|
||||
|
||||
|
||||
class CollisionTestWindow(BasicTestWindow):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
@@ -33,13 +37,15 @@ class CollisionTestWindow(BasicTestWindow):
|
||||
|
||||
self.player_list = arcade.SpriteList()
|
||||
self.player_sprite = arcade.Sprite(
|
||||
"../arcade/arcade/examples/images/character.png", SPRITE_SCALING)
|
||||
"../arcade/arcade/examples/images/character.png", SPRITE_SCALING
|
||||
)
|
||||
self.player_sprite.center_x = 400
|
||||
self.player_sprite.center_y = 800
|
||||
self.player_list.append(self.player_sprite)
|
||||
|
||||
self.physics_engine = arcade.PhysicsEnginePlatformer(
|
||||
self.player_sprite, self.layers[0], gravity_constant=GRAVITY)
|
||||
self.player_sprite, self.layers[0], gravity_constant=GRAVITY
|
||||
)
|
||||
|
||||
def on_draw(self):
|
||||
super().on_draw()
|
||||
@@ -54,12 +60,10 @@ class CollisionTestWindow(BasicTestWindow):
|
||||
self.physics_engine.update()
|
||||
|
||||
|
||||
|
||||
|
||||
window = CollisionTestWindow(
|
||||
SCREEN_WIDTH,
|
||||
SCREEN_HEIGHT,
|
||||
"Test Text",
|
||||
"../arcade/arcade/examples/map_polyline_collision.tmx"
|
||||
"../arcade/arcade/examples/map_polyline_collision.tmx",
|
||||
)
|
||||
arcade.run()
|
||||
|
||||
@@ -1 +1 @@
|
||||
MAP_NAME = 'assets/tiled_test_4.tmx'
|
||||
MAP_NAME = "assets/tiled_test_4.tmx"
|
||||
|
||||
1705
test/foo.py
1705
test/foo.py
File diff suppressed because one or more lines are too long
@@ -4,6 +4,7 @@ import config
|
||||
|
||||
from arcade.tiled import read_tiled_map
|
||||
|
||||
|
||||
class MyTestWindow(arcade.Window):
|
||||
def __init__(self, width, height, title):
|
||||
super().__init__(width, height, title)
|
||||
@@ -14,14 +15,15 @@ class MyTestWindow(arcade.Window):
|
||||
self.map.draw()
|
||||
|
||||
|
||||
MAP_NAME = 'assets/tiled_test_4.tmx'
|
||||
MAP_NAME = "assets/tiled_test_4.tmx"
|
||||
my_map = arcade.read_tiled_map(config.MAP_NAME, 1)
|
||||
|
||||
for row in my_map.layers["Tile Layer 1"]:
|
||||
for grid_object in row:
|
||||
print(grid_object)
|
||||
print(
|
||||
f"{grid_object.tile.local_id}, {grid_object.center_x}, {grid_object.center_y}")
|
||||
test = MyTestWindow(640,800,"meme")
|
||||
f"{grid_object.tile.local_id}, {grid_object.center_x}, {grid_object.center_y}"
|
||||
)
|
||||
test = MyTestWindow(640, 800, "meme")
|
||||
test.test()
|
||||
test.close()
|
||||
|
||||
@@ -5,6 +5,7 @@ import pprint
|
||||
|
||||
pp = pprint.PrettyPrinter(indent=4, compact=True, width=200)
|
||||
|
||||
|
||||
class MyTestWindow(arcade.Window):
|
||||
def __init__(self, width, height, title, map_name):
|
||||
super().__init__(width, height, title)
|
||||
@@ -13,8 +14,11 @@ class MyTestWindow(arcade.Window):
|
||||
my_map = arcade.tiled.read_tiled_map(map_name, 1)
|
||||
pp.pprint(my_map.layers_int_data)
|
||||
for layer in my_map.layers_int_data:
|
||||
self.layers.append(arcade.tiled.generate_sprites(
|
||||
my_map, layer, 1, "../arcade/arcade/examples/"))
|
||||
self.layers.append(
|
||||
arcade.tiled.generate_sprites(
|
||||
my_map, layer, 1, "../arcade/arcade/examples/"
|
||||
)
|
||||
)
|
||||
|
||||
def on_draw(self):
|
||||
arcade.start_render()
|
||||
@@ -22,7 +26,7 @@ class MyTestWindow(arcade.Window):
|
||||
layer.draw()
|
||||
|
||||
|
||||
MAP_NAME = '../arcade/arcade/examples/map_base64_gzip.tmx'
|
||||
MAP_NAME = "../arcade/arcade/examples/map_base64_gzip.tmx"
|
||||
|
||||
test = MyTestWindow(640, 800, "meme", MAP_NAME)
|
||||
arcade.run()
|
||||
|
||||
Reference in New Issue
Block a user