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} #lever b = {'y':40,'press':1,'cou':'SB','on':0}# button kn = {'r':0,'bar':0,'turn':1,'on':0}#knob h = {'x':60,'grab':1,'col':105,'on':0}# horizontal lever ab = {'y1':590,'y2':590,'press1':1,'press2':1,'cou':'SB','on':0,'side':0} li = {'st':'...','pl':4,'cur':'','on':0}#letter input c = {'y1':840,'y2':840,'x':330,'grab':1,'press1':1,'press2':1,'order':'','cou':'SB','on':0}# combo mous = {'pr':0,'time':0}#mouse and timer start = {'a':0,'lives':3,'col':200}# menu and lives die = ['Hardcore','Hardcore','','','','']#just in case 4 modules activate in the same frame lol 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] sh = [4,10,16,22,28,34,40,46,52,58] sa1 = [1,1,2,2,3,3,4,4] sa2 = [1,1,2,2,3,3,4,4] te = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] cl = [1,2,3,4,5,6,8,9,10,11,12,14] cb1 = [1,1,2,2,3,3,4,4] cb2 = [1,1,2,2,3,3,4,4] cord = ['Button 1','Button 2','Lever Left','Lever Right'] def setup(): global title size(500,1050) background(200) title = loadImage('https://oyohub.s3.amazonaws.com/spriteeditor/projects/59ff7bf1ca292c38749df130/mttitle.gif') def mousePressed(): mous['pr'] = 1 def mouseReleased(): mous['pr'] = 0 def keyPressed(): if li['on'] > 0: if li['pl'] < 3: if keyboard.key == li['st'][li['pl']] and keyboard.key != ".": li['pl'] += 1 def draw(): background(start['col'],200-(start['col']-200),200-(start['col']-200)) if start['col'] > 200: start['col'] -= 1 if mous['pr'] > 0: mous['pr'] += 1 if mous['pr'] > 30: #hold number limit mous['pr'] = 30 if start['a'] == 1: #timer fill(100) rect(350,50,100,100) fill(50) rect(360,60,80,60) fill(0) rect(350,150,100,6) rect(360,60,80,3) text('tip:scroll down',300,175) pushMatrix() fill(0,240,0) textSize(30) textAlign(CENTER, CENTER) text(mous['time']/60,400,90) popMatrix() mous['time'] += 1 ellipseMode(CENTER,CENTER) fill(200,0,0) if start['lives'] == 0: fill(50) ellipse(375,135,20,20) if start['lives'] == 1: fill(50) ellipse(400,135,20,20) if start['lives'] == 2: fill(50) ellipse(425,135,20,20) #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']/2),60,l['on']/2) 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'] = 320 if l['on'] == 1: start['lives'] -= 1 start['col'] = 255 die[2-start['lives']] = 'Vertical Lever' if l['on'] > 0: 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']/9),30,b['on']/9) 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'] = 720 b['cou'] = 300 if b['on'] == 1: start['lives'] -= 1 start['col'] = 255 die[2-start['lives']] = 'Single Button' b['cou'] = 0 if b['on'] > 0: 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']/20),30,(kn['on']/20)) 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,1800) == 1: kn['on'] = 3600 if kn['on'] == 1: start['lives'] -= 1 start['col'] = 255 die[2-start['lives']] = 'The Knob' kn['bar'] = 0 if kn['on'] > 0: 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 #multitasking plus time #horizontal levers fill(100) rect(50,450,400,100) fill(150) rect(70,470,310,60) fill(105,h['col'],105) rect(390,460,50,80) fill(240,0,0) rect(390,460+(80-h['on']/6),50,h['on']/6) fill(0) rect(50,550,400,6) rect(70,470,310,3) rect(80,490,290,20) rect(390,460,50,3) fill(200,0,0) rect(h['x'],460,30,80) fill(200,50,50) rect(h['x'],440,30,80) if h['on'] == 0: if randint(1,400) == 1: h['on'] = 480 if h['on'] == 1: start['lives'] -= 1 start['col'] = 255 die[2-start['lives']] = 'Horizontal Lever' if h['on'] > 0: h['on'] -= 1 if mous['pr'] > 0 and h['grab'] == 1: if mouse.x > h['x'] - 20 and mouse.x < h['x'] + 50 and mouse.y > 440 and mouse.y < 550: h['x'] = mouse.x - 15 if h['x'] < 60: h['x'] = 60 elif h['x'] > 370: h['x'] = 370 if h['x'] == 370: h['grab'] = 0 h['col'] = 255 h['on'] = 0 if h['grab'] == 0: if len(sh) == 0: h['x'] = 60 h['grab'] = 1 h['col'] = 105 sh.append(8) sh.append(10) sh.append(16) sh.append(22) sh.append(28) sh.append(34) sh.append(40) sh.append(46) sh.append(52) sh.append(58) else: k = sh.pop() h['x'] -= k h['col'] -= k/2 #alternating buttons fill(100) rect(50,600,200,200) fill(200,0,0) rect(60,630,80,60)#1 rect(160,630,80,60)#2 fill(200,50,50) rect(60,ab['y1'],80,80)#1 rect(160,ab['y2'],80,80)#2 fill(50) rect(60,710,80,80) rect(160,710,80,35) rect(160,755,80,35) fill(240,0,0) rect(160,755,ab['on']/10,35) fill(0) rect(50,800,200,6) rect(60,710,80,3) rect(160,710,80,3) rect(160,755,80,3) fill(0,240,0) pushMatrix() textSize(30) textAlign(CENTER, CENTER) text(ab['cou'],100,750) popMatrix() if ab['on'] == 0: pass elif ab['side'] == 0: pushMatrix() textSize(30) textAlign(CENTER, CENTER) text('< ',200,728) popMatrix() elif ab['side'] == 1: pushMatrix() textSize(30) textAlign(CENTER, CENTER) text(' >',200,728) popMatrix() if ab['on'] == 0: if randint(1,700) == 1: ab['on'] = 800 ab['cou'] = 10 ab['side'] = randint(0,1) if ab['on'] == 1: start['lives'] -= 1 start['col'] = 255 die[2-start['lives']] = 'Alternating Buttons' ab['cou'] = 0 if ab['on'] > 1: ab['on'] -= 1 if ab['press1'] == 0: if len(sa1) == 0: ab['y1'] = 590 ab['press1'] = 1 sa1.append(1) sa1.append(1) sa1.append(2) sa1.append(2) sa1.append(3) sa1.append(3) sa1.append(4) sa1.append(4) else: k = sa1.pop() ab['y1'] -= k if ab['press2'] == 0: if len(sa2) == 0: ab['y2'] = 590 ab['press2'] = 1 sa2.append(1) sa2.append(1) sa2.append(2) sa2.append(2) sa2.append(3) sa2.append(3) sa2.append(4) sa2.append(4) else: k = sa2.pop() ab['y2'] -= k if mous['pr'] == 2 and ab['press1'] == 1: if mouse.x > 60 and mouse.y > 590 and mouse.x < 140 and mouse.y < 690: ab['y1'] = 610 ab['press1'] = 0 if str(ab['cou']).isdigit() and ab['side'] == 0: ab['cou'] -= 1 ab['side'] = 1 if mous['pr'] == 2 and ab['press2'] == 1: if mouse.x > 160 and mouse.y > 590 and mouse.x < 240 and mouse.y < 690: ab['y2'] = 610 ab['press2'] = 0 if str(ab['cou']).isdigit() and ab['side'] == 1: ab['cou'] -= 1 ab['side'] = 0 if ab['cou'] == 0: ab['cou'] = 'SB' ab['on'] = 0 #letter input fill(100) rect(300,600,150,200) fill(50) rect(310,610,130,80) rect(310,775,130,16) fill(150) for j in range(4): for i in range(10): rect(310+(i*13),710+(j*13),10,10) rect(336,762,75,10) fill(240,0,0) rect(310,775,li['on']/5,16) fill(0) rect(300,800,150,6) rect(310,610,130,3) rect(310,775,130,3) fill(0,240,0) pushMatrix() textSize(30) textAlign(CENTER, CENTER) text(li['st'][0],355,650) if li['pl'] < 1: fill(0,100,0) text(li['st'][1],375,650) if li['pl'] < 2: fill(0,100,0) text(li['st'][2],395,650) popMatrix() if li['on'] == 0: if randint(1,500) == 1: li['on'] = 650 li['st'] = te[randint(0,25)]+te[randint(0,25)]+te[randint(0,25)] li['pl'] = 0 if li['on'] == 1: start['lives'] -= 1 start['col'] = 255 die[2-start['lives']] = 'Letter Input' li['pl'] = 3 if li['on'] > 0: li['on'] -= 1 if li['pl'] == 3: li['pl'] = 4 li['on'] = 0 li['st'] = "..." #combo module fill(100) rect(50,850,400,150) fill(200,0,0) rect(60,880,80,60) rect(160,880,80,60) fill(200,50,50) rect(60,c['y1'],80,80)#1 rect(160,c['y2'],80,80)#2 fill(150) rect(260,870,170,60) fill(50) rect(60,960,180,30) rect(260,960,80,30) rect(350,960,80,30) fill(240,0,0) rect(350,960,c['on']/18,30) fill(0) rect(270,890,150,20) rect(50,1000,400,6) rect(260,870,170,3) rect(60,960,180,3) rect(260,960,80,3) rect(350,960,80,3) fill(200,0,0) rect(c['x'],860,30,80) fill(200,50,50) rect(c['x'],840,30,80) fill(0,240,0) pushMatrix() textSize(20) textAlign(CENTER, CENTER) text(c['order'],150,976) text(c['cou'],300,976) popMatrix() if c['on'] == 0: if randint(1,1600) == 1: c['on'] = 1440 c['order'] = cord[randint(0,3)] c['cou'] = 5 if c['on'] == 1: start['lives'] -= 1 start['col'] = 255 die[2-start['lives']] = 'Combo Module' c['cou'] = 0 if c['on'] > 0: c['on'] -= 1 if mouse.x > c['x'] - 25 and mouse.x < c['x'] + 55 and mouse.y > 860 and mouse.y < 920 and c['grab'] == 1 and mous['pr'] > 0: c['x'] = mouse.x - 15 if c['x'] > 410: c['x'] = 410 if c['x'] < 250: c['x'] = 250 if c['x'] == 410: c['grab'] = 0 if c['order'] == 'Lever Right' and c['on'] != 0: c['cou'] -= 1 c['order'] = cord[randint(0,3)] if c['x'] == 250: c['grab'] = 0 if c['order'] == 'Lever Left' and c['on'] != 0: c['cou'] -= 1 c['order'] = cord[randint(0,3)] if c['grab'] == 0: if c['x'] > 330: if len(cl) == 0: c['x'] = 330 cl.append(1) cl.append(2) cl.append(3) cl.append(4) cl.append(5) cl.append(6) cl.append(8) cl.append(9) cl.append(10) cl.append(11) cl.append(12) cl.append(14) c['grab'] = 1 else: k = cl.pop() c['x'] -= k else: if len(cl) == 0: c['x'] = 330 cl.append(1) cl.append(2) cl.append(3) cl.append(4) cl.append(5) cl.append(6) cl.append(8) cl.append(9) cl.append(10) cl.append(11) cl.append(12) cl.append(14) c['grab'] = 1 else: k = cl.pop() c['x'] += k if mouse.x > 60 and mouse.x < 140 and mouse.y > 840 and mouse.y < 940 and mous['pr'] == 2 and c['press1'] == 1: c['press1'] = 0 c['y1'] = 860 if c['order'] == 'Button 1' and c['on'] != 0: c['cou'] -= 1 c['order'] = cord[randint(0,3)] if c['press1'] == 0: if len(cb1) == 0: c['y1'] = 840 c['press1'] = 1 cb1.append(1) cb1.append(1) cb1.append(2) cb1.append(2) cb1.append(3) cb1.append(3) cb1.append(4) cb1.append(4) else: k = cb1.pop() c['y1'] -= k if mouse.x > 160 and mouse.x < 240 and mouse.y > 840 and mouse.y < 940 and mous['pr'] == 2 and c['press2'] == 1: c['press2'] = 0 c['y2'] = 860 if c['order'] == 'Button 2' and c['on'] != 0: c['cou'] -= 1 c['order'] = cord[randint(0,3)] if c['press2'] == 0: if len(cb2) == 0: c['y2'] = 840 c['press2'] = 1 cb2.append(1) cb2.append(1) cb2.append(2) cb2.append(2) cb2.append(3) cb2.append(3) cb2.append(4) cb2.append(4) else: k = cb2.pop() c['y2'] -= k if c['cou'] == 0: c['order'] = '' c['on'] = 0 c['cou'] = 'SB' #dededeath dededetection if start['lives'] < 1: background(150,50,50) fill(0) textSize(50) text('Game Over',250,400) textSize(40) text('Causes of Loss:',250,500) textSize(30) text('Life 1:'+die[0],250,600) text('Life 2:'+die[1],250,640) text('Life 3:'+die[2],250,680) textSize(40) text('Score:'+str(mous['time']/60),250,740) exitp() else: pushMatrix() textAlign(CENTER, CENTER) fill(100) rect(150,150,200,100) fill(150,100,100) rect(50,900,400,100) fill(0) rect(150,250,200,6) rect(50,1000,400,6) textSize(30) text('v v v How to play v v v',250,300) textSize(20) text('Goal: survive for as long as you can',250,400) text('by deactivating widgets.',250,420) text('Each widget is deactivated in a different way.',250,450) text("When a widget's timer runs out",250,490) text('(Indicated by the red bar next to it)',250,510) text('you lose a life. When you run out, you lose.',250,530) text('The amount of lives is indicated by',250,560) text('the red dots on the timer.',250,580) text('Your final score is the time on the timer.',250,610) textSize(15) text('(Tip 1: The timer is weird and ticks slower when you scroll.)',250,640) text('(Tip 2: You might not see all 7 widgets, scroll down.)',250,660) text("(Tip 3: Try to play on a real computer. It's a lot better.)",250,680) text('(Tip 4: Also, use a mouse.)',250,700) text('(Tip 5: Hold down the mouse button to spin the knob.)',250,720) text('(Tip 6: One of the widgets requires the keyboard. Can you guess which?)',250,740) textSize(50) fill(255) image(title,140,5,240,150) text('Play',250,200) text('Play Hardcore',250,950) popMatrix() if mouse.x > 150 and mouse.x < 350 and mouse.y > 150 and mouse.y < 250 and mous['pr'] == 2 and start['a'] == 0: start['a'] = 1 start['lives'] = 3 if mouse.x > 150 and mouse.x < 350 and mouse.y > 900 and mouse.y < 1000 and mous['pr'] == 2 and start['a'] == 0: start['a'] = 1 start['lives'] = 1 run()
multitaskplus.py
( around 667 lines python code )
Published By:
luyfru
Published on
2024-06-06T23:39:36Z
Python Mini
- an
OYOclass
application,
own your own class today
.
Run
Result
×
Error message shows here