2025-02-23 15:26:53 +01:00
|
|
|
import pygame
|
2025-02-23 16:17:11 +01:00
|
|
|
from knob import *
|
2025-02-23 15:26:53 +01:00
|
|
|
|
|
|
|
|
# pygame setup
|
|
|
|
|
pygame.init()
|
2025-02-23 16:17:11 +01:00
|
|
|
screenW = 561
|
|
|
|
|
screenH = 325
|
|
|
|
|
screen = pygame.display.set_mode((screenW, screenH))
|
2025-02-23 20:46:34 +01:00
|
|
|
|
2025-02-23 22:37:40 +01:00
|
|
|
color_primary = (0, 190, 180)
|
|
|
|
|
color_primary_light = (0, 255, 245)
|
2025-02-24 12:35:21 +01:00
|
|
|
color_primary_dark = (0, 110, 115)
|
2025-02-23 22:37:40 +01:00
|
|
|
|
2025-02-23 21:11:49 +01:00
|
|
|
# Create and position the knobs
|
2025-02-23 20:46:34 +01:00
|
|
|
knobs_radius = screenW / 25
|
|
|
|
|
knobs_spacing = knobs_radius * 2
|
|
|
|
|
knobs_x = (screenW - (knobs_radius + knobs_spacing) * 2) / 2
|
|
|
|
|
x = knobs_x
|
|
|
|
|
knobs_y = (screenH - (knobs_radius + knobs_spacing) * 3) / 2
|
|
|
|
|
y = knobs_y
|
|
|
|
|
knobs = []
|
|
|
|
|
for i in range(8):
|
2025-02-23 22:37:40 +01:00
|
|
|
knobs.append(Knob(screen, color_primary, knobs_radius, (x, y)))
|
2025-02-23 20:46:34 +01:00
|
|
|
y += knobs_radius + knobs_spacing
|
|
|
|
|
if i == 3 or i == 6:
|
|
|
|
|
x += knobs_radius + knobs_spacing
|
|
|
|
|
y = knobs_y
|
2025-02-23 16:17:11 +01:00
|
|
|
|
2025-02-23 22:37:40 +01:00
|
|
|
pygame.font.init() # you have to call this at the start,
|
|
|
|
|
# if you want to use this module.
|
|
|
|
|
font_helvetica = pygame.font.SysFont('Helvetica', 30)
|
|
|
|
|
|
2025-02-23 15:26:53 +01:00
|
|
|
clock = pygame.time.Clock()
|
|
|
|
|
running = True
|
|
|
|
|
|
2025-02-24 12:15:20 +01:00
|
|
|
def display_label(index):
|
|
|
|
|
fx_label = font_helvetica.render('REVERB WET', False, color_primary_light)
|
|
|
|
|
fx_value = font_helvetica.render('[ 86% ]', False, color_primary_light)
|
|
|
|
|
|
|
|
|
|
label_x = screenW - fx_label.get_width() - 20
|
|
|
|
|
label_y = (screenH - fx_label.get_height() - fx_value.get_height()) / 2
|
|
|
|
|
screen.blit(fx_label, (label_x, label_y))
|
|
|
|
|
screen.blit(fx_value, (label_x, screenH / 2))
|
2025-02-24 12:35:21 +01:00
|
|
|
pygame.draw.line(screen, color_primary_dark, (label_x - 10, label_y), (label_x - 10, screenH - label_y), 2)
|
2025-02-24 12:15:20 +01:00
|
|
|
|
|
|
|
|
line_points = []
|
|
|
|
|
line_points.append(knobs[index].get_position())
|
|
|
|
|
|
|
|
|
|
if (index == 0 or index == 1 or index == 4 or index == 5):
|
|
|
|
|
x = knobs[index].get_position()[0] + knobs_radius * 1.5
|
|
|
|
|
y = knobs[index].get_position()[1] + knobs_radius * 1.5
|
|
|
|
|
line_points.append((x, y))
|
|
|
|
|
elif (index == 2 or index == 3 or index == 6):
|
|
|
|
|
x = knobs[index].get_position()[0] + knobs_radius * 1.5
|
|
|
|
|
y = knobs[index].get_position()[1] - knobs_radius * 1.5
|
|
|
|
|
line_points.append((x, y))
|
|
|
|
|
elif (index == 7):
|
|
|
|
|
x = knobs[index].get_position()[0] - knobs_radius * 1.5
|
|
|
|
|
y = knobs[index].get_position()[1] + knobs_radius * 1.5
|
|
|
|
|
line_points.append((x, y))
|
|
|
|
|
|
|
|
|
|
if (index == 0 or index == 3):
|
|
|
|
|
line_points.append((knobs_x + knobs_radius * 1.5, screenH/2))
|
|
|
|
|
elif (index == 4 or index == 6 or index == 7):
|
|
|
|
|
line_points.append((knobs[4].get_position()[0] + knobs_radius * 1.5, screenH/2))
|
|
|
|
|
|
|
|
|
|
line_points.append((label_x - 10, screenH/2))
|
|
|
|
|
|
|
|
|
|
for i in range(len(line_points)-1):
|
2025-02-24 12:35:21 +01:00
|
|
|
pygame.draw.line(screen, color_primary_dark, line_points[i], line_points[i+1], 2)
|
2025-02-24 12:15:20 +01:00
|
|
|
|
|
|
|
|
knobs[index].set_value(0.86)
|
|
|
|
|
knobs[index].set_color(color_primary_light)
|
|
|
|
|
|
2025-02-23 15:26:53 +01:00
|
|
|
while running:
|
|
|
|
|
# poll for events
|
|
|
|
|
# pygame.QUIT event means the user clicked X to close your window
|
|
|
|
|
for event in pygame.event.get():
|
|
|
|
|
if event.type == pygame.QUIT:
|
|
|
|
|
running = False
|
|
|
|
|
|
|
|
|
|
# fill the screen with a color to wipe away anything from last frame
|
2025-02-23 16:17:11 +01:00
|
|
|
screen.fill("black")
|
2025-02-23 15:26:53 +01:00
|
|
|
|
|
|
|
|
# RENDER YOUR GAME HERE
|
2025-02-23 22:37:40 +01:00
|
|
|
|
2025-02-24 12:35:21 +01:00
|
|
|
display_label(4)
|
2025-02-23 22:37:40 +01:00
|
|
|
|
2025-02-23 20:46:34 +01:00
|
|
|
for i in range(8):
|
|
|
|
|
knobs[i].display()
|
2025-02-23 16:17:11 +01:00
|
|
|
|
2025-02-23 20:46:34 +01:00
|
|
|
pygame.draw.polygon(screen, "white", [(0, screenH/2), (screenW*3/19, screenH), (0, screenH)])
|
2025-02-23 15:26:53 +01:00
|
|
|
# flip() the display to put your work on screen
|
|
|
|
|
pygame.display.flip()
|
|
|
|
|
|
|
|
|
|
clock.tick(60) # limits FPS to 60
|
|
|
|
|
|
|
|
|
|
pygame.quit()
|