Created
June 7, 2023 07:58
-
-
Save RedBigz/2114e7410cc6d7da176a7924b81585a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This contains some of orteil's code, THIS IS NOT MINE! The 60FPS patch is mine however. | |
var CC60_Counter = 0 | |
Game.Logic=function() | |
{ | |
CC60_Counter += 30 / Game.fps | |
if (CC60_Counter >= 1) CC60_Counter = 0 | |
Game.bounds=Game.l.getBounds(); | |
if (!Game.OnAscend && Game.AscendTimer==0) | |
{ | |
for (var i in Game.Objects) | |
{ | |
if (Game.Objects[i].eachFrame && CC60_Counter == 0) Game.Objects[i].eachFrame(); | |
} | |
Game.UpdateSpecial(); | |
Game.UpdateGrandmapocalypse(); | |
//these are kinda fun | |
//if (Game.BigCookieState==2 && !Game.promptOn && Game.Scroll!=0) Game.ClickCookie(); | |
//if (Game.BigCookieState==1 && !Game.promptOn) Game.ClickCookie(); | |
//handle graphic stuff | |
if (Game.prefs.wobbly) | |
{ | |
if (Game.BigCookieState==1) Game.BigCookieSizeT=0.98; | |
else if (Game.BigCookieState==2) Game.BigCookieSizeT=1.05; | |
else Game.BigCookieSizeT=1; | |
Game.BigCookieSizeD+=(Game.BigCookieSizeT-Game.BigCookieSize)*0.75/Game.fps*30; | |
Game.BigCookieSizeD*=0.75; | |
Game.BigCookieSize+=Game.BigCookieSizeD; | |
Game.BigCookieSize=Math.max(0.1,Game.BigCookieSize); | |
} | |
else | |
{ | |
if (Game.BigCookieState==1) Game.BigCookieSize+=(0.98-Game.BigCookieSize)*0.5/Game.fps*30; | |
else if (Game.BigCookieState==2) Game.BigCookieSize+=(1.05-Game.BigCookieSize)*0.5/Game.fps*30; | |
else Game.BigCookieSize+=(1-Game.BigCookieSize)*0.5/Game.fps*30; | |
} | |
Game.particlesUpdate(); | |
if (Game.mousePointer) l('sectionLeft').style.cursor='pointer'; | |
else l('sectionLeft').style.cursor='auto'; | |
Game.mousePointer=0; | |
//handle milk and milk accessories | |
Game.milkProgress=Game.AchievementsOwned/25; | |
if (Game.milkProgress>=0.5) Game.Unlock('Kitten helpers'); | |
if (Game.milkProgress>=1) Game.Unlock('Kitten workers'); | |
if (Game.milkProgress>=2) Game.Unlock('Kitten engineers'); | |
if (Game.milkProgress>=3) Game.Unlock('Kitten overseers'); | |
if (Game.milkProgress>=4) Game.Unlock('Kitten managers'); | |
if (Game.milkProgress>=5) Game.Unlock('Kitten accountants'); | |
if (Game.milkProgress>=6) Game.Unlock('Kitten specialists'); | |
if (Game.milkProgress>=7) Game.Unlock('Kitten experts'); | |
if (Game.milkProgress>=8) Game.Unlock('Kitten consultants'); | |
if (Game.milkProgress>=9) Game.Unlock('Kitten assistants to the regional manager'); | |
if (Game.milkProgress>=10) Game.Unlock('Kitten marketeers'); | |
if (Game.milkProgress>=11) Game.Unlock('Kitten analysts'); | |
if (Game.milkProgress>=12) Game.Unlock('Kitten executives'); | |
if (Game.milkProgress>=13) Game.Unlock('Kitten admins'); | |
if (Game.milkProgress>=14) Game.Unlock('Kitten strategists'); | |
Game.milkH=Math.min(1,Game.milkProgress)*0.35; | |
Game.milkHd+=(Game.milkH-Game.milkHd)*0.02; | |
Game.Milk=Game.Milks[Math.min(Math.floor(Game.milkProgress),Game.Milks.length-1)]; | |
if (Game.autoclickerDetected>0) Game.autoclickerDetected--; | |
//handle research | |
if (Game.researchT>0) | |
{ | |
Game.researchT--; | |
} | |
if (Game.researchT==0 && Game.nextResearch) | |
{ | |
if (!Game.Has(Game.UpgradesById[Game.nextResearch].name)) | |
{ | |
Game.Unlock(Game.UpgradesById[Game.nextResearch].name); | |
Game.Notify(loc("Research complete"),loc("You have discovered: <b>%1</b>.",Game.UpgradesById[Game.nextResearch].dname),Game.UpgradesById[Game.nextResearch].icon); | |
} | |
Game.nextResearch=0; | |
Game.researchT=-1; | |
Game.recalculateGains=1; | |
} | |
//handle seasons | |
if (Game.seasonT>0) | |
{ | |
Game.seasonT--; | |
} | |
if (Game.seasonT<=0 && Game.season!='' && Game.season!=Game.baseSeason && !Game.Has('Eternal seasons')) | |
{ | |
Game.Notify(Game.seasons[Game.season].over,'',Game.seasons[Game.season].triggerUpgrade.icon); | |
if (Game.Has('Season switcher')) {Game.Unlock(Game.seasons[Game.season].trigger);Game.seasons[Game.season].triggerUpgrade.bought=0;} | |
Game.season=Game.baseSeason; | |
Game.seasonT=-1; | |
} | |
//press ctrl to bulk-buy 10, shift to bulk-buy 100 | |
if (!Game.promptOn) | |
{ | |
if ((Game.keys[16] || Game.keys[17]) && !Game.buyBulkShortcut) | |
{ | |
Game.buyBulkOld=Game.buyBulk; | |
if (Game.keys[16]) Game.buyBulk=100; | |
if (Game.keys[17]) Game.buyBulk=10; | |
Game.buyBulkShortcut=1; | |
Game.storeBulkButton(-1); | |
} | |
} | |
if ((!Game.keys[16] && !Game.keys[17]) && Game.buyBulkShortcut)//release | |
{ | |
Game.buyBulk=Game.buyBulkOld; | |
Game.buyBulkShortcut=0; | |
Game.storeBulkButton(-1); | |
} | |
//handle cookies | |
if (Game.recalculateGains) Game.CalculateGains(); | |
Game.Earn(Game.cookiesPs/Game.fps);//add cookies per second | |
//grow lumps | |
Game.doLumps(); | |
//minigames | |
for (var i in Game.Objects) | |
{ | |
var me=Game.Objects[i]; | |
if (Game.isMinigameReady(me) && me.minigame.logic && Game.ascensionMode!=1) me.minigame.logic(); | |
} | |
if (Game.specialTab!='' && Game.T%(Game.fps*3)==0) Game.ToggleSpecialMenu(1); | |
//wrinklers | |
if (Game.cpsSucked>0) | |
{ | |
Game.Dissolve((Game.cookiesPs/Game.fps)*Game.cpsSucked); | |
Game.cookiesSucked+=((Game.cookiesPs/Game.fps)*Game.cpsSucked); | |
//should be using one of the following, but I'm not sure what I'm using this stat for anymore | |
//Game.cookiesSucked=Game.wrinklers.reduce(function(s,w){return s+w.sucked;},0); | |
//for (var i in Game.wrinklers) {Game.cookiesSucked+=Game.wrinklers[i].sucked;} | |
} | |
//var cps=Game.cookiesPs+Game.cookies*0.01;//exponential cookies | |
//Game.Earn(cps/Game.fps);//add cookies per second | |
for (var i in Game.Objects) | |
{ | |
var me=Game.Objects[i]; | |
me.totalCookies+=(me.storedTotalCps*Game.globalCpsMult)/Game.fps; | |
} | |
if (Game.prefs.particles && Game.cookies && Game.T%Math.ceil(Game.fps/Math.min(10,Game.cookiesPs))==0) Game.particleAdd();//cookie shower | |
if (Game.T%(Game.fps*10)==0) Game.recalculateGains=1;//recalculate CpS every 10 seconds (for dynamic boosts such as Century egg) | |
/*===================================================================================== | |
UNLOCKING STUFF | |
=======================================================================================*/ | |
if (Game.T%(Game.fps)==0 && Math.random()<1/1000000) Game.Win('Just plain lucky');//1 chance in 1,000,000 every second achievement | |
if (Game.T%(Game.fps*5)==0 && Game.ObjectsById.length>0)//check some achievements and upgrades | |
{ | |
if (isNaN(Game.cookies)) {Game.cookies=0;Game.cookiesEarned=0;Game.recalculateGains=1;} | |
var timePlayed=new Date(); | |
timePlayed.setTime(Date.now()-Game.startDate); | |
if (!Game.fullDate || (Date.now()-Game.fullDate)>=365*24*60*60*1000) Game.Win('So much to do so much to see'); | |
if (Game.cookiesEarned>=1000000 && (Game.ascensionMode==1 || Game.resets==0))//challenge run or hasn't ascended yet | |
{ | |
if (timePlayed<=1000*60*35) Game.Win('Speed baking I'); | |
if (timePlayed<=1000*60*25) Game.Win('Speed baking II'); | |
if (timePlayed<=1000*60*15) Game.Win('Speed baking III'); | |
if (Game.cookieClicks<=15) Game.Win('Neverclick'); | |
if (Game.cookieClicks<=0) Game.Win('True Neverclick'); | |
if (Game.cookiesEarned>=1000000000 && Game.UpgradesOwned==0) Game.Win('Hardcore'); | |
} | |
for (var i in Game.UnlockAt) | |
{ | |
var unlock=Game.UnlockAt[i]; | |
if (Game.cookiesEarned>=unlock.cookies) | |
{ | |
var pass=1; | |
if (unlock.require && !Game.Has(unlock.require) && !Game.HasAchiev(unlock.require)) pass=0; | |
if (unlock.season && Game.season!=unlock.season) pass=0; | |
if (pass) {Game.Unlock(unlock.name);Game.Win(unlock.name);} | |
} | |
} | |
if (Game.Has('Golden switch')) Game.Unlock('Golden switch [off]'); | |
if (Game.Has('Shimmering veil') && !Game.Has('Shimmering veil [off]') && !Game.Has('Shimmering veil [on]')) {Game.Unlock('Shimmering veil [on]');Game.Upgrades['Shimmering veil [off]'].earn();} | |
if (Game.Has('Sugar craving')) Game.Unlock('Sugar frenzy'); | |
if (Game.Has('Classic dairy selection')) Game.Unlock('Milk selector'); | |
if (Game.Has('Basic wallpaper assortment')) Game.Unlock('Background selector'); | |
if (Game.Has('Golden cookie alert sound')) Game.Unlock('Golden cookie sound selector'); | |
if (Game.Has('Sound test')) Game.Unlock('Jukebox'); | |
if (Game.Has('Prism heart biscuits')) Game.Win('Lovely cookies'); | |
if (Game.season=='easter') | |
{ | |
var eggs=0; | |
for (var i in Game.easterEggs) | |
{ | |
if (Game.HasUnlocked(Game.easterEggs[i])) eggs++; | |
} | |
if (eggs>=1) Game.Win('The hunt is on'); | |
if (eggs>=7) Game.Win('Egging on'); | |
if (eggs>=14) Game.Win('Mass Easteria'); | |
if (eggs>=Game.easterEggs.length) Game.Win('Hide & seek champion'); | |
} | |
if (Game.Has('Fortune cookies')) | |
{ | |
var list=Game.Tiers['fortune'].upgrades; | |
var fortunes=0; | |
for (var i in list) | |
{ | |
if (Game.Has(list[i].name)) fortunes++; | |
} | |
if (fortunes>=list.length) Game.Win('O Fortuna'); | |
} | |
if (Game.Has('Legacy') && Game.ascensionMode!=1) | |
{ | |
Game.Unlock('Heavenly chip secret'); | |
if (Game.Has('Heavenly chip secret')) Game.Unlock('Heavenly cookie stand'); | |
if (Game.Has('Heavenly cookie stand')) Game.Unlock('Heavenly bakery'); | |
if (Game.Has('Heavenly bakery')) Game.Unlock('Heavenly confectionery'); | |
if (Game.Has('Heavenly confectionery')) Game.Unlock('Heavenly key'); | |
if (Game.Has('Heavenly key')) Game.Win('Wholesome'); | |
} | |
for (var i in Game.BankAchievements) | |
{ | |
if (Game.cookiesEarned>=Game.BankAchievements[i].threshold) Game.Win(Game.BankAchievements[i].name); | |
} | |
if (Game.elderWrath>=3) Game.Win('Grandmapocalypse'); | |
var buildingsOwned=0; | |
var mathematician=1; | |
var base10=1; | |
var minAmount=100000; | |
for (var i in Game.Objects) | |
{ | |
buildingsOwned+=Game.Objects[i].amount; | |
minAmount=Math.min(Game.Objects[i].amount,minAmount); | |
if (!Game.HasAchiev('Mathematician')) {if (Game.Objects[i].amount<Math.min(128,Math.pow(2,(Game.ObjectsById.length-Game.Objects[i].id)-1))) mathematician=0;} | |
if (!Game.HasAchiev('Base 10')) {if (Game.Objects[i].amount<(Game.ObjectsById.length-Game.Objects[i].id)*10) base10=0;} | |
} | |
if (minAmount>=1) Game.Win('One with everything'); | |
if (mathematician==1) Game.Win('Mathematician'); | |
if (base10==1) Game.Win('Base 10'); | |
if (minAmount>=100) {Game.Win('Centennial');Game.Unlock('Milk chocolate butter biscuit');} | |
if (minAmount>=150) {Game.Win('Centennial and a half');Game.Unlock('Dark chocolate butter biscuit');} | |
if (minAmount>=200) {Game.Win('Bicentennial');Game.Unlock('White chocolate butter biscuit');} | |
if (minAmount>=250) {Game.Win('Bicentennial and a half');Game.Unlock('Ruby chocolate butter biscuit');} | |
if (minAmount>=300) {Game.Win('Tricentennial');Game.Unlock('Lavender chocolate butter biscuit');} | |
if (minAmount>=350) {Game.Win('Tricentennial and a half');Game.Unlock('Synthetic chocolate green honey butter biscuit');} | |
if (minAmount>=400) {Game.Win('Quadricentennial');Game.Unlock('Royal raspberry chocolate butter biscuit');} | |
if (minAmount>=450) {Game.Win('Quadricentennial and a half');Game.Unlock('Ultra-concentrated high-energy chocolate butter biscuit');} | |
if (minAmount>=500) {Game.Win('Quincentennial');Game.Unlock('Pure pitch-black chocolate butter biscuit');} | |
if (minAmount>=550) {Game.Win('Quincentennial and a half');Game.Unlock('Cosmic chocolate butter biscuit');} | |
if (minAmount>=600) {Game.Win('Sexcentennial');Game.Unlock('Butter biscuit (with butter)');} | |
if (minAmount>=650) {Game.Win('Sexcentennial and a half');Game.Unlock('Everybutter biscuit');} | |
if (minAmount>=700) {Game.Win('Septcentennial');Game.Unlock('Personal biscuit');} | |
if (Game.handmadeCookies>=1000) {Game.Win('Clicktastic');Game.Unlock('Plastic mouse');} | |
if (Game.handmadeCookies>=100000) {Game.Win('Clickathlon');Game.Unlock('Iron mouse');} | |
if (Game.handmadeCookies>=10000000) {Game.Win('Clickolympics');Game.Unlock('Titanium mouse');} | |
if (Game.handmadeCookies>=1000000000) {Game.Win('Clickorama');Game.Unlock('Adamantium mouse');} | |
if (Game.handmadeCookies>=100000000000) {Game.Win('Clickasmic');Game.Unlock('Unobtainium mouse');} | |
if (Game.handmadeCookies>=10000000000000) {Game.Win('Clickageddon');Game.Unlock('Eludium mouse');} | |
if (Game.handmadeCookies>=1000000000000000) {Game.Win('Clicknarok');Game.Unlock('Wishalloy mouse');} | |
if (Game.handmadeCookies>=100000000000000000) {Game.Win('Clickastrophe');Game.Unlock('Fantasteel mouse');} | |
if (Game.handmadeCookies>=10000000000000000000) {Game.Win('Clickataclysm');Game.Unlock('Nevercrack mouse');} | |
if (Game.handmadeCookies>=1000000000000000000000) {Game.Win('The ultimate clickdown');Game.Unlock('Armythril mouse');} | |
if (Game.handmadeCookies>=100000000000000000000000) {Game.Win('All the other kids with the pumped up clicks');Game.Unlock('Technobsidian mouse');} | |
if (Game.handmadeCookies>=10000000000000000000000000) {Game.Win('One...more...click...');Game.Unlock('Plasmarble mouse');} | |
if (Game.handmadeCookies>=1000000000000000000000000000) {Game.Win('Clickety split');Game.Unlock('Miraculite mouse');} | |
if (Game.handmadeCookies>=100000000000000000000000000000) {Game.Win('Ain\'t that a click in the head');Game.Unlock('Aetherice mouse');} | |
if (Game.handmadeCookies>=10000000000000000000000000000000) {Game.Win('What\'s not clicking');Game.Unlock('Omniplast mouse');} | |
if (Game.cookiesEarned<Game.cookies) Game.Win('Cheated cookies taste awful'); | |
if (Game.Has('Skull cookies') && Game.Has('Ghost cookies') && Game.Has('Bat cookies') && Game.Has('Slime cookies') && Game.Has('Pumpkin cookies') && Game.Has('Eyeball cookies') && Game.Has('Spider cookies')) Game.Win('Spooky cookies'); | |
if (Game.wrinklersPopped>=1) Game.Win('Itchscratcher'); | |
if (Game.wrinklersPopped>=50) Game.Win('Wrinklesquisher'); | |
if (Game.wrinklersPopped>=200) Game.Win('Moistburster'); | |
if (Game.cookiesEarned>=1000000 && Game.Has('How to bake your dragon')) Game.Unlock('A crumbly egg'); | |
if (Game.cookiesEarned>=25 && Game.season=='christmas') Game.Unlock('A festive hat'); | |
if (Game.Has('Christmas tree biscuits') && Game.Has('Snowflake biscuits') && Game.Has('Snowman biscuits') && Game.Has('Holly biscuits') && Game.Has('Candy cane biscuits') && Game.Has('Bell biscuits') && Game.Has('Present biscuits')) Game.Win('Let it snow'); | |
if (Game.reindeerClicked>=1) Game.Win('Oh deer'); | |
if (Game.reindeerClicked>=50) Game.Win('Sleigh of hand'); | |
if (Game.reindeerClicked>=200) Game.Win('Reindeer sleigher'); | |
if (buildingsOwned>=100) Game.Win('Builder'); | |
if (buildingsOwned>=500) Game.Win('Architect'); | |
if (buildingsOwned>=1000) Game.Win('Engineer'); | |
if (buildingsOwned>=2500) Game.Win('Lord of Constructs'); | |
if (buildingsOwned>=5000) Game.Win('Grand design'); | |
if (buildingsOwned>=7500) Game.Win('Ecumenopolis'); | |
if (buildingsOwned>=10000) Game.Win('Myriad'); | |
if (Game.UpgradesOwned>=20) Game.Win('Enhancer'); | |
if (Game.UpgradesOwned>=50) Game.Win('Augmenter'); | |
if (Game.UpgradesOwned>=100) Game.Win('Upgrader'); | |
if (Game.UpgradesOwned>=200) Game.Win('Lord of Progress'); | |
if (Game.UpgradesOwned>=300) Game.Win('The full picture'); | |
if (Game.UpgradesOwned>=400) Game.Win('When there\'s nothing left to add'); | |
if (Game.UpgradesOwned>=500) Game.Win('Kaizen'); | |
if (Game.UpgradesOwned>=600) Game.Win('Beyond quality'); | |
if (Game.UpgradesOwned>=700) Game.Win('Oft we mar what\'s well'); | |
if (buildingsOwned>=4000 && Game.UpgradesOwned>=300) Game.Win('Polymath'); | |
if (buildingsOwned>=8000 && Game.UpgradesOwned>=400) Game.Win('Renaissance baker'); | |
if (!Game.HasAchiev('Jellicles')) | |
{ | |
var kittens=0; | |
for (var i=0;i<Game.UpgradesByPool['kitten'].length;i++) | |
{ | |
if (Game.Has(Game.UpgradesByPool['kitten'][i].name)) kittens++; | |
} | |
if (kittens>=10) Game.Win('Jellicles'); | |
} | |
if (Game.cookiesEarned>=1e14 && !Game.HasAchiev('You win a cookie')) {Game.Win('You win a cookie');Game.Earn(1);} | |
if (Game.shimmerTypes['golden'].n>=4) Game.Win('Four-leaf cookie'); | |
var grandmas=0; | |
for (var i in Game.GrandmaSynergies) | |
{ | |
if (Game.Has(Game.GrandmaSynergies[i])) grandmas++; | |
} | |
if (!Game.HasAchiev('Elder') && grandmas>=7) Game.Win('Elder'); | |
if (!Game.HasAchiev('Veteran') && grandmas>=14) Game.Win('Veteran'); | |
if (Game.Objects['Grandma'].amount>=6 && !Game.Has('Bingo center/Research facility') && Game.HasAchiev('Elder')) Game.Unlock('Bingo center/Research facility'); | |
if (Game.pledges>0) Game.Win('Elder nap'); | |
if (Game.pledges>=5) Game.Win('Elder slumber'); | |
if (Game.pledges>=10) Game.Unlock('Sacrificial rolling pins'); | |
if (Game.Objects['Cursor'].amount+Game.Objects['Grandma'].amount>=777) Game.Win('The elder scrolls'); | |
for (var i in Game.Objects) | |
{ | |
var it=Game.Objects[i]; | |
for (var ii in it.productionAchievs) | |
{ | |
if (it.totalCookies>=it.productionAchievs[ii].pow) Game.Win(it.productionAchievs[ii].achiev.name); | |
} | |
} | |
if (!Game.HasAchiev('Cookie-dunker') && Game.LeftBackground && Game.milkProgress>0.1 && (Game.LeftBackground.canvas.height*0.4+256/2-16)>((1-Game.milkHd)*Game.LeftBackground.canvas.height)) Game.Win('Cookie-dunker'); | |
//&& l('bigCookie').getBounds().bottom>l('milk').getBounds().top+16 && Game.milkProgress>0.1) Game.Win('Cookie-dunker'); | |
Game.runModHook('check'); | |
} | |
Game.cookiesd+=(Game.cookies-Game.cookiesd)*0.3; | |
if (Game.storeToRefresh) Game.RefreshStore(); | |
if (Game.upgradesToRebuild) Game.RebuildUpgrades(); | |
Game.updateShimmers(); | |
Game.updateBuffs(); | |
Game.UpdateTicker(); | |
} | |
if (Game.T%(Game.fps*2)==0) | |
{ | |
var title='Cookie Clicker'; | |
if (Game.season=='fools') title='Cookie Baker'; | |
document.title=(Game.OnAscend?(EN?'Ascending! ':(loc("Ascending")+' | ')):'')+loc("%1 cookie",LBeautify(Game.cookies))+' - '+title; | |
} | |
if (Game.T%15==0) | |
{ | |
//written through the magic of "hope for the best" maths | |
var chipsOwned=Game.HowMuchPrestige(Game.cookiesReset); | |
var ascendNowToOwn=Math.floor(Game.HowMuchPrestige(Game.cookiesReset+Game.cookiesEarned)); | |
var ascendNowToGet=ascendNowToOwn-Math.floor(chipsOwned); | |
var nextChipAt=Game.HowManyCookiesReset(Math.floor(chipsOwned+ascendNowToGet+1))-Game.HowManyCookiesReset(Math.floor(chipsOwned+ascendNowToGet)); | |
var cookiesToNext=Game.HowManyCookiesReset(ascendNowToOwn+1)-(Game.cookiesEarned+Game.cookiesReset); | |
var percent=1-(cookiesToNext/nextChipAt); | |
//fill the tooltip under the Legacy tab | |
var date=new Date(); | |
date.setTime(Date.now()-Game.startDate); | |
var timeInSeconds=date.getTime()/1000; | |
var startDate=Game.sayTime(timeInSeconds*Game.fps,-1); | |
var str=''; | |
if (EN) str+='You\'ve been on this run for <b>'+(startDate==''?'not very long':(startDate))+'</b>.<br>'; | |
else str+=loc("You've been on this run for <b>%1</b>.",startDate)+'<br>'; | |
str+='<div class="line"></div>'; | |
if (Game.prestige>0) | |
{ | |
str+=loc("Your prestige level is currently <b>%1</b>.<br>(CpS +%2%)",[Beautify(Game.prestige),Beautify(Game.prestige)]); | |
str+='<div class="line"></div>'; | |
} | |
if (ascendNowToGet<1) str+=loc("Ascending now would grant you no prestige."); | |
else if (ascendNowToGet<2) str+=loc("Ascending now would grant you<br><b>1 prestige level</b> (+1% CpS)<br>and <b>1 heavenly chip</b> to spend."); | |
else str+=loc("Ascending now would grant you<br><b>%1 prestige levels</b> (+%2% CpS)<br>and <b>%3 heavenly chips</b> to spend.",[Beautify(ascendNowToGet),Beautify(ascendNowToGet),Beautify(ascendNowToGet)]); | |
if (cookiesToNext>=0) | |
{ | |
//note: cookiesToNext can be negative at higher HC amounts due to precision loss. we simply hide it in such cases, as this usually only occurs when the gap is small and rapidly overcome anyway | |
str+='<div class="line"></div>'; | |
str+=loc("You need <b>%1 more cookies</b> for the next level.",Beautify(cookiesToNext))+'<br>'; | |
} | |
l('ascendTooltip').innerHTML=str; | |
if (ascendNowToGet>0)//show number saying how many chips you'd get resetting now | |
{ | |
Game.ascendNumber.textContent='+'+SimpleBeautify(ascendNowToGet); | |
Game.ascendNumber.style.display='block'; | |
} | |
else | |
{ | |
Game.ascendNumber.style.display='none'; | |
} | |
if (ascendNowToGet>Game.ascendMeterLevel || Game.ascendMeterPercentT<Game.ascendMeterPercent) | |
{ | |
//reset the gauge and play a sound if we gained a potential level | |
Game.ascendMeterPercent=0; | |
//PlaySound('snd/levelPrestige.mp3');//a bit too annoying | |
} | |
Game.ascendMeterLevel=ascendNowToGet; | |
Game.ascendMeterPercentT=percent;//gauge that fills up as you near your next chip | |
//if (Game.ascendMeterPercentT<Game.ascendMeterPercent) {Game.ascendMeterPercent=0;PlaySound('snd/levelPrestige.mp3',0.5);} | |
//if (percent>=1) {Game.ascendMeter.className='';} else Game.ascendMeter.className='filling'; | |
} | |
//Game.ascendMeter.style.right=Math.floor(Math.max(0,1-Game.ascendMeterPercent)*100)+'px'; | |
Game.ascendMeter.style.backgroundPosition=(-Game.T*0.5-Game.ascendMeterPercent*100)+'px'; | |
Game.ascendMeter.style.transform='translate('+Math.floor(-Math.max(0,1-Game.ascendMeterPercent)*100)+'%,0px)'; | |
Game.ascendMeterPercent+=(Game.ascendMeterPercentT-Game.ascendMeterPercent)*0.1; | |
Game.NotesLogic(); | |
if (Game.mouseMoved || Game.Scroll || Game.tooltip.dynamic) Game.tooltip.update(); | |
if (Game.T%(Game.fps*5)==0 && !Game.mouseDown && (Game.onMenu=='stats' || Game.onMenu=='prefs')) Game.UpdateMenu(); | |
if (Game.T%(Game.fps*1)==0) Game.UpdatePrompt(); | |
if (Game.AscendTimer>0) Game.UpdateAscendIntro(); | |
if (Game.ReincarnateTimer>0) Game.UpdateReincarnateIntro(); | |
if (Game.OnAscend) Game.UpdateAscend(); | |
Game.runModHook('logic'); | |
if (Game.sparklesT>0) | |
{ | |
Game.sparkles.style.backgroundPosition=-Math.floor((Game.sparklesFrames-Game.sparklesT+1)*128)+'px 0px'; | |
Game.sparklesT--; | |
if (Game.sparklesT==1) Game.sparkles.style.display='none'; | |
} | |
Game.Click=0; | |
Game.Scroll=0; | |
Game.mouseMoved=0; | |
Game.CanClick=1; | |
if ((Game.toSave || (Game.T%(Game.fps*60)==0 && Game.T>Game.fps*10 && Game.prefs.autosave)) && !Game.OnAscend) | |
{ | |
//check if we can save : no minigames are loading | |
var canSave=true; | |
for (var i in Game.Objects) | |
{ | |
var me=Game.Objects[i]; | |
if (me.minigameLoading){canSave=false;break;} | |
} | |
if (canSave) Game.WriteSave(); | |
} | |
if (!Game.toSave && !Game.isSaving) | |
{ | |
if (Game.toReload) {Game.toReload=false;if (!App){location.reload();}else{App.reload();}} | |
if (Game.toQuit) {Game.toQuit=false;if (!App){window.close();}else{App.quit();}} | |
} | |
if (App && App.logic) App.logic(Game.T); | |
//every hour: get server data (ie. update notification, patreon, steam etc) | |
if (Game.T%(Game.fps*60*60)==0 && Game.T>Game.fps*10/* && Game.prefs.autoupdate*/) {Game.CheckUpdates();Game.GrabData();} | |
Game.T++; | |
} | |
Game.particlesUpdate=function() | |
{ | |
for (var i=0;i<Game.particlesN;i++) | |
{ | |
var me=Game.particles[i]; | |
if (me.life!=-1) | |
{ | |
if (!me.text) me.yd+=0.2+Math.random()*0.1; | |
me.x+=me.xd/Game.fps*30; | |
me.y+=me.yd/Game.fps*30; | |
//me.y+=me.life*0.25+Math.random()*0.25; | |
me.life += 1/30*Game.fps; | |
if (me.life>=Game.fps*me.dur) | |
{ | |
me.life=-1/30*Game.fps; | |
} | |
} | |
} | |
} | |
Game.DrawBackground=function() | |
{ | |
Timer.clean(); | |
//background | |
if (!Game.Background)//init some stuff | |
{ | |
Game.Background=l('backgroundCanvas').getContext('2d'); | |
Game.Background.canvas.width=Game.Background.canvas.parentNode.offsetWidth; | |
Game.Background.canvas.height=Game.Background.canvas.parentNode.offsetHeight; | |
Game.LeftBackground=l('backgroundLeftCanvas').getContext('2d'); | |
Game.LeftBackground.canvas.width=Game.LeftBackground.canvas.parentNode.offsetWidth; | |
Game.LeftBackground.canvas.height=Game.LeftBackground.canvas.parentNode.offsetHeight; | |
//preload ascend animation bits so they show up instantly | |
Game.LeftBackground.globalAlpha=0; | |
Game.LeftBackground.drawImage(Pic('brokenCookie.png'),0,0); | |
Game.LeftBackground.drawImage(Pic('brokenCookieHalo.png'),0,0); | |
Game.LeftBackground.drawImage(Pic('starbg.jpg'),0,0); | |
window.addEventListener('resize',function(event) | |
{ | |
Game.Background.canvas.width=Game.Background.canvas.parentNode.offsetWidth; | |
Game.Background.canvas.height=Game.Background.canvas.parentNode.offsetHeight; | |
Game.LeftBackground.canvas.width=Game.LeftBackground.canvas.parentNode.offsetWidth; | |
Game.LeftBackground.canvas.height=Game.LeftBackground.canvas.parentNode.offsetHeight; | |
}); | |
} | |
var ctx=Game.LeftBackground; | |
if (Game.OnAscend) | |
{ | |
Timer.clean(); | |
//starry background on ascend screen | |
var w=Game.Background.canvas.width; | |
var h=Game.Background.canvas.height; | |
var b=Game.ascendl.getBounds(); | |
var x=(b.left+b.right)/2; | |
var y=(b.top+b.bottom)/2; | |
Game.Background.globalAlpha=0.5; | |
var s=1*Game.AscendZoom*(1+Math.cos(Game.T*0.0027)*0.05); | |
Game.Background.fillPattern(Pic('starbg.jpg'),0,0,w,h,1024*s,1024*s,x+Game.AscendOffX*0.25*s,y+Game.AscendOffY*0.25*s); | |
Timer.track('star layer 1'); | |
if (Game.prefs.fancy) | |
{ | |
//additional star layer | |
Game.Background.globalAlpha=0.5*(0.5+Math.sin(Game.T*0.02)*0.3); | |
var s=2*Game.AscendZoom*(1+Math.sin(Game.T*0.002)*0.07); | |
//Game.Background.globalCompositeOperation='lighter'; | |
Game.Background.fillPattern(Pic('starbg.jpg'),0,0,w,h,1024*s,1024*s,x+Game.AscendOffX*0.25*s,y+Game.AscendOffY*0.25*s); | |
//Game.Background.globalCompositeOperation='source-over'; | |
Timer.track('star layer 2'); | |
x=x+Game.AscendOffX*Game.AscendZoom; | |
y=y+Game.AscendOffY*Game.AscendZoom; | |
//wispy nebula around the center | |
Game.Background.save(); | |
Game.Background.globalAlpha=0.5; | |
Game.Background.translate(x,y); | |
Game.Background.globalCompositeOperation='lighter'; | |
Game.Background.rotate(Game.T*0.001); | |
s=(600+150*Math.sin(Game.T*0.007))*Game.AscendZoom; | |
Game.Background.drawImage(Pic('heavenRing1.jpg'),-s/2,-s/2,s,s); | |
Game.Background.rotate(-Game.T*0.0017); | |
s=(600+150*Math.sin(Game.T*0.0037))*Game.AscendZoom; | |
Game.Background.drawImage(Pic('heavenRing2.jpg'),-s/2,-s/2,s,s); | |
Game.Background.restore(); | |
Timer.track('nebula'); | |
//Game.Background.drawImage(Pic('shadedBorders.png'),0,0,w,h); | |
//Timer.track('border'); | |
} | |
} | |
else | |
{ | |
var goodBuff=0; | |
var badBuff=0; | |
for (var i in Game.buffs) | |
{ | |
if (Game.buffs[i].aura==1) goodBuff=1; | |
if (Game.buffs[i].aura==2) badBuff=1; | |
} | |
if (Game.drawT%5==0) | |
{ | |
if (false && Game.bgType!=0 && Game.ascensionMode!=1) | |
{ | |
//l('backgroundCanvas').style.background='url('+Game.resPath+'img/shadedBordersSoft.png) 0px 0px,url('+Game.resPath+'img/bgWheat.jpg) 50% 50%'; | |
//l('backgroundCanvas').style.backgroundSize='100% 100%,cover'; | |
} | |
else | |
{ | |
l('backgroundCanvas').style.background='transparent'; | |
Game.defaultBg='bgBlue'; | |
Game.bgR=0; | |
if (Game.season=='fools') Game.defaultBg='bgMoney'; | |
if (Game.elderWrathD<1 || Game.prefs.notScary) | |
{ | |
Game.bgR=0; | |
Game.bg=Game.defaultBg; | |
Game.bgFade=Game.defaultBg; | |
} | |
else if (Game.elderWrathD>=1 && Game.elderWrathD<2) | |
{ | |
Game.bgR=(Game.elderWrathD-1)/1; | |
Game.bg=Game.defaultBg; | |
Game.bgFade='grandmas1'; | |
} | |
else if (Game.elderWrathD>=2 && Game.elderWrathD<3) | |
{ | |
Game.bgR=(Game.elderWrathD-2)/1; | |
Game.bg='grandmas1'; | |
Game.bgFade='grandmas2'; | |
} | |
else if (Game.elderWrathD>=3)// && Game.elderWrathD<4) | |
{ | |
Game.bgR=(Game.elderWrathD-3)/1; | |
Game.bg='grandmas2'; | |
Game.bgFade='grandmas3'; | |
} | |
if (Game.bgType!=0 && Game.ascensionMode!=1) | |
{ | |
Game.bgR=0; | |
Game.bg=Game.BGsByChoice[Game.bgType].pic; | |
Game.bgFade=Game.bg; | |
} | |
Game.Background.fillPattern(Pic(Game.bg+'.jpg'),0,0,Game.Background.canvas.width,Game.Background.canvas.height,512,512,0,0); | |
if (Game.bgR>0) | |
{ | |
Game.Background.globalAlpha=Game.bgR; | |
Game.Background.fillPattern(Pic(Game.bgFade+'.jpg'),0,0,Game.Background.canvas.width,Game.Background.canvas.height,512,512,0,0); | |
} | |
Game.Background.globalAlpha=1; | |
Game.Background.drawImage(Pic('shadedBordersSoft.png'),0,0,Game.Background.canvas.width,Game.Background.canvas.height); | |
} | |
} | |
Timer.track('window background'); | |
//clear | |
ctx.clearRect(0,0,ctx.canvas.width,ctx.canvas.height); | |
/*if (Game.AscendTimer<Game.AscendBreakpoint) ctx.clearRect(0,0,ctx.canvas.width,ctx.canvas.height); | |
else | |
{ | |
ctx.globalAlpha=0.05; | |
ctx.fillStyle='#000'; | |
ctx.fillRect(0,0,ctx.canvas.width,ctx.canvas.height); | |
ctx.globalAlpha=1; | |
OldCanvasDrawImage.apply(ctx,[ctx.canvas,Math.random()*4-2,Math.random()*4-2-4]); | |
ctx.globalAlpha=1; | |
}*/ | |
Timer.clean(); | |
var showDragon=0; | |
if (Game.hasBuff('Dragonflight') || Game.hasBuff('Dragon Harvest')) showDragon=1; | |
Game.cookieOriginX=Math.floor(ctx.canvas.width/2); | |
Game.cookieOriginY=Math.floor(ctx.canvas.height*0.4); | |
if (Game.AscendTimer==0) | |
{ | |
if (Game.prefs.particles) | |
{ | |
//falling cookies | |
var pic=''; | |
var opacity=1; | |
if (Game.elderWrathD<=1.5 || Game.prefs.notScary) | |
{ | |
if (Game.cookiesPs>=1000) pic='cookieShower3.png'; | |
else if (Game.cookiesPs>=500) pic='cookieShower2.png'; | |
else if (Game.cookiesPs>=50) pic='cookieShower1.png'; | |
else pic=''; | |
} | |
if (pic!='') | |
{ | |
if (Game.elderWrathD>=1 && !Game.prefs.notScary) opacity=1-((Math.min(Game.elderWrathD,1.5)-1)/0.5); | |
ctx.globalAlpha=opacity; | |
var y=(Math.floor(Game.T/Game.fps*30*2)%512); | |
ctx.fillPattern(Pic(pic),0,0,ctx.canvas.width,ctx.canvas.height+512,512,512,0,y); | |
ctx.globalAlpha=1; | |
} | |
//snow | |
if (Game.season=='christmas') | |
{ | |
var y=(Math.floor(Game.T/Game.fps*30*2.5)%512); | |
ctx.globalAlpha=0.75; | |
ctx.globalCompositeOperation='lighter'; | |
ctx.fillPattern(Pic('snow2.jpg'),0,0,ctx.canvas.width,ctx.canvas.height+512,512,512,0,y); | |
ctx.globalCompositeOperation='source-over'; | |
ctx.globalAlpha=1; | |
} | |
//hearts | |
if (Game.season=='valentines') | |
{ | |
var y=(Math.floor(Game.T/Game.fps*30*2.5)%512); | |
ctx.globalAlpha=1; | |
ctx.fillPattern(Pic('heartStorm.png'),0,0,ctx.canvas.width,ctx.canvas.height+512,512,512,0,y); | |
ctx.globalAlpha=1; | |
} | |
Timer.track('left background'); | |
Game.particlesDraw(0); | |
ctx.globalAlpha=1; | |
Timer.track('particles'); | |
//big cookie shine | |
var s=512; | |
var x=Game.cookieOriginX; | |
var y=Game.cookieOriginY; | |
var r=Math.floor((Game.T/Game.fps*30*0.5)%360); | |
ctx.save(); | |
ctx.translate(x,y); | |
ctx.rotate((r/360)*Math.PI*2); | |
var alphaMult=1; | |
if (Game.bgType==2 || Game.bgType==4) alphaMult=0.5; | |
var pic='shine.png'; | |
if (goodBuff) {pic='shineGold.png';alphaMult=1;} | |
else if (badBuff) {pic='shineRed.png';alphaMult=1;} | |
if (goodBuff && Game.prefs.fancy) ctx.globalCompositeOperation='lighter'; | |
ctx.globalAlpha=0.5*alphaMult; | |
ctx.drawImage(Pic(pic),-s/2,-s/2,s,s); | |
ctx.rotate((-r*2/360)*Math.PI*2); | |
ctx.globalAlpha=0.25*alphaMult; | |
ctx.drawImage(Pic(pic),-s/2,-s/2,s,s); | |
ctx.restore(); | |
Timer.track('shine'); | |
if (Game.ReincarnateTimer>0) | |
{ | |
ctx.globalAlpha=1-Game.ReincarnateTimer/Game.ReincarnateDuration; | |
ctx.fillStyle='#000'; | |
ctx.fillRect(0,0,ctx.canvas.width,ctx.canvas.height); | |
ctx.globalAlpha=1; | |
} | |
if (showDragon) | |
{ | |
//big dragon | |
var s=300*2*(1+Math.sin(Game.T*0.013)*0.1); | |
var x=Game.cookieOriginX-s/2; | |
var y=Game.cookieOriginY-s/(1.4+0.2*Math.sin(Game.T*0.01)); | |
ctx.drawImage(Pic('dragonBG.png'),x,y,s,s); | |
} | |
//big cookie | |
if (false)//don't do that | |
{ | |
ctx.globalAlpha=1; | |
var amount=Math.floor(Game.cookies).toString(); | |
var digits=amount.length; | |
var space=0; | |
for (var i=0;i<digits;i++) | |
{ | |
var s=16*(digits-i); | |
var num=parseInt(amount[i]); | |
if (i>0) space-=s*(1-num/10)/2; | |
if (i==0 && num>1) space+=s*0.1; | |
for (var ii=0;ii<num;ii++) | |
{ | |
var x=Game.cookieOriginX; | |
var y=Game.cookieOriginY; | |
var spin=Game.T*(0.005+i*0.001)+i+(ii/num)*Math.PI*2; | |
x+=Math.sin(spin)*space; | |
y+=Math.cos(spin)*space; | |
ctx.drawImage(Pic('perfectCookie.png'),x-s/2,y-s/2,s,s); | |
} | |
space+=s/2; | |
} | |
} | |
else | |
{ | |
ctx.globalAlpha=1; | |
var s=256*Game.BigCookieSize; | |
var x=Game.cookieOriginX; | |
var y=Game.cookieOriginY; | |
ctx.save(); | |
if (Game.prefs.fancy) ctx.drawImage(Pic('cookieShadow.png'),x-s/2,y-s/2+20,s,s); | |
ctx.translate(x,y); | |
if (Game.season=='easter') | |
{ | |
var nestW=304*0.98*Game.BigCookieSize; | |
var nestH=161*0.98*Game.BigCookieSize; | |
ctx.drawImage(Pic('nest.png'),-nestW/2,-nestH/2+130,nestW,nestH); | |
} | |
//ctx.rotate(((Game.startDate%360)/360)*Math.PI*2); | |
ctx.drawImage(Pic('perfectCookie.png'),-s/2,-s/2,s,s); | |
if (goodBuff && Game.prefs.particles)//sparkle | |
{ | |
ctx.globalCompositeOperation='lighter'; | |
for (var i=0;i<1;i++) | |
{ | |
ctx.globalAlpha=Math.random()*0.65+0.1; | |
var size=Math.random()*30+5; | |
var a=Math.random()*Math.PI*2; | |
var d=s*0.9*Math.random()/2; | |
ctx.drawImage(Pic('glint.png'),-size/2+Math.sin(a)*d,-size/2+Math.cos(a)*d,size,size); | |
} | |
} | |
ctx.restore(); | |
Timer.track('big cookie'); | |
} | |
} | |
else//no particles | |
{ | |
//big cookie shine | |
var s=512; | |
var x=Game.cookieOriginX-s/2; | |
var y=Game.cookieOriginY-s/2; | |
ctx.globalAlpha=0.5; | |
ctx.drawImage(Pic('shine.png'),x,y,s,s); | |
if (showDragon) | |
{ | |
//big dragon | |
var s=300*2*(1+Math.sin(Game.T*0.013)*0.1); | |
var x=Game.cookieOriginX-s/2; | |
var y=Game.cookieOriginY-s/(1.4+0.2*Math.sin(Game.T*0.01)); | |
ctx.drawImage(Pic('dragonBG.png'),x,y,s,s); | |
} | |
//big cookie | |
ctx.globalAlpha=1; | |
var s=256*Game.BigCookieSize; | |
var x=Game.cookieOriginX-s/2; | |
var y=Game.cookieOriginY-s/2; | |
if (Game.prefs.fancy) ctx.drawImage(Pic('cookieShadow.png'),x,y+20,s,s); | |
ctx.drawImage(Pic('perfectCookie.png'),x,y,s,s); | |
} | |
//cursors | |
if (Game.prefs.cursors) | |
{ | |
ctx.save(); | |
ctx.translate(Game.cookieOriginX,Game.cookieOriginY); | |
var pic=Pic('cursor.png'); | |
var fancy=Game.prefs.fancy; | |
if (showDragon) ctx.globalAlpha=0.25; | |
var amount=Game.Objects['Cursor'].amount; | |
//var spe=-1; | |
for (var i=0;i<amount;i++) | |
{ | |
var n=Math.floor(i/50); | |
//var a=((i+0.5*n)%50)/50; | |
var w=0; | |
if (fancy) w=(Math.sin((Game.T/Game.fps*30*0.025+(((i+n*12)%25)/25)*Math.PI*2))); | |
if (w>0.997) w=1.5; | |
else if (w>0.994) w=0.5; | |
else w=0; | |
w*=-4; | |
if (fancy) w+=Math.sin((n+Game.T/Game.fps*30*0.01)*Math.PI/2)*4; | |
var x=0; | |
var y=(140/* *Game.BigCookieSize*/+n*16+w)-16; | |
var rot=7.2;//(1/50)*360 | |
if (i==0 && fancy) rot-=Game.T*0.1; | |
if (i%50==0) rot+=7.2/2/Game.fps*30; | |
ctx.rotate((rot/360)*Math.PI*2); | |
ctx.drawImage(pic,0,0,32,32,x,y,32,32); | |
//ctx.drawImage(pic,32*(i==spe),0,32,32,x,y,32,32); | |
/*if (i==spe) | |
{ | |
y+=16; | |
x=Game.cookieOriginX+Math.sin(-((r-5)/360)*Math.PI*2)*y; | |
y=Game.cookieOriginY+Math.cos(-((r-5)/360)*Math.PI*2)*y; | |
if (Game.CanClick && ctx && Math.abs(Game.mouseX-x)<16 && Math.abs(Game.mouseY-y)<16) Game.mousePointer=1; | |
}*/ | |
} | |
ctx.restore(); | |
Timer.track('cursors'); | |
} | |
} | |
else | |
{ | |
var tBase=Math.max(0,(Game.AscendTimer-Game.AscendBreakpoint)/(Game.AscendDuration-Game.AscendBreakpoint)); | |
//big crumbling cookie | |
//var t=(3*Math.pow(tBase,2)-2*Math.pow(tBase,3));//S curve | |
var t=Math.pow(tBase,0.5); | |
var shake=0; | |
if (Game.AscendTimer<Game.AscendBreakpoint) {shake=Game.AscendTimer/Game.AscendBreakpoint;} | |
//else {shake=1-t;} | |
ctx.globalAlpha=1; | |
var x=Game.cookieOriginX; | |
var y=Game.cookieOriginY; | |
x+=(Math.random()*2-1)*10*shake; | |
y+=(Math.random()*2-1)*10*shake; | |
var s=1; | |
if (tBase>0) | |
{ | |
ctx.save(); | |
ctx.globalAlpha=1-Math.pow(t,0.5); | |
ctx.translate(x,y); | |
ctx.globalCompositeOperation='lighter'; | |
ctx.rotate(Game.T*0.007); | |
s=0.5+Math.pow(tBase,0.6)*1; | |
var s2=(600)*s; | |
ctx.drawImage(Pic('heavenRing1.jpg'),-s2/2,-s2/2,s2,s2); | |
ctx.rotate(-Game.T*0.002); | |
s=0.5+Math.pow(1-tBase,0.4)*1; | |
s2=(600)*s; | |
ctx.drawImage(Pic('heavenRing2.jpg'),-s2/2,-s2/2,s2,s2); | |
ctx.restore(); | |
} | |
s=256;//*Game.BigCookieSize; | |
ctx.save(); | |
ctx.translate(x,y); | |
ctx.rotate((t*(-0.1))*Math.PI*2); | |
var chunks={0:7,1:6,2:3,3:2,4:8,5:1,6:9,7:5,8:0,9:4}; | |
s*=t/2+1; | |
/*ctx.globalAlpha=(1-t)*0.33; | |
for (var i=0;i<10;i++) | |
{ | |
var d=(t-0.2)*(80+((i+2)%3)*40); | |
ctx.drawImage(Pic('brokenCookie.png'),256*(chunks[i]),0,256,256,-s/2+Math.sin(-(((chunks[i]+4)%10)/10)*Math.PI*2)*d,-s/2+Math.cos(-(((chunks[i]+4)%10)/10)*Math.PI*2)*d,s,s); | |
} | |
ctx.globalAlpha=(1-t)*0.66; | |
for (var i=0;i<10;i++) | |
{ | |
var d=(t-0.1)*(80+((i+2)%3)*40); | |
ctx.drawImage(Pic('brokenCookie.png'),256*(chunks[i]),0,256,256,-s/2+Math.sin(-(((chunks[i]+4)%10)/10)*Math.PI*2)*d,-s/2+Math.cos(-(((chunks[i]+4)%10)/10)*Math.PI*2)*d,s,s); | |
}*/ | |
ctx.globalAlpha=1-t; | |
for (var i=0;i<10;i++) | |
{ | |
var d=(t)*(80+((i+2)%3)*40); | |
var x2=(Math.random()*2-1)*5*shake; | |
var y2=(Math.random()*2-1)*5*shake; | |
ctx.drawImage(Pic('brokenCookie.png'),256*(chunks[i]),0,256,256,-s/2+Math.sin(-(((chunks[i]+4)%10)/10)*Math.PI*2)*d+x2,-s/2+Math.cos(-(((chunks[i]+4)%10)/10)*Math.PI*2)*d+y2,s,s); | |
} | |
var brokenHalo=1-Math.min(t/(1/3),1/3)*3; | |
if (Game.AscendTimer<Game.AscendBreakpoint) brokenHalo=Game.AscendTimer/Game.AscendBreakpoint; | |
ctx.globalAlpha=brokenHalo; | |
ctx.drawImage(Pic('brokenCookieHalo.png'),-s/1.3333,-s/1.3333,s*1.5,s*1.5); | |
ctx.restore(); | |
//flares | |
var n=9; | |
var t=Game.AscendTimer/Game.AscendBreakpoint; | |
if (Game.AscendTimer<Game.AscendBreakpoint) | |
{ | |
ctx.save(); | |
ctx.translate(x,y); | |
for (var i=0;i<n;i++) | |
{ | |
if (Math.floor(t/3*n*3+i*2.7)%2) | |
{ | |
var t2=Math.pow((t/3*n*3+i*2.7)%1,1.5); | |
ctx.globalAlpha=(1-t)*(Game.drawT%2==0?0.5:1); | |
var sw=(1-t2*0.5)*96; | |
var sh=(0.5+t2*1.5)*96; | |
ctx.drawImage(Pic('shineSpoke.png'),-sw/2,-sh-32-(1-t2)*256,sw,sh); | |
} | |
ctx.rotate(Math.PI*2/n); | |
} | |
ctx.restore(); | |
} | |
//flash at breakpoint | |
if (tBase<0.1 && tBase>0) | |
{ | |
ctx.globalAlpha=1-tBase/0.1; | |
ctx.fillStyle='#fff'; | |
ctx.fillRect(0,0,ctx.canvas.width,ctx.canvas.height); | |
ctx.globalAlpha=1; | |
} | |
if (tBase>0.8) | |
{ | |
ctx.globalAlpha=(tBase-0.8)/0.2; | |
ctx.fillStyle='#000'; | |
ctx.fillRect(0,0,ctx.canvas.width,ctx.canvas.height); | |
ctx.globalAlpha=1; | |
} | |
} | |
//milk and milk accessories | |
if (Game.prefs.milk) | |
{ | |
var width=ctx.canvas.width; | |
var height=ctx.canvas.height; | |
var x=Math.floor((Game.T/Game.fps*30*2-(Game.milkH-Game.milkHd)*2000+480*2)%480);//Math.floor((Game.T*2+Math.sin(Game.T*0.1)*2+Math.sin(Game.T*0.03)*2-(Game.milkH-Game.milkHd)*2000+480*2)%480); | |
var y=(Game.milkHd)*height;//(((Game.milkHd)*ctx.canvas.height)*(1+0.05*(Math.sin(Game.T*0.017)/2+0.5))); | |
var a=1; | |
if (Game.AscendTimer>0) | |
{ | |
y*=1-Math.pow((Game.AscendTimer/Game.AscendBreakpoint),2)*2; | |
a*=1-Math.pow((Game.AscendTimer/Game.AscendBreakpoint),2)*2; | |
} | |
else if (Game.ReincarnateTimer>0) | |
{ | |
y*=1-Math.pow(1-(Game.ReincarnateTimer/Game.ReincarnateDuration),2)*2; | |
a*=1-Math.pow(1-(Game.ReincarnateTimer/Game.ReincarnateDuration),2)*2; | |
} | |
if (Game.TOYS) | |
{ | |
//golly | |
if (!Game.Toy) | |
{ | |
Game.toys=[]; | |
Game.toysType=choose([1,2]); | |
Game.Toy=function(x,y) | |
{ | |
this.id=Game.toys.length; | |
this.x=x; | |
this.y=y; | |
this.xd=Math.random()*10-5; | |
this.yd=Math.random()*10-5; | |
this.r=Math.random()*Math.PI*2; | |
this.rd=Math.random()*0.1-0.05; | |
var v=Math.random();var a=0.5;var b=0.5; | |
if (v<=a) v=b-b*Math.pow(1-v/a,3); else v=b+(1-b)*Math.pow((v-a)/(1-a),3); | |
this.s=(Game.toysType==1?64:48)*(0.1+v*1.9); | |
if (Game.toysType==2) this.s=(this.id%10==1)?96:48; | |
this.st=this.s;this.s=0; | |
var cookies=[[10,0]]; | |
for (var i in Game.Upgrades) | |
{ | |
var cookie=Game.Upgrades[i]; | |
if (cookie.bought>0 && cookie.pool=='cookie') cookies.push(cookie.icon); | |
} | |
this.icon=choose(cookies); | |
this.dragged=false; | |
this.l=document.createElement('div'); | |
this.l.innerHTML=this.id; | |
this.l.style.cssText='cursor:pointer;border-radius:'+(this.s/2)+'px;opacity:0;width:'+this.s+'px;height:'+this.s+'px;background:#999;position:absolute;left:0px;top:0px;z-index:10000000;transform:translate(-1000px,-1000px);'; | |
l('sectionLeft').appendChild(this.l); | |
AddEvent(this.l,'mousedown',function(what){return function(){what.dragged=true;};}(this)); | |
AddEvent(this.l,'mouseup',function(what){return function(){what.dragged=false;};}(this)); | |
Game.toys.push(this); | |
return this; | |
} | |
for (var i=0;i<Math.floor(Math.random()*15+(Game.toysType==1?5:30));i++) | |
{ | |
new Game.Toy(Math.random()*width,Math.random()*height*0.3); | |
} | |
} | |
ctx.globalAlpha=0.5; | |
for (var i in Game.toys) | |
{ | |
var me=Game.toys[i]; | |
ctx.save(); | |
ctx.translate(me.x,me.y); | |
ctx.rotate(me.r); | |
if (Game.toysType==1) ctx.drawImage(Pic('smallCookies.png'),(me.id%8)*64,0,64,64,-me.s/2,-me.s/2,me.s,me.s); | |
else ctx.drawImage(Pic('icons.png'),me.icon[0]*48,me.icon[1]*48,48,48,-me.s/2,-me.s/2,me.s,me.s); | |
ctx.restore(); | |
} | |
ctx.globalAlpha=1; | |
for (var i in Game.toys) | |
{ | |
var me=Game.toys[i]; | |
//psst... not real physics | |
for (var ii in Game.toys) | |
{ | |
var it=Game.toys[ii]; | |
if (it.id!=me.id) | |
{ | |
var x1=me.x+me.xd; | |
var y1=me.y+me.yd; | |
var x2=it.x+it.xd; | |
var y2=it.y+it.yd; | |
var dist=Math.sqrt(Math.pow((x1-x2),2)+Math.pow((y1-y2),2))/(me.s/2+it.s/2); | |
if (dist<(Game.toysType==1?0.95:0.75)) | |
{ | |
var angle=Math.atan2(y1-y2,x1-x2); | |
var v1=Math.sqrt(Math.pow((me.xd),2)+Math.pow((me.yd),2)); | |
var v2=Math.sqrt(Math.pow((it.xd),2)+Math.pow((it.yd),2)); | |
var v=((v1+v2)/2+dist)*0.75; | |
var ratio=it.s/me.s; | |
me.xd+=Math.sin(-angle+Math.PI/2)*v*(ratio); | |
me.yd+=Math.cos(-angle+Math.PI/2)*v*(ratio); | |
it.xd+=Math.sin(-angle-Math.PI/2)*v*(1/ratio); | |
it.yd+=Math.cos(-angle-Math.PI/2)*v*(1/ratio); | |
me.rd+=(Math.random()*1-0.5)*0.1*(ratio); | |
it.rd+=(Math.random()*1-0.5)*0.1*(1/ratio); | |
me.rd*=Math.min(1,v); | |
it.rd*=Math.min(1,v); | |
} | |
} | |
} | |
if (me.y>=height-(Game.milkHd)*height+8) | |
{ | |
me.xd*=0.85; | |
me.yd*=0.85; | |
me.rd*=0.85; | |
me.yd-=1; | |
me.xd+=(Math.random()*1-0.5)*0.3; | |
me.yd+=(Math.random()*1-0.5)*0.05; | |
me.rd+=(Math.random()*1-0.5)*0.02; | |
} | |
else | |
{ | |
me.xd*=0.99; | |
me.rd*=0.99; | |
me.yd+=1; | |
} | |
me.yd*=(Math.min(1,Math.abs(me.y-(height-(Game.milkHd)*height)/16))); | |
me.rd+=me.xd*0.01/(me.s/(Game.toysType==1?64:48)); | |
if (me.x<me.s/2 && me.xd<0) me.xd=Math.max(0.1,-me.xd*0.6); else if (me.x<me.s/2) {me.xd=0;me.x=me.s/2;} | |
if (me.x>width-me.s/2 && me.xd>0) me.xd=Math.min(-0.1,-me.xd*0.6); else if (me.x>width-me.s/2) {me.xd=0;me.x=width-me.s/2;} | |
me.xd=Math.min(Math.max(me.xd,-30),30); | |
me.yd=Math.min(Math.max(me.yd,-30),30); | |
me.rd=Math.min(Math.max(me.rd,-0.5),0.5); | |
me.x+=me.xd; | |
me.y+=me.yd; | |
me.r+=me.rd; | |
me.r=me.r%(Math.PI*2); | |
me.s+=(me.st-me.s)*0.5; | |
if (Game.toysType==2 && !me.dragged && Math.random()<0.003) me.st=choose([48,48,48,48,96]); | |
if (me.dragged) | |
{ | |
me.x=Game.mouseX; | |
me.y=Game.mouseY; | |
me.xd+=((Game.mouseX-Game.mouseX2)*3-me.xd)*0.5; | |
me.yd+=((Game.mouseY-Game.mouseY2)*3-me.yd)*0.5 | |
me.l.style.transform='translate('+(me.x-me.s/2)+'px,'+(me.y-me.s/2)+'px) scale(50)'; | |
} | |
else me.l.style.transform='translate('+(me.x-me.s/2)+'px,'+(me.y-me.s/2)+'px)'; | |
me.l.style.width=me.s+'px'; | |
me.l.style.height=me.s+'px'; | |
ctx.save(); | |
ctx.translate(me.x,me.y); | |
ctx.rotate(me.r); | |
if (Game.toysType==1) ctx.drawImage(Pic('smallCookies.png'),(me.id%8)*64,0,64,64,-me.s/2,-me.s/2,me.s,me.s); | |
else ctx.drawImage(Pic('icons.png'),me.icon[0]*48,me.icon[1]*48,48,48,-me.s/2,-me.s/2,me.s,me.s); | |
ctx.restore(); | |
} | |
} | |
var pic=Game.Milk.pic; | |
if (Game.milkType!=0 && Game.ascensionMode!=1) pic=Game.AllMilks[Game.milkType].pic; | |
ctx.globalAlpha=0.95*a; | |
ctx.fillPattern(Pic(pic),0,height-y,width+480,1,480,480,x,0); | |
ctx.fillStyle='#000'; | |
ctx.fillRect(0,height-y+480,width,Math.max(0,(y-480))); | |
ctx.globalAlpha=1; | |
Timer.track('milk'); | |
} | |
if (Game.AscendTimer>0) | |
{ | |
ctx.drawImage(Pic('shadedBordersSoft.png'),0,0,ctx.canvas.width,ctx.canvas.height); | |
} | |
if (Game.AscendTimer==0) | |
{ | |
Game.DrawWrinklers();Timer.track('wrinklers'); | |
//shimmering veil | |
if (Game.Has('Shimmering veil [off]')) | |
{ | |
ctx.globalAlpha=1; | |
ctx.globalCompositeOperation='lighter'; | |
var s=300+Math.sin(Game.T*0.037)*20; | |
var x=Game.cookieOriginX; | |
var y=Game.cookieOriginY; | |
ctx.save(); | |
ctx.translate(x,y); | |
ctx.rotate(-Game.T*0.01); | |
ctx.drawImage(Pic('shimmeringVeil.png'),-s/2,-s/2,s,s); | |
ctx.restore(); | |
if (Game.prefs.particles)//sparkles | |
{ | |
for (i=0;i<6;i++) | |
{ | |
var t=Game.T+i*15; | |
var r=(t%30)/30; | |
var a=(Math.floor(t/30)*30*6-i*30)*0.01; | |
var size=32*(1-Math.pow(r*2-1,2)); | |
var xx=x+Math.sin(a)*(110+r*16); | |
var yy=y+Math.cos(a)*(110+r*16); | |
ctx.drawImage(Pic('glint.png'),xx-size/2,yy-size/2,size,size); | |
} | |
} | |
ctx.globalCompositeOperation='source-over'; | |
} | |
Game.DrawSpecial();Timer.track('evolvables'); | |
Game.particlesDraw(2);Timer.track('text particles'); | |
//shiny border during frenzies etc | |
ctx.globalAlpha=1; | |
var borders='shadedBordersSoft.png'; | |
if (goodBuff) borders='shadedBordersGold.png'; | |
else if (badBuff) borders='shadedBordersRed.png'; | |
if (goodBuff && Game.prefs.fancy) ctx.globalCompositeOperation='lighter'; | |
ctx.drawImage(Pic(borders),0,0,ctx.canvas.width,ctx.canvas.height); | |
if (goodBuff && Game.prefs.fancy) ctx.globalCompositeOperation='source-over'; | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment