This repository has been archived on 2026-02-27. You can view files and clone it, but cannot push or open issues or pull requests.
Files
SpinTheSin/game.py

57 lines
1.7 KiB
Python

import math as maths
import logging
import pygame
import gameUtils
import NoPELib
import numpy as np
class Game(gameUtils.Game):
def __init__(self, *args, **kwargs):
"""
Ran when the game starts.
You have access to the following variables:
self.surf (pygame.Surface): This is the surface you draw onto.
self.pm (NoPELib.PlayerManager): This is where your players are stored.
self.cfg (dict): Everything from the `game.toml` file. You can access it like this: self.details['title']
"""
# Don't remove this. It does important things. :3
super().__init__(*args, **kwargs)
self.wheelSurf = pygame.Surface([min(self.size)]*2) # Don't ask.
items = [f'Example item {i+1}' for i in range(10)]
circleR = self.wheelSurf.size[0] / 2
pygame.draw.circle(self.wheelSurf, (100, 100, 100), (circleR, circleR), circleR)
for idx, item in enumerate(items):
scaledIdx = (idx / len(items)) * maths.pi * 2
vector = maths.cos(scaledIdx), maths.sin(scaledIdx)
endPos = np.add(np.multiply(vector, circleR), circleR)
pygame.draw.line(self.wheelSurf, (255, 255, 255), (circleR, circleR), endPos)
def onEvent(self, event):
"""
Ran when an event is fired.
Args:
event (pygame.Event): The event that was fired.
"""
pass
def update(self):
"""
Ran once per frame, put your drawing code and any
game logic that should be ran once per frame in here.
"""
self.surf.blit(gameUtils.centre(self.wheelSurf, self.size), (0, 0))
def close(self):
"""
Ran when the game closes.
"""
pass