initialized a knobs module

This commit is contained in:
2025-02-23 16:17:11 +01:00
parent a927fa8b90
commit d7d3603dc7
3 changed files with 23 additions and 2 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/__pycache__

13
knob.py Normal file
View File

@ -0,0 +1,13 @@
import pygame
class Knob:
def __init__(self, screen):
self.screen = screen
self.radius = screen.get_width()/20
self.fill_color = (255,0,255)
self.position = (screen.get_width()/2, screen.get_height()/2)
def display(self):
pygame.draw.circle(self.screen, self.fill_color , self.position, self.radius)

View File

@ -1,9 +1,14 @@
# Example file showing a basic pygame "game loop" # Example file showing a basic pygame "game loop"
import pygame import pygame
from knob import *
# pygame setup # pygame setup
pygame.init() pygame.init()
screen = pygame.display.set_mode((1280, 720)) screenW = 561
screenH = 325
screen = pygame.display.set_mode((screenW, screenH))
knob1 = Knob(screen)
clock = pygame.time.Clock() clock = pygame.time.Clock()
running = True running = True
@ -15,9 +20,11 @@ while running:
running = False running = False
# fill the screen with a color to wipe away anything from last frame # fill the screen with a color to wipe away anything from last frame
screen.fill("purple") screen.fill("black")
# RENDER YOUR GAME HERE # RENDER YOUR GAME HERE
knob1.display()
# flip() the display to put your work on screen # flip() the display to put your work on screen
pygame.display.flip() pygame.display.flip()