/
Suplin3
/
PySimulation
Обзор
Документация
Войти
/
Suplin3
/
PySimulation
Код
Запросы
0
Задачи
Пакеты
0
Релизы
1
Аналитика
Безопасность
master
main.py
57 строк
1 KB
Suplin3
delete wxgui
27 сен 2024, 23:25
27 сен 2024, 23:25
8a57449
Код
Авторство
О чём код?
import pygame as pg from phisycs import * import math import time import gui pg.init() screen = pg.display.set_mode((1080, 600), pg.RESIZABLE) pg.display.set_caption("PySimulation") time_interval = 10 # simulation time in seconds if __name__ == '__main__': testBall = Ball(Vector2(0, 0), 0.5) axes = gui.CoordAxes(oneStepPixels=50, stepsOn=True) yBall = Ball(Vector2(0, 0), 0.5) xBall = Ball(Vector2(0, 0), 0.5) start = time.perf_counter() while 1: screen.fill((50, 50, 50)) axes.draw(screen) t = time.perf_counter() - start if t >= time_interval: start = time.perf_counter() if testBall.pos.y < 0: start = time.perf_counter() testBall.throw(60, 14) testBall.calcPos(t) testBall.draw(screen, axes) xBall.pos.x = testBall.pos.x yBall.pos.y = testBall.pos.y xBall.draw(screen, axes) yBall.draw(screen, axes) axes.draw_vector(screen, testBall.speed.norm(), testBall.pos) pg.display.flip() for event in pg.event.get(): if event.type == pg.QUIT: pg.quit() exit() elif event.type == pg.VIDEORESIZE: width = min(10000, max(400, event.w)) height = min(10000, max(400, event.h)) if (width, height) != event.size: screen = pg.display.set_mode((width, height), pg.RESIZABLE)