diff --git a/games/config.py b/games/config.py new file mode 100644 index 0000000..feed4aa --- /dev/null +++ b/games/config.py @@ -0,0 +1,9 @@ +PADDLE_SPEED_MAX = 1 +PADDLE_SIZE_HEIGHT = 10 +PADDLE_SIZE_WIDTH = 100 + +PADDLE_RAIL = PADDLE_SIZE_WIDTH * 5 + +BALL_SPEED_INC = 1 +BALL_SPEED_START = 1 +BALL_SIZE = 4 diff --git a/games/urls.py b/games/urls.py index 96d61a8..8495b34 100644 --- a/games/urls.py +++ b/games/urls.py @@ -3,7 +3,9 @@ from django.conf import settings from django.conf.urls.static import static from .viewset import GameViewSet +from .views import GameConfigView urlpatterns = [ path("", GameViewSet.as_view({"get": "retrieve"}), name="game_page"), + path("", GameConfigView.as_view(), name = "game_config") ] \ No newline at end of file diff --git a/games/views.py b/games/views.py new file mode 100644 index 0000000..2675031 --- /dev/null +++ b/games/views.py @@ -0,0 +1,23 @@ +from rest_framework.views import APIView +from rest_framework.response import Response +from rest_framework import permissions, status + +from django.http import HttpRequest + +from . import config + +class GameConfigView(APIView): + + permission_classes = (permissions.AllowAny,) + + def get(self, request): + config_data = { + "BALL_SIZE": config.BALL_SIZE, + "PADDLE_SPEED_MAX": config.PADDLE_SPEED_MAX, + "PADDLE_SIZE_HEIGHT": config.PADDLE_SIZE_HEIGHT, + "PADDLE_SIZE_WIDTH": config.PADDLE_SIZE_WIDTH, + "PADDLE_RAIL": config.PADDLE_RAIL, + "BALL_SPEED_INC": config.BALL_SPEED_INC, + "BALL_SPEED_START": config.BALL_SPEED_START + } + return Response(config_data, status = status.HTTP_200_OK) \ No newline at end of file