Skip to content

Commit

Permalink
py39
Browse files Browse the repository at this point in the history
  • Loading branch information
JaskRendix committed Jan 17, 2024
1 parent c22ed9d commit c4f14c2
Show file tree
Hide file tree
Showing 19 changed files with 259 additions and 235 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9']
python-version: ['3.9', '3.10', '3.11', '3.12']
name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pyscroll
========

For Python 3.7+ and pygame 2.0+
For Python 3.9+ and pygame 2.0+

__pygame-ce is supported__

Expand Down
5 changes: 2 additions & 3 deletions apps/demo/demo-stitched.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from __future__ import annotations

from pathlib import Path
from typing import List

import pygame
from pygame.locals import (
Expand Down Expand Up @@ -57,11 +56,11 @@ def __init__(self) -> None:
self.feet = pygame.Rect(0, 0, self.rect.width * 0.5, 8)

@property
def position(self) -> List[float]:
def position(self) -> list[float]:
return list(self._position)

@position.setter
def position(self, value: List[float]) -> None:
def position(self, value: list[float]) -> None:
self._position = list(value)

def update(self, dt: float) -> None:
Expand Down
31 changes: 17 additions & 14 deletions apps/demo/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ def init_screen(width, height):


class ScrollTest:
""" Test and demo of pyscroll
"""Test and demo of pyscroll
For normal use, please see the quest demo, not this.
"""

def __init__(self, filename):

# load data from pytmx
Expand All @@ -50,19 +51,22 @@ def __init__(self, filename):
map_data = pyscroll.data.TiledMapData(tmx_data)

# create new renderer
self.map_layer = pyscroll.orthographic.BufferedRenderer(map_data, screen.get_size())
self.map_layer = pyscroll.orthographic.BufferedRenderer(
map_data, screen.get_size()
)

# create a font and pre-render some text to be displayed over the map
f = pygame.font.Font(pygame.font.get_default_font(), 20)
t = ["scroll demo. press escape to quit",
"arrow keys move"]
t = ["scroll demo. press escape to quit", "arrow keys move"]

# save the rendered text
self.text_overlay = [f.render(i, 1, (180, 180, 0)) for i in t]

# set our initial viewpoint in the center of the map
self.center = [self.map_layer.map_rect.width / 2,
self.map_layer.map_rect.height / 2]
self.center = [
self.map_layer.map_rect.width / 2,
self.map_layer.map_rect.height / 2,
]

# the camera vector is used to handle camera movement
self.camera_acc = [0, 0, 0]
Expand All @@ -88,8 +92,7 @@ def draw_text(self, surface):
y += text.get_height()

def handle_input(self):
""" Simply handle pygame input events
"""
"""Simply handle pygame input events"""
for event in pygame.event.get():
if event.type == QUIT:
self.running = False
Expand Down Expand Up @@ -129,7 +132,7 @@ def handle_input(self):
def update(self, td):
self.last_update_time = td

friction = pow(.0001, self.last_update_time)
friction = pow(0.0001, self.last_update_time)

# update the camera vector
self.camera_vel[0] += self.camera_acc[0] * td
Expand Down Expand Up @@ -167,18 +170,18 @@ def update(self, td):
def run(self):
clock = pygame.time.Clock()
self.running = True
fps = 60.
fps = 60.0
fps_log = collections.deque(maxlen=20)

try:
while self.running:
# somewhat smoother way to get fps and limit the framerate
clock.tick(fps*2)
clock.tick(fps * 2)

try:
fps_log.append(clock.get_fps())
fps = sum(fps_log)/len(fps_log)
dt = 1/fps
fps = sum(fps_log) / len(fps_log)
dt = 1 / fps
except ZeroDivisionError:
continue

Expand All @@ -197,7 +200,7 @@ def run(self):
pygame.init()
pygame.font.init()
screen = init_screen(800, 600)
pygame.display.set_caption('pyscroll Test')
pygame.display.set_caption("pyscroll Test")

try:
filename = sys.argv[1]
Expand Down
1 change: 0 additions & 1 deletion apps/demo/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Dummy:

def run(self):
surface = None

Expand Down
7 changes: 4 additions & 3 deletions apps/tutorial/quest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from __future__ import annotations

from pathlib import Path
from typing import List

import pygame
from pygame.locals import (
Expand Down Expand Up @@ -70,6 +69,7 @@ class Hero(pygame.sprite.Sprite):
it collides with level walls.
"""

def __init__(self) -> None:
super().__init__()
self.image = load_image("hero.png").convert_alpha()
Expand All @@ -80,11 +80,11 @@ def __init__(self) -> None:
self.feet = pygame.Rect(0, 0, self.rect.width * 0.5, 8)

@property
def position(self) -> List[float]:
def position(self) -> list[float]:
return list(self._position)

@position.setter
def position(self, value: List[float]) -> None:
def position(self, value: list[float]) -> None:
self._position = list(value)

def update(self, dt: float) -> None:
Expand Down Expand Up @@ -113,6 +113,7 @@ class QuestGame:
Finally, it uses a pyscroll group to render the map and Hero.
"""

map_path = RESOURCES_DIR / "grasslands.tmx"

def __init__(self, screen: pygame.Surface) -> None:
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/_sources/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
pyscroll
========

for Python 2.7 & 3.3 and Pygame 1.9
for Python 3.9 and Pygame 1.9

A simple, fast module for adding scrolling maps to your new or existing game.

Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h3>Navigation</h3>

<div class="section" id="pyscroll">
<h1>pyscroll<a class="headerlink" href="#pyscroll" title="Permalink to this headline"></a></h1>
<p>for Python 2.7 &amp; 3.3 and Pygame 1.9</p>
<p>for Python 3.9 and Pygame 1.9</p>
<p>A simple, fast module for adding scrolling maps to your new or existing game.</p>
</div>
<div class="section" id="introduction">
Expand Down
Loading

0 comments on commit c4f14c2

Please sign in to comment.