summaryrefslogtreecommitdiff
path: root/pycameltris/screens
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2021-11-08 17:53:17 +0100
committerOlivier Gayot <olivier.gayot@sigexec.com>2021-11-08 22:05:55 +0100
commit1fe19d3e589bbc5d40b74d007d6b1984cfc34925 (patch)
tree11e63c628f5b8adc4f5711f02e98d555c572fe48 /pycameltris/screens
parentc51fd84bc896c74f291b4c5f2c73b5e5852de3e5 (diff)
Make controller classes and screen classes inherit from abstract classes
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'pycameltris/screens')
-rw-r--r--pycameltris/screens/InGame.py3
-rw-r--r--pycameltris/screens/Pause.py3
-rw-r--r--pycameltris/screens/Screen.py12
3 files changed, 16 insertions, 2 deletions
diff --git a/pycameltris/screens/InGame.py b/pycameltris/screens/InGame.py
index f865c77..aa3e53b 100644
--- a/pycameltris/screens/InGame.py
+++ b/pycameltris/screens/InGame.py
@@ -5,6 +5,7 @@ import sys
import pygame
+from .Screen import Screen
from ..piece import *
from ..controller import Input, KeyboardController, JoystickController
from ..misc import Pause
@@ -247,7 +248,7 @@ def handle_input_released(instance, players, event):
frames_per_gridcell = [48, 43, 38, 33, 28, 23, 18, 13, 8, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]
-class InGame:
+class InGame(Screen):
def __init__(self, players, screen):
self.players = players
self.screen = screen
diff --git a/pycameltris/screens/Pause.py b/pycameltris/screens/Pause.py
index f9f8859..baca5ca 100644
--- a/pycameltris/screens/Pause.py
+++ b/pycameltris/screens/Pause.py
@@ -3,6 +3,7 @@ import sys
import pygame
+from .Screen import Screen
from ..controller import KeyboardController, JoystickController, Input
from ..misc import UnPause
@@ -12,7 +13,7 @@ def handle_input_pressed(controller, event):
raise UnPause()
-class Pause:
+class Pause(Screen):
def __init__(self, screen):
self.event_handler = dict()
diff --git a/pycameltris/screens/Screen.py b/pycameltris/screens/Screen.py
new file mode 100644
index 0000000..01f80ab
--- /dev/null
+++ b/pycameltris/screens/Screen.py
@@ -0,0 +1,12 @@
+import abc
+
+
+class Screen(abc.ABC):
+ @abc.abstractmethod
+ def refresh(self):
+ pass
+
+ @abc.abstractmethod
+ def oneframe(self):
+ pass
+