game: add: config
This commit is contained in:
parent
5db03a3c69
commit
072944c503
9
games/config.py
Normal file
9
games/config.py
Normal file
@ -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
|
@ -3,7 +3,9 @@ from django.conf import settings
|
|||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
|
|
||||||
from .viewset import GameViewSet
|
from .viewset import GameViewSet
|
||||||
|
from .views import GameConfigView
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("<int:pk>", GameViewSet.as_view({"get": "retrieve"}), name="game_page"),
|
path("<int:pk>", GameViewSet.as_view({"get": "retrieve"}), name="game_page"),
|
||||||
|
path("", GameConfigView.as_view(), name = "game_config")
|
||||||
]
|
]
|
23
games/views.py
Normal file
23
games/views.py
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user