Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Tilemap implementation
All platforms are now created through a map (.txt file) Changed (again) how collision works making it consistent through all platforms.
- Loading branch information
Showing
10 changed files
with
118 additions
and
76 deletions.
There are no files selected for viewing
BIN
-53 Bytes
(95%)
__pycache__/settings.cpython-38.pyc
Binary file not shown.
BIN
+33 Bytes
(100%)
__pycache__/sprites.cpython-38.pyc
Binary file not shown.
BIN
+1.35 KB
img/grassLeft.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+1.17 KB
img/grassMid.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN
+1.34 KB
img/grassRight.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.............................. | ||
....P.....1................... | ||
.............................. | ||
.............................. | ||
...............11............. | ||
.............................. | ||
....111....................... | ||
...................111........ | ||
...........111................ | ||
................111........... | ||
.............................. | ||
.....111............111....... | ||
1..........11111.............. | ||
1............................1 | ||
111111111111111111111111111111 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pygame | ||
|
||
|
||
class spritesheet(object): | ||
def __init__(self, filename): | ||
self.sheet = pygame.image.load(filename).convert() | ||
|
||
# Load a specific image from a specific rectangle | ||
def image_at(self, rectangle, colorkey=None): | ||
"Loads image from x,y,x+offset,y+offset" | ||
rect = pygame.Rect(rectangle) | ||
image = pygame.Surface(rect.size).convert() | ||
image.blit(self.sheet, (0, 0), rect) | ||
if colorkey is not None: | ||
if colorkey is -1: | ||
colorkey = image.get_at((0, 0)) | ||
image.set_colorkey(colorkey, pygame.RLEACCEL) | ||
return image | ||
|
||
# Load a whole bunch of images and return them as a list | ||
def images_at(self, rects, colorkey=None): | ||
"Loads multiple images, supply a list of coordinates" | ||
return [self.image_at(rect, colorkey) for rect in rects] | ||
|
||
# Load a whole strip of images | ||
def load_strip(self, rect, image_count, colorkey=None): | ||
"Loads a strip of images and returns them as a list" | ||
tups = [(rect[0] + rect[2] * x, rect[1], rect[2], rect[3]) | ||
for x in range(image_count)] | ||
return self.images_at(tups, colorkey) |