Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
ebff280
New map file, new folder, new class
Davidek523 Dec 1, 2024
d13edbc
Animation speed
Davidek523 Dec 26, 2024
d764004
Adding to sprites
Davidek523 Dec 26, 2024
cee9473
Adding coast
Davidek523 Dec 26, 2024
c575674
Adding function
Davidek523 Dec 26, 2024
b87c3b3
Adding logic
Davidek523 Dec 26, 2024
cefb891
Adding coast to world frames
Davidek523 Dec 26, 2024
65c5725
Fixed small bug
Davidek523 Dec 26, 2024
8fd4185
Expanding logic
Davidek523 Dec 26, 2024
0a51499
Adding coast
Davidek523 Dec 26, 2024
f6b5a8c
Small fix
Davidek523 Dec 26, 2024
2fe476b
Changing sea
Davidek523 Dec 26, 2024
a9e941a
Adding sea
Davidek523 Dec 26, 2024
9ba4044
Changes in map
Davidek523 Dec 27, 2024
a9fafe1
Scaling of map
Davidek523 Dec 27, 2024
f2cb5f3
Fixed scale bug
Davidek523 Dec 27, 2024
0a69b02
Adding coasts
Davidek523 Dec 27, 2024
3dc47f8
World layers
Davidek523 Dec 27, 2024
bd0a7eb
Adding new things
Davidek523 Dec 27, 2024
02566d0
New method logic
Davidek523 Dec 27, 2024
ee33577
New method in support
Davidek523 Dec 27, 2024
7d3e56b
Finishing method
Davidek523 Dec 27, 2024
30655c8
Added simple image
Davidek523 Dec 27, 2024
f93cd8e
Adding animation method
Davidek523 Dec 27, 2024
91a49d0
Logic and update
Davidek523 Dec 27, 2024
57b34ca
Updating animation
Davidek523 Dec 27, 2024
cae0703
Adding new method
Davidek523 Dec 27, 2024
56cbd4c
Replacing old images
Davidek523 Dec 27, 2024
bf914f5
Logic for movement
Davidek523 Dec 27, 2024
ee62280
Finishing logic
Davidek523 Dec 27, 2024
9a5520b
Old code
Davidek523 Dec 28, 2024
95dfbc5
Adding layers
Davidek523 Dec 28, 2024
6fa9959
Layers in gameloop
Davidek523 Dec 28, 2024
619a6bf
Water fix
Davidek523 Dec 28, 2024
9bea1c6
Adding shallow water
Davidek523 Dec 28, 2024
402d4d9
Fixing islands
Davidek523 Dec 28, 2024
406540d
Old code
Davidek523 Dec 28, 2024
3a727cf
Camera drag method
Davidek523 Dec 28, 2024
5ea3bab
Handling camera drag
Davidek523 Dec 28, 2024
a36a959
Introducing drag for player
Davidek523 Dec 28, 2024
c6412f4
Commenting out code
Davidek523 Jan 10, 2025
e8ad607
Removed 1
Davidek523 Jan 10, 2025
a78b58e
Remove 2
Davidek523 Jan 10, 2025
f1bca83
Remove 3
Davidek523 Jan 10, 2025
605ed6a
Remove 4
Davidek523 Jan 10, 2025
c70ecb7
Remove 5
Davidek523 Jan 10, 2025
eb5d68e
Fixed small issue
Davidek523 Jan 10, 2025
065448c
Removing old code
Davidek523 Jan 10, 2025
b034513
Add direction vector
Davidek523 Jan 10, 2025
f0eb57e
Refactored movement
Davidek523 Jan 10, 2025
f8288d5
Fixed ship texture
Davidek523 Feb 9, 2025
1517799
Merge branch 'main' of https://github.com/PyCeas/Pyceas into Map-revi…
Davidek523 Feb 9, 2025
600c5dd
Merge conflicts
Davidek523 Feb 9, 2025
c4921f2
Fixed issue
Davidek523 Feb 9, 2025
48fce93
Fixed lint
Davidek523 Feb 9, 2025
dfe6daf
Merge branch 'main' of https://github.com/PyCeas/Pyceas into Map-revi…
Davidek523 Feb 9, 2025
81bbfb0
Small fixes
Davidek523 Feb 9, 2025
54c77a7
Update credits
Davidek523 Feb 17, 2025
20c24de
Removing ghost preview
Davidek523 Feb 17, 2025
2fd4bac
Merge branch 'main' of https://github.com/PyCeas/Pyceas into Map-revi…
Davidek523 Feb 17, 2025
6e1df77
Reverting sprite
Davidek523 Feb 18, 2025
3aeb897
Added new texture
Davidek523 Feb 18, 2025
1e7ceb8
Replaced the texture
Davidek523 Feb 18, 2025
3be1185
Added new texture
Davidek523 Feb 18, 2025
13d54c2
Removed the old texture
Davidek523 Feb 18, 2025
6b3d80a
Renamed the image
Davidek523 Feb 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ This file provides credits for all assets, tools, and contributions that have be

## Contributors

- **Davidek523**
- **Role**: Programmer
- **Github**: [davidek523](https://github.com/Davidek523)

- **Danilo Saiu**
- **Role**: Project overseer/programmer
- **Github**: [ultimateownsz](https://www.github.com/ultimateownsz)
Expand Down
1,055 changes: 1,055 additions & 0 deletions data/new_maps/100x100_map.tmx

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions data/new_tilesets/Fort Tiles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.11.0" name="Fort Tiles" tilewidth="16" tileheight="16" tilecount="432" columns="27">
<image source="../../images/tilesets/Fort Tiles.png" width="432" height="256"/>
</tileset>
4 changes: 4 additions & 0 deletions data/new_tilesets/Ships tiles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.11.0" name="Ships tiles" tilewidth="16" tileheight="16" tilecount="1890" columns="45">
<image source="../../images/tilesets/Ships tiles.png" width="720" height="672"/>
</tileset>
4 changes: 4 additions & 0 deletions data/new_tilesets/Water and Island tiles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.11.0" name="Water and Island tiles" tilewidth="16" tileheight="16" tilecount="216" columns="24">
<image source="../../images/tilesets/Water and Island tiles.png" width="384" height="144"/>
</tileset>
4 changes: 4 additions & 0 deletions data/new_tilesets/Water+.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.11.0" name="Water+" tilewidth="16" tileheight="16" tilecount="168" columns="12">
<image source="../../images/tilesets/Water+.png" width="192" height="224"/>
</tileset>
Binary file added images/tilesets/coast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/tilesets/ships/player_ship.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/tilesets/ships/player_sloop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/tilesets/ships/player_test_ship.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/tilesets/temporary_water/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/tilesets/water/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/tilesets/water/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/tilesets/water/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 125 additions & 0 deletions src/GUI/gameloop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
from os.path import join
import sys

# import dataclasses and typchecking
from dataclasses import dataclass, field

# import pygame related
import pygame
from pytmx.util_pygame import load_pygame # type: ignore

# import Pygame specific objects, functions and functionality
from src.settings import SCREEN_WIDTH, SCREEN_HEIGHT, TILE_SIZE, WORLD_LAYERS
from src.support import import_folder, coast_importer, all_character_import
import src.sprites
from src.sprites import AnimatedSprites


@dataclass
class GUI:
"""Graphial User Interface vertion of the game, using pygame-ce"""

screen_size: tuple[int, int] = (SCREEN_WIDTH, SCREEN_HEIGHT)
screen: pygame.Surface = field(init=False)

# groups
# all_sprites: pygame.sprite.Group = field(
# init=False, default_factory=pygame.sprite.Group
# )

def __post_init__(self):
pygame.init()
self.screen = pygame.display.set_mode(self.screen_size)
pygame.display.set_caption("PySeas")
self.clock = pygame.Clock()

# self.players: list[src.sprites.Player] = [src.sprites.Player()]

self.all_sprites = src.sprites.AllSprites()
self.running = True
self.import_assets()
self.setup(
tmx_maps=self.tmx_map["map"], player_start_pos="top_left_island"
) # The start positions will be one of the 4 islands in the corners of the board
self.camera_mode = "drag"

def import_assets(self):
"""load the map"""
# The map was made as a basic start for the game, it can be changes or altered if it is better for the overall flow of the game
self.tmx_map = {
"map": load_pygame(join(".", "data", "new_maps", "100x100_map.tmx"))
}

self.world_frames = {
"water": import_folder(".", "images", "tilesets", "water"),
"coast": coast_importer(6, 6, ".", "images", "tilesets", "coast"),
"ships": all_character_import(".", "images", "tilesets", "ships")
}
# print(self.world_frames["ships"])

def setup(self, tmx_maps, player_start_pos):
"""create tiles"""

# Sea
for x, y, surface in tmx_maps.get_layer_by_name("Sea").tiles():
src.sprites.Sprite((x * TILE_SIZE, y * TILE_SIZE), surface, self.all_sprites, WORLD_LAYERS["bg"])

# Water animated
for obj in tmx_maps.get_layer_by_name("Water"):
for x in range(int(obj.x), int(obj.x + obj.width), TILE_SIZE):
for y in range(int(obj.y), int(obj.y + obj.height), TILE_SIZE):
AnimatedSprites((x, y), self.world_frames["water"], self.all_sprites, WORLD_LAYERS["water"])

# Shallow water
for x, y, surface in tmx_maps.get_layer_by_name("Shallow Sea").tiles():
src.sprites.Sprite((x * TILE_SIZE, y * TILE_SIZE), surface, self.all_sprites, WORLD_LAYERS["bg"])

# Islands
islands = tmx_maps.get_layer_by_name("Islands")
for x, y, surface in islands.tiles():
src.sprites.Sprite((x * TILE_SIZE, y * TILE_SIZE), surface, self.all_sprites, WORLD_LAYERS["bg"])

# Enitites
for obj in tmx_maps.get_layer_by_name("Ships"):
if obj.name == "Player" and obj.properties["pos"] == player_start_pos:
self.player = src.sprites.Player(
pos = (obj.x, obj.y),
frames = self.world_frames["ships"]["player_test_ship"],
groups = self.all_sprites)

# Coast
for obj in tmx_maps.get_layer_by_name("Coast"):
terrain = obj.properties["terrain"]
side = obj.properties["side"]
AnimatedSprites((obj.x, obj.y), self.world_frames["coast"][terrain][side], self.all_sprites, WORLD_LAYERS["bg"])


def run(self) -> None:
"""main loop of the game"""
while self.running:
self.handle_events()
self.render()

def handle_events(self) -> None:
"""get events like keypress or mouse clicks"""
for event in pygame.event.get():
match event.type:
case pygame.QUIT:
pygame.quit()
sys.exit()

def render(self) -> None:
"""draw sprites to the canvas"""
dt = self.clock.tick() / 1000
self.screen.fill("#000000")

self.all_sprites.update(dt)
self.all_sprites.draw(self.player.rect.center, self.player.player_preview, self.player.player_preview_rect)

'''No need to loop through the players because it is now in the sprite group AllSprites'''
# draw players on top of the other sprites
# for player in self.players:
# player.render(surface=self.screen)

pygame.display.update()

8 changes: 8 additions & 0 deletions src/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@

SCREEN_WIDTH, SCREEN_HEIGHT = 1280, 720
TILE_SIZE = 16
ANIMATION_SPEED = 4

WORLD_LAYERS = {
"water": 0,
"bg": 1,
"main": 2,
"top": 3
}
FPS = 60


Expand Down
Loading