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 * width = 550 height = 600 cookie = { 'x': 20, 'y': 20, 'w': 150, 'h': 150 } grandmaBtn = { 'x': 50, 'y': 200, 'w': 200, 'h': 25, 'text': "Moldy Cheese", 'amtPerSec': 1, 'price': 10, 'priceInc': 3, 'owned': 0 } farmBtn = { 'x': 50, 'y': 230, 'w': 200, 'h': 25, 'text': "Normal Cheese", 'amtPerSec': 10, 'price': 50, 'priceInc': 50, 'owned': 0 } factoryBtn = { 'x': 50, 'y': 260, 'w': 200, 'h': 25, 'text': "Very good cheese", 'amtPerSec': 100, 'price': 100, 'priceInc': 100, 'owned': 0 } massProductionBtn = { 'x': 50, 'y': 290, 'w': 200, 'h': 25, 'text': "Legendary cheese", 'amtPerSec': 1000, 'price': 500, 'priceInc': 500, 'owned': 0 } cookieGodBtn = { 'x': 50, 'y': 320, 'w': 200, 'h': 25, 'text': " Duplicate Ohio", 'amtPerSec': 10000000, 'price': 5000000, 'priceInc': 5000000, 'owned': 0 } btns = [grandmaBtn, farmBtn, factoryBtn, massProductionBtn, cookieGodBtn] numCookies = 0 cookiesPerSecond = 0 def setup(): global lastSec lastSec = millis() size(width, height) cookie['image'] = loadImage("https://gisgeography.com/wp-content/uploads/2020/02/Ohio-Map-1265x1312.jpg") def drawButtons(): for b in btns: fill(0, 255, 0) stroke(255, 0, 0) rect(b['x'], b['y'], b['w'], b['h']) textSize(14) fill(0, 50, 0) text(b['text'] + " - " + str(b['price']), b['x'] + 5, b['y'] + 17) fill(0) textSize(20) text("Owned: " + str(b['owned']), 255, b['y'] + 20) def calculatePassiveIncome(): global cookiesPerSecond total = 0 for b in btns: total += b['owned'] * b['amtPerSec'] cookiesPerSecond = total def draw(): global numCookies, lastSec background(255, 255, 255) image(cookie['image'], cookie['x'], cookie['y'], cookie['w'], cookie['h']) textSize(20) fill(0, 0, 0) text("Ohio: " + str(numCookies), 200, 50) text("Ohio per second: " + str(cookiesPerSecond), 200, 75) drawButtons() curr = millis() calculatePassiveIncome() if curr >= lastSec + 1000: numCookies += cookiesPerSecond lastSec = curr def mouseClicked(): global numCookies, cookiesPerSecond if (cookie['x'] <= mouse.x <= cookie['x'] + cookie['w'] and cookie['y'] <= mouse.y <= cookie['y'] + cookie['h']): numCookies += 1 for b in btns: if b['x'] <= mouse.x <= b['x'] + b['w'] and b['y'] <= mouse.y <= b['y'] + b['h']: if numCookies >= b['price']: numCookies -= b['price'] b['price'] += b['priceInc'] b['owned'] += 1 run()
Ohio_Clicker.py
( around 115 lines python code )
Published By:
Jaxol
Published on
2022-01-21T16:57:51Z
Python Mini
- an
OYOclass
application,
own your own class today
.
Run
Result
×
Error message shows here