Added changable scale

This commit is contained in:
garrett 2024-10-24 09:38:37 -04:00
parent 41c2aecf88
commit fbc1849079
5 changed files with 42 additions and 27 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -22,6 +22,7 @@ class Slider:
pygame.draw.circle(screen, RED, (int(handle_x), self.rect.centery), self.rect.height // 2)
def handle_event(self, event):
print("hi")
if event.type == pygame.MOUSEBUTTONDOWN:
if self.rect.collidepoint(event.pos):
self.grabbed = True

View File

@ -1,12 +1,17 @@
import pygame
import sys
import math
from sensor import Sensor
from particle import Particle
from slider import Slider
SCREEN_WIDTH = 1352
SCREEN_HEIGHT = 878
scale = 1 * pow(10, -8)
sensor = Sensor((50*pow(10, -9)) / scale, (200 * pow(10,-9)) / scale, (300 * pow(10, -9)) / scale)
pygame.init()
pygame.display.set_caption("CytoSim")
@ -20,16 +25,25 @@ while True:
sys.exit()
if event.type == pygame.VIDEORESIZE:
screen = pygame.display.set_mode((event.w, event.h), pygame.RESIZABLE)
if event.type == pygame.MOUSEWHEEL:
print("SCROLL")
if event.y == 1:
scale = scale / 1.1
elif event.y == -1:
scale = scale * 1.1
x, y = screen.get_size()
screen.fill((0,0,105))
screen.fill((200,100,5))
sensor.generate(x, y, screen)
pygame.draw.circle(screen, (150,255,10), (x / 2, y /2), 3 * pow(10, -6) / scale)
pygame.draw.line(screen, (255,255,255), (x - (x * .1), y - (y * .1)), ((x - (x * .1)) - (1 * pow(10, -6) / scale), y - (y * .1)))
print((1 *pow(10, -6)) / scale)
print(scale)
#print((1 *pow(10, -6)) / scale)
pygame.display.update()