Text Size
Text Size
Exit Full Screen
Python Mini
Show
Source Code
View Source Code in Full Screen
Open in New Tab
from processing import * from math import * from random import randint l = {'y':210,'grab':1,'col':105,'on':0} b = {'y':40,'press':1,'cou':'SB','on':0} kn = {'r':0,'bar':0,'on':0,'turn':1} mous = {'pr':0,'time':0} sl = [1,2,3,4,5,7,9,11,13,14,15,16,17,18,19] sb = [1,1,2,2,3,3,4,4] sk = [3,5,7,9,11,13,15,17] def setup(): size(500,500) background(200) def mousePressed(): mous['pr'] = 1 def mouseReleased(): mous['pr'] = 0 def draw(): background(200) if mous['pr'] > 0: mous['pr'] += 1 if mous['pr'] > 30: #hold number limit mous['pr'] = 30 #timer fill(100) rect(350,50,100,100) fill(50) rect(360,60,80,80) fill(0) rect(350,150,100,6) rect(360,60,80,3) pushMatrix() fill(0,240,0) textSize(30) textAlign(CENTER, CENTER) text(mous['time']/60,400,100) popMatrix() mous['time'] += 1 #lever stuff fill(100) rect(50,200,200,200) fill(150) rect(70,220,60,160) fill(105,l['col'],105) rect(170,220,60,160) fill(240,0,0) rect(170,220+(160-l['on']/1.5),60,l['on']/1.5) fill(0) rect(70,217,60,3) rect(170,217,60,3) rect(90,230,20,140) rect(50,400,200,6) fill(200,0,0) rect(60,l['y'],80,30) fill(200,50,50) rect(60,l['y']-15,80,30) if l['on'] == 0: if randint(1,400) == 1: l['on'] = 240 if l['on'] == 1: exit() if l['on'] > 1: l['on'] -= 1 if mous['pr'] > 0 and l['grab'] == 1: if mouse.y > l['y'] - 25 and mouse.y < l['y'] + 40 and mouse.x > 50 and mouse.x < 150: l['y'] = mouse.y - 15 if l['y'] < 210: l['y'] = 210 elif l['y'] > 360: l['y'] = 360 if l['y'] == 360: l['grab'] = 0 l['col'] = 255 l['on'] = 0 if l['grab'] == 0: if len(sl) == 0: l['y'] = 210 l['grab'] = 1 l['col'] = 105 sl.append(1) sl.append(2) sl.append(3) sl.append(4) sl.append(5) sl.append(7) sl.append(9) sl.append(11) sl.append(13) sl.append(14) sl.append(15) sl.append(16) sl.append(17) sl.append(18) sl.append(19) else: k = sl.pop() l['y'] -= k l['col'] -= k #button things fill(100) rect(50,50,250,100) fill(200,0,0) rect(60,80,80,60) fill(200,50,50) rect(60,b['y'],80,80) fill(50) rect(160,60,80,80) rect(260,60,30,80) fill(0) rect(50,150,250,6) rect(160,60,80,3) rect(260,60,30,3) fill(240,0,0) rect(260,140-(b['on']/7),30,b['on']/7) fill(0,240,0) pushMatrix() textSize(30) textAlign(CENTER, CENTER) text(b['cou'],200,100) popMatrix() if b['on'] == 0: if randint(1,600) == 1: b['on'] = 560 b['cou'] = 500 if b['on'] == 1: exit() if b['on'] > 1: b['on'] -= 1 if b['press'] == 0: if len(sb) == 0: b['y'] = 40 b['press'] = 1 sb.append(1) sb.append(1) sb.append(2) sb.append(2) sb.append(3) sb.append(3) sb.append(4) sb.append(4) else: k = sb.pop() b['y'] -= k if str(b['cou']).isdigit(): b['cou'] -= k if mous['pr'] == 2 and b['press'] == 1: if mouse.x > 60 and mouse.y > 40 and mouse.x < 140 and mouse.y < 140: b['y'] = 60 b['press'] = 0 if b['cou'] == 0: b['cou'] = 'SB' b['on'] = 0 #the nob lol fill(100) rect(300,200,150,200) fill(50) rect(310,310,80,80) rect(410,210,30,180) fill(0,240,0) rect(310,310+(80-kn['bar']),80,kn['bar']) fill(0) rect(300,400,150,6) rect(310,307,80,3) rect(410,210,30,3) fill(240,0,0) rect(410,390-(kn['on']/10),30,(kn['on']/10)) ellipseMode(CENTER, CENTER) fill(50) ellipse(350,250,80,80) beginShape() vertex(310,250) vertex(310,230) vertex(390,230) vertex(390,250) endShape() fill(60) ellipse(350,230,80,80) rectMode(CENTER, CENTER) fill(240) pushMatrix() translate(350,230) rotate(kn['r']) rect(0,0,70,5) popMatrix() rectMode(LEFT, TOP) if kn['on'] == 0: if randint(1,1200) == 1: kn['on'] = 1800 if kn['on'] == 1: exit() if kn['on'] > 1: kn['on'] -= 1 if mouse.x > 310 and mouse.x < 390 and mouse.y > 190 and mouse.y < 290 and mous['pr'] > 0 and kn['turn'] == 1: kn['r'] += PI/30 if kn['on'] > 0: kn['bar'] += .1 if kn['bar'] > 80: kn['bar'] = 80 if kn['bar'] == 80: kn['on'] = 0 kn['turn'] = 0 if kn['turn'] == 0: if len(sk) == 0: kn['bar'] = 0 kn['turn'] = 1 sk.append(3) sk.append(5) sk.append(7) sk.append(9) sk.append(11) sk.append(13) sk.append(15) sk.append(17) else: k = sk.pop() kn['bar'] -= k run()
multitask.py
( around 217 lines python code )
Published By:
luyfru
Published on
2024-06-06T23:39:13Z
Python Mini
- an
OYOclass
application,
own your own class today
.
Run
Result
×
Error message shows here