-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ added support for pygbag (toolchain to use pygame with WebAssembly …
…aka wasm)
- Loading branch information
Showing
42 changed files
with
1,327 additions
and
1,288 deletions.
There are no files selected for viewing
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,11 @@ | ||
@echo off | ||
set project_name=Pirate | ||
REM building web version using pygbag (toolchain to use pygame with WebAssembly aka wasm) | ||
REM build can be found in bin\web | ||
REM add --archive to crate web.zip (e.g. for easy deploy to itch.io) | ||
REM see https://pypi.org/project/pygbag/ for more details | ||
|
||
set current_dir=%CD% | ||
cd .. | ||
pygbag --build --archive --app_name %project_name% "%current_dir%" | ||
cd "%current_dir%" |
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
@echo off | ||
REM building Windows exe file | ||
REM build can be found in bin\win | ||
REM https://stackoverflow.com/questions/54210392/how-can-i-convert-pygame-to-exe | ||
|
||
python setup.py build |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,90 +1,90 @@ | ||
from settings import VERTICAL_TILE_NUMBER, TILE_SIZE, SCREEN_WIDTH | ||
import pygame | ||
from tiles import AnimatedTile, StaticTile | ||
from support import import_folder | ||
from random import choice, randint | ||
|
||
class Sky: | ||
def __init__(self,horizon,style = 'level'): | ||
self.top = pygame.image.load('../graphics/decoration/sky/sky_top.png').convert() | ||
self.bottom = pygame.image.load('../graphics/decoration/sky/sky_bottom.png').convert() | ||
self.middle = pygame.image.load('../graphics/decoration/sky/sky_middle.png').convert() | ||
self.horizon = horizon | ||
|
||
# stretch | ||
self.top = pygame.transform.scale(self.top,(SCREEN_WIDTH,TILE_SIZE)) | ||
self.bottom = pygame.transform.scale(self.bottom,(SCREEN_WIDTH,TILE_SIZE)) | ||
self.middle = pygame.transform.scale(self.middle,(SCREEN_WIDTH,TILE_SIZE)) | ||
|
||
self.style = style | ||
if self.style == 'overworld': | ||
palm_surfaces = import_folder('../graphics/overworld/palms') | ||
self.palms = [] | ||
|
||
for surface in [choice(palm_surfaces) for image in range(10)]: | ||
x = randint(0,SCREEN_WIDTH) | ||
y = (self.horizon * TILE_SIZE) + randint(50,100) | ||
rect = surface.get_rect(midbottom = (x,y)) | ||
self.palms.append((surface,rect)) | ||
|
||
cloud_surfaces = import_folder('../graphics/overworld/clouds') | ||
self.clouds = [] | ||
|
||
for surface in [choice(cloud_surfaces) for image in range(10)]: | ||
x = randint(0,SCREEN_WIDTH) | ||
y = randint(0,(self.horizon * TILE_SIZE) - 100) | ||
rect = surface.get_rect(midbottom = (x,y)) | ||
self.clouds.append((surface,rect)) | ||
|
||
def draw(self,surface): | ||
for row in range(VERTICAL_TILE_NUMBER): | ||
y = row * TILE_SIZE | ||
if row < self.horizon: | ||
surface.blit(self.top,(0,y)) | ||
elif row == self.horizon: | ||
surface.blit(self.middle,(0,y)) | ||
else: | ||
surface.blit(self.bottom,(0,y)) | ||
|
||
if self.style == 'overworld': | ||
for palm in self.palms: | ||
surface.blit(palm[0],palm[1]) | ||
for cloud in self.clouds: | ||
surface.blit(cloud[0],cloud[1]) | ||
|
||
class Water: | ||
def __init__(self,top,level_width): | ||
water_start = -SCREEN_WIDTH | ||
water_tile_width = 192 | ||
tile_x_amount = int((level_width + SCREEN_WIDTH * 2) / water_tile_width) | ||
self.water_sprites = pygame.sprite.Group() | ||
|
||
for tile in range(tile_x_amount): | ||
x = tile * water_tile_width + water_start | ||
y = top | ||
sprite = AnimatedTile(192,x,y,'../graphics/decoration/water') | ||
self.water_sprites.add(sprite) | ||
|
||
def draw(self,surface,shift): | ||
self.water_sprites.update(shift) | ||
self.water_sprites.draw(surface) | ||
|
||
class Clouds: | ||
def __init__(self,horizon,level_width,cloud_number): | ||
cloud_surf_list = import_folder('../graphics/decoration/clouds') | ||
min_x = -SCREEN_WIDTH | ||
max_x = level_width + SCREEN_WIDTH | ||
min_y = 0 | ||
max_y = horizon | ||
self.cloud_sprites = pygame.sprite.Group() | ||
|
||
for cloud in range(cloud_number): | ||
cloud = choice(cloud_surf_list) | ||
x = randint(min_x,max_x) | ||
y = randint(min_y,max_y) | ||
sprite = StaticTile(0,x,y,cloud) | ||
self.cloud_sprites.add(sprite) | ||
|
||
def draw(self,surface,shift): | ||
self.cloud_sprites.update(shift) | ||
self.cloud_sprites.draw(surface) | ||
from settings import VERTICAL_TILE_NUMBER, TILE_SIZE, SCREEN_WIDTH | ||
import pygame | ||
from tiles import AnimatedTile, StaticTile | ||
from support import import_folder | ||
from random import choice, randint | ||
|
||
class Sky: | ||
def __init__(self,horizon,style = 'level'): | ||
self.top = pygame.image.load('graphics/decoration/sky/sky_top.png').convert() | ||
self.bottom = pygame.image.load('graphics/decoration/sky/sky_bottom.png').convert() | ||
self.middle = pygame.image.load('graphics/decoration/sky/sky_middle.png').convert() | ||
self.horizon = horizon | ||
|
||
# stretch | ||
self.top = pygame.transform.scale(self.top,(SCREEN_WIDTH,TILE_SIZE)) | ||
self.bottom = pygame.transform.scale(self.bottom,(SCREEN_WIDTH,TILE_SIZE)) | ||
self.middle = pygame.transform.scale(self.middle,(SCREEN_WIDTH,TILE_SIZE)) | ||
|
||
self.style = style | ||
if self.style == 'overworld': | ||
palm_surfaces = import_folder('graphics/overworld/palms') | ||
self.palms = [] | ||
|
||
for surface in [choice(palm_surfaces) for image in range(10)]: | ||
x = randint(0,SCREEN_WIDTH) | ||
y = (self.horizon * TILE_SIZE) + randint(50,100) | ||
rect = surface.get_rect(midbottom = (x,y)) | ||
self.palms.append((surface,rect)) | ||
|
||
cloud_surfaces = import_folder('graphics/overworld/clouds') | ||
self.clouds = [] | ||
|
||
for surface in [choice(cloud_surfaces) for image in range(10)]: | ||
x = randint(0,SCREEN_WIDTH) | ||
y = randint(0,(self.horizon * TILE_SIZE) - 100) | ||
rect = surface.get_rect(midbottom = (x,y)) | ||
self.clouds.append((surface,rect)) | ||
|
||
def draw(self,surface): | ||
for row in range(VERTICAL_TILE_NUMBER): | ||
y = row * TILE_SIZE | ||
if row < self.horizon: | ||
surface.blit(self.top,(0,y)) | ||
elif row == self.horizon: | ||
surface.blit(self.middle,(0,y)) | ||
else: | ||
surface.blit(self.bottom,(0,y)) | ||
|
||
if self.style == 'overworld': | ||
for palm in self.palms: | ||
surface.blit(palm[0],palm[1]) | ||
for cloud in self.clouds: | ||
surface.blit(cloud[0],cloud[1]) | ||
|
||
class Water: | ||
def __init__(self,top,level_width): | ||
water_start = -SCREEN_WIDTH | ||
water_tile_width = 192 | ||
tile_x_amount = int((level_width + SCREEN_WIDTH * 2) / water_tile_width) | ||
self.water_sprites = pygame.sprite.Group() | ||
|
||
for tile in range(tile_x_amount): | ||
x = tile * water_tile_width + water_start | ||
y = top | ||
sprite = AnimatedTile(192,x,y,'graphics/decoration/water') | ||
self.water_sprites.add(sprite) | ||
|
||
def draw(self,surface,shift): | ||
self.water_sprites.update(shift) | ||
self.water_sprites.draw(surface) | ||
|
||
class Clouds: | ||
def __init__(self,horizon,level_width,cloud_number): | ||
cloud_surf_list = import_folder('graphics/decoration/clouds') | ||
min_x = -SCREEN_WIDTH | ||
max_x = level_width + SCREEN_WIDTH | ||
min_y = 0 | ||
max_y = horizon | ||
self.cloud_sprites = pygame.sprite.Group() | ||
|
||
for cloud in range(cloud_number): | ||
cloud = choice(cloud_surf_list) | ||
x = randint(min_x,max_x) | ||
y = randint(min_y,max_y) | ||
sprite = StaticTile(0,x,y,cloud) | ||
self.cloud_sprites.add(sprite) | ||
|
||
def draw(self,surface,shift): | ||
self.cloud_sprites.update(shift) | ||
self.cloud_sprites.draw(surface) |
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 |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import pygame | ||
from tiles import AnimatedTile | ||
from random import randint | ||
|
||
class Enemy(AnimatedTile): | ||
def __init__(self,size,x,y): | ||
super().__init__(size,x,y,'../graphics/enemy/run') | ||
self.rect.y += size - self.image.get_size()[1] | ||
self.speed = randint(3,5) | ||
|
||
def move(self): | ||
self.rect.x += self.speed | ||
|
||
def reverse_image(self): | ||
if self.speed > 0: | ||
self.image = pygame.transform.flip(self.image,True,False) | ||
|
||
def reverse(self): | ||
self.speed *= -1 | ||
|
||
def update(self,shift): | ||
self.rect.x += shift | ||
self.animate() | ||
self.move() | ||
import pygame | ||
from tiles import AnimatedTile | ||
from random import randint | ||
|
||
class Enemy(AnimatedTile): | ||
def __init__(self,size,x,y): | ||
super().__init__(size,x,y,'graphics/enemy/run') | ||
self.rect.y += size - self.image.get_size()[1] | ||
self.speed = randint(3,5) | ||
|
||
def move(self): | ||
self.rect.x += self.speed | ||
|
||
def reverse_image(self): | ||
if self.speed > 0: | ||
self.image = pygame.transform.flip(self.image,True,False) | ||
|
||
def reverse(self): | ||
self.speed *= -1 | ||
|
||
def update(self,shift): | ||
self.rect.x += shift | ||
self.animate() | ||
self.move() | ||
self.reverse_image() |
Oops, something went wrong.