mirror of
https://github.com/Xevion/processing-projects.git
synced 2025-12-06 13:16:03 -06:00
doppler effect sketch
This commit is contained in:
@@ -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()
|
||||
|
||||
2
physics/ExtremelySimplePointCollision/sketch.properties
Normal file
2
physics/ExtremelySimplePointCollision/sketch.properties
Normal file
@@ -0,0 +1,2 @@
|
||||
mode=Python
|
||||
mode.id=jycessing.mode.PythonMode
|
||||
@@ -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.
|
||||
Reference in New Issue
Block a user