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 = 500 height = 500 # http://tastyfruit.oyosite.com/cookie.png cookie = { 'x': 0, 'y': 0, 'w': 150, 'h': 150 } numCookies = 0 cookiesPerSec = 0 grandma = { 'x': 50, 'y': 200, 'w': 120, 'h': 25, 'text': "Grandma", 'amtPerSec': 1, 'price': 10, 'priceInc': 3, 'owned': 0 } farm = { 'x': 50, 'y': 250, 'w': 120, 'h': 25, 'text': "Farm", 'amtPerSec': 10, 'price': 100, 'priceInc': 30, 'owned': 0 } factory = { 'x': 50, 'y': 300, 'w': 120, 'h': 25, 'text': "Factory", 'amtPerSec': 100, 'price': 1000, 'priceInc': 100, 'owned': 0 } empire = { 'x': 50, 'y': 350, 'w': 120, 'h': 25, 'text': "Empire", 'amtPerSec': 1000, 'price': 10000, 'priceInc': 1000, 'owned': 0 } planet = { 'x': 50, 'y': 400, 'w': 120, 'h': 25, 'text': "Planet", 'amtPerSec': 10000, 'price': 100000, 'priceInc': 10000, 'owned': 0 } # List that hold all upgrades upgrades = [grandma, farm, factory, empire, planet] def setup(): size(width, height) cookie['img'] = loadImage("http://tastyfruit.oyosite.com/2018/cookie.png ") global lastSec lastSec = millis() def draw(): global numCookies, lastSec background(255, 255, 255) image(cookie['img'], cookie['x'], cookie['y'], cookie['w'], cookie['h']) #draw num cookies textSize(24) fill(0, 0, 0) text("Cookies: " + str(numCookies), 200, 50) text("Cookies Per Second: " + str(cookiesPerSec), 200, 100) text("Number of Grandmas: " + str(grandma['owned']), 200, 225) text("Number of Farms: " + str(farm['owned']), 200, 275) text("Number of Factories: " + str(factory['owned']), 200, 325) text("Number of Empires: " + str(empire['owned']), 200, 375) text("Number of Planets: " + str(planet['owned']), 200, 425) drawUpgrades() curr = millis() if curr >= lastSec +1000: numCookies += cookiesPerSec lastSec = curr def drawUpgrades(): for upg in upgrades: fill(0, 200, 0) stroke(0, 200, 0) rect(upg['x'], upg['y'], upg['w'], upg['h']) textSize(14) fill(255) text(upg['text'] + " - " + str(upg['price']), upg['x'] + 5, upg['y'] + 17) def mouseClicked(): global numCookies, cookiesPerSec if (cookie['x'] <= mouse.x <= cookie['x'] + cookie['w'] and cookie['y'] <= mouse.y <= cookie['y'] + cookie['h']): numCookies += 1 for upg in upgrades: if (upg['x'] <= mouse.x <= upg['x'] + upg['w'] and upg['y'] <= mouse.y <= upg['y'] + upg['h']): if numCookies >= upg['price']: numCookies -= upg['price'] upg['price'] += upg ['priceInc'] upg['owned'] += 1 cookiesPerSec += upg['amtPerSec'] run()
CookieClicker.py
( around 116 lines python code )
Published By:
James_da_boss
Published on
2018-08-07T15:23:17Z
Python Mini
- an
OYOclass
application,
own your own class today
.
Run
Result
×
Error message shows here