mirror of
https://github.com/Xevion/processing-projects.git
synced 2025-12-06 03:16:04 -06:00
DVD Logo sketch
This commit is contained in:
BIN
other/DVD Logo/dvd_logo/DVD_video_logo.png
Normal file
BIN
other/DVD Logo/dvd_logo/DVD_video_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
89
other/DVD Logo/dvd_logo/dvd_logo.pyde
Normal file
89
other/DVD Logo/dvd_logo/dvd_logo.pyde
Normal file
@@ -0,0 +1,89 @@
|
||||
from random import choice, randint
|
||||
import sys, os
|
||||
|
||||
def setup():
|
||||
readSettings()
|
||||
frameRate(45)
|
||||
size(1280, 720)
|
||||
fill(0, 0, 0)
|
||||
rect(0, 0, width, height)
|
||||
|
||||
global img, rectX, rectY
|
||||
rectX, rectY = randint(1, width-rectWidth), randint(1, height-rectHeight)
|
||||
img = loadImage("image.jpg")
|
||||
# img = loadImage("DVD_video_logo.png")
|
||||
|
||||
# Create and/or overwrite the settings.json file in the directory
|
||||
def createSettings():
|
||||
settingsJSON = {
|
||||
"height" : 1280,
|
||||
"width" : 720,
|
||||
"colorRGB" : [255, 255, 255]
|
||||
}
|
||||
with open(os.path.join(sys.path[2], 'settings.json'), 'w+') as settingsfile:
|
||||
json.dump(settingsfile, settingsJSON)
|
||||
|
||||
# Read the settings file, importing and setting the variables in the script to correlate
|
||||
def readSettings():
|
||||
try:
|
||||
with open(os.path.join(sys.path[2], 'settings.json'), 'r+') as settingsfile:
|
||||
data = json.load(settingsfile)
|
||||
setup(data["height"], data["width"])
|
||||
except IOError:
|
||||
print("No settings file found. Creating one now.")
|
||||
createSettings()
|
||||
os.exec()
|
||||
# print("Settings file created. Exiting program")
|
||||
# sys.exit()
|
||||
Xspeed, Yspeed = 5,5
|
||||
if(choice([True, False])):
|
||||
Xspeed *= -1
|
||||
if(choice([True, False])):
|
||||
Yspeed *= -1
|
||||
rectWidth, rectHeight = 600/2, 400/2
|
||||
renderpos = False
|
||||
count = 1
|
||||
|
||||
def collision():
|
||||
global Xspeed, Yspeed, rectX, rectWidth, rectY, rectHeight
|
||||
xcollide, ycollide = False, False
|
||||
if rectX <= 0 or rectX+rectWidth >= width:
|
||||
xcollide = True
|
||||
Xspeed *= -1
|
||||
if rectY <= 0 or rectY+rectHeight >= height:
|
||||
ycollide = True
|
||||
Yspeed *= -1
|
||||
if xcollide and ycollide:
|
||||
global count
|
||||
count +=1
|
||||
print("Corner hit while at ({}, {})".format(rectX, rectY))
|
||||
|
||||
def mouseClicked():
|
||||
global renderpos
|
||||
renderpos = not renderpos
|
||||
|
||||
def draw():
|
||||
global slope, rectX, rectY, rectWidth, rectHeight, Xspeed, Yspeed, renderpos, count
|
||||
rectX, rectY = rectX+Xspeed, rectY+Yspeed
|
||||
|
||||
if count > 0:
|
||||
fill(255,255,255)
|
||||
textAlign(CENTER)
|
||||
textSize(20)
|
||||
text("Corner Hits: " + str(count), 20, 20)
|
||||
|
||||
fill(0, 0, 0)
|
||||
rect(0, 0, width, height)
|
||||
|
||||
fill(255, 255, 255)
|
||||
image(img, rectX, rectY, rectWidth, rectHeight)
|
||||
# rect(rectX, rectY, rectWidth, rectHeight)
|
||||
if(renderpos):
|
||||
fill(255, 255, 255)
|
||||
textAlign(CENTER)
|
||||
textSize(20)
|
||||
x, y = rectX, rectY
|
||||
x2, y2 = rectX + (rectWidth)/2, rectY + (rectHeight)/2
|
||||
text("({}, {})".format(x, y), x, y)
|
||||
line(x2, y2, x2 + (Xspeed*500), y2 + (Yspeed*500))
|
||||
collision()
|
||||
BIN
other/DVD Logo/dvd_logo/image.jpg
Normal file
BIN
other/DVD Logo/dvd_logo/image.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
0
other/DVD Logo/dvd_logo/settings.json
Normal file
0
other/DVD Logo/dvd_logo/settings.json
Normal file
2
other/DVD Logo/dvd_logo/sketch.properties
Normal file
2
other/DVD Logo/dvd_logo/sketch.properties
Normal file
@@ -0,0 +1,2 @@
|
||||
mode=Python
|
||||
mode.id=jycessing.mode.PythonMode
|
||||
@@ -9,3 +9,5 @@ Other sketches without any specific purpose. If enough fit into a specific categ
|
||||
- **Chaser** A test demonstrating easing equations.
|
||||
|
||||
- **Clusters** A test of a simple clusterization algorithm.
|
||||
|
||||
- **DVD Logo** A fun little sketch displaying the iconic bouncing DVD Logo. May need a little more work to better visualize true-to-heart.
|
||||
Reference in New Issue
Block a user