doppler effect sketch

This commit is contained in:
Xevion
2019-11-02 15:43:15 -05:00
parent 401cdb52dc
commit b9d01927bd
3 changed files with 39 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
import random
x, y = random.randint(1,500), random.randint(1,500)
xSpeed, ySpeed = random.randint(1,3), random.randint(1,3)
def reverseX():
global xSpeed
xSpeed *= -1
def reverseY():
global ySpeed
ySpeed *= -1
def collision():
global x, y, xSpeed, ySpeed
if x < 0 or x > width:
reverseX()
print("X Collision at ({}, {})".format(x, y))
if y < 0 or y > height:
reverseY()
print("Y Collision at ({}, {})".format(x, y))
def tick():
global x,y, xSpeed, ySpeed
collision()
x += xSpeed
y += ySpeed
ellipse(x, y, 1, 1)
def setup():
size(500, 500)
def draw():
tick()

View File

@@ -0,0 +1,2 @@
mode=Python
mode.id=jycessing.mode.PythonMode

View File

@@ -6,4 +6,6 @@ Sketches that simulate physics or physical phenomena in some way or another.
## Sketches
- **Doppler_Effect** - Simulates the doppler effect with apparent high accuracy.
- **Doppler_Effect** - Simulates the doppler effect with apparent high accuracy.
- **ExtremelySimplePointCollision** - Simulates simplistic point collision on the sides of the sketch display window.