-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscroll.py
More file actions
33 lines (24 loc) · 840 Bytes
/
scroll.py
File metadata and controls
33 lines (24 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pyscroll
from pytmx.util_pygame import load_pygame
# Load TMX data
#tmx_data = load_pygame("desert.tmx")
# Make data source for the map
map_data = pyscroll.TiledMapData(tmx_data)
# Make the scrolling layer
screen_size = (400, 400)
map_layer = pyscroll.BufferedRenderer(map_data, screen_size)
# make the PyGame SpriteGroup with a scrolling map
group = pyscroll.PyscrollGroup(map_layer=map_layer)
# Add sprites to the group
group.add(sprite)
# Center the layer and sprites on a sprite
group.center(sprite.rect.center)
# Draw the layer
# If the map covers the entire screen, do not clear the screen:
# Clearing the screen is not needed since the map will clear it when drawn
# This map covers the screen, so no clearing!
group.draw(screen)
# adjust the zoom (out)
map_layer.zoom = .5
# adjust the zoom (in)
map_layer.zoom = 2.0