11#!/usr/bin/env python
22# Credits!!!
33# (YT) Clear Code - Particle System
4+ # (YT) Python Simplified - Python to .app
45# jay3332 - Number Abbreviation
56# Cryptogrounds / Considera Core
7+ # https://www.reddit.com/r/pygame/comments/ehbbr9/comment/fchsd94/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
68
79import pygame
810import random
2628
2729GameFPS = 60
2830
31+ def resource_path (relative_path ):
32+ """ Get absolute path to resource, works for dev and for PyInstaller """
33+ try :
34+ #https://stackoverflow.com/a/13790741
35+ # PyInstaller creates a temp folder and stores path in _MEIPASS
36+ base_path = sys ._MEIPASS2
37+ except Exception :
38+ base_path = os .path .abspath ("." )
39+
40+ return os .path .join (base_path , relative_path )
41+
2942class ParticlePrinciple :
3043 def __init__ (self ):
3144 self .particles = []
@@ -253,7 +266,7 @@ def abbreviate(number, suffixes, decimals, greaterthan, rounda):
253266# pygame.time.set_timer(PARTICLE_EVENT, 20)
254267
255268# Font
256- font = pygame .font .Font ("./assets/fonts/Lato/Lato-Bold.ttf" , 24 )
269+ font = pygame .font .Font (resource_path ( "./assets/fonts/Lato/Lato-Bold.ttf" ) , 24 )
257270
258271# Colors
259272WHITE = (255 , 255 , 255 )
@@ -480,10 +493,10 @@ def resetupgrades():
480493Settings_Button_Y_scroll = 0
481494Settings_Button_Y_scroll_vel = 0
482495# Clicker button
483- clicker_button_image = pygame .image .load ("./assets/img/copilot.png" ).convert_alpha ()
496+ clicker_button_image = pygame .image .load (resource_path ( "./assets/img/copilot.png" ) ).convert_alpha ()
484497# clicker_button_rect = clicker_button_image.get_rect(center=(screen_width // 2, screen_height // 2))
485- arrow_down_img1 = pygame .image .load ("./assets/img/Arrow1-c.png" ).convert_alpha ()
486- arrow_up_img1 = pygame .image .load ("./assets/img/Arrow1-d.png" ).convert_alpha ()
498+ arrow_down_img1 = pygame .image .load (resource_path ( "./assets/img/Arrow1-c.png" ) ).convert_alpha ()
499+ arrow_up_img1 = pygame .image .load (resource_path ( "./assets/img/Arrow1-d.png" ) ).convert_alpha ()
487500
488501# Upgrade button setup
489502for i , upgrade in enumerate (upgrades ):
@@ -569,7 +582,6 @@ def PlayMusic(musNum):
569582 pymusictype = "wav"
570583 musicfilepath = "./assets/audio/INOSSI - Got you-loop 44100.wav"
571584 musicintrofilepath = "./assets/audio/INOSSI - Got you-start 44100.wav"
572- print (musicintrofilepath )
573585 original_musicintro = AudioSegment .from_file (musicintrofilepath )
574586 pitched_musicintro = change_pitch_in_memory (original_musicintro , 3 )
575587 audio_buffer1 = BytesIO ()
@@ -582,9 +594,9 @@ def PlayMusic(musNum):
582594
583595PlayMusic (random .randint (1 ,6 ))
584596pygame .mixer .music .set_volume (Decimal (pygamemixermusic ) * (Settings [1 ]["value" ] / 100 ))
585- click_sound = pygame .mixer .Sound ("./assets/audio/Click mouse - Fugitive Simulator - The-Nick-of-Time.wav" )
586- hover_sound = pygame .mixer .Sound ("./assets/audio/251389__deadsillyrabbit__button_hover-wav.wav" )
587- upgrade_sound = pygame .mixer .Sound ("./assets/audio/Upgrade SOund 0001.wav" )
597+ click_sound = pygame .mixer .Sound (resource_path ( "./assets/audio/Click mouse - Fugitive Simulator - The-Nick-of-Time.wav" ) )
598+ hover_sound = pygame .mixer .Sound (resource_path ( "./assets/audio/251389__deadsillyrabbit__button_hover-wav.wav" ) )
599+ upgrade_sound = pygame .mixer .Sound (resource_path ( "./assets/audio/Upgrade SOund 0001.wav" ) )
588600
589601Hovering_Buttons = [0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ]
590602framestofixload = 0
@@ -598,12 +610,12 @@ def save_game():
598610 offlineTime = time .time ()
599611 GameStuff = [gems , score , start_time , offlineTime , bulkbuy ]
600612 GameStuff2 = [Settings , upgrades , GameStuff ]
601- with open ( f'. /SaveData.pickle' , 'wb' ) as fileSave :
613+ with open ( resource_path ( "save /SaveData.pickle" ) , 'wb' ) as fileSave :
602614 pickle .dump (GameStuff2 , fileSave , protocol = pickle .HIGHEST_PROTOCOL )
603615def load_game ():
604616 try :
605617 global Settings , upgrades , gems , score , start_time , game_time , offlineCurrentTime , offlineOldTime , delta_time , offlineTime , framestofixload , auto_click_rate , auto_click_value , click_value , click_value_multi , cps_to_cpc , offlineBoxAlpha , differenceTimeOffline , offlineCurrentTime , offlineOldTime , gemboost , GameStuff , bulkbuy , GameStuff2
606- with open ( '. /SaveData.pickle' , 'rb' ) as fileSave :
618+ with open ( resource_path ( "save /SaveData.pickle" ) , 'rb' ) as fileSave :
607619 GameStuff2 = pickle .load (fileSave )
608620 GameStuff = GameStuff2 [2 ]
609621 upgrades = GameStuff2 [1 ]
@@ -864,7 +876,7 @@ def load_game():
864876 screen .fill ((30 , 30 , 30 ))
865877 screen .blit (smalclicrimg , (button_rect_x [0 ]- (scale_x [0 ]/ 2 )* WindowScale2 , button_rect_y [0 ]- (scale_y [0 ]/ 2 )* WindowScale2 ))
866878 # Draw text
867- font = pygame .font .Font ("./assets/fonts/Lato/Lato-Bold.ttf" , int (24 * WindowScale2 ))
879+ font = pygame .font .Font (resource_path ( "./assets/fonts/Lato/Lato-Bold.ttf" ) , int (24 * WindowScale2 ))
868880 def draw_text (text , font , color , x , y , align , alpha ):
869881 text_surface = font .render (text , True , color )
870882 text_surface .set_alpha (alpha )
@@ -927,9 +939,9 @@ def prestige():
927939 draw_text (f"{ Settings [i ]['name' ]} " , font , WHITE , setx * WindowXscale + Settings_button_width [i ]* WindowXscale / 2 , sety * WindowYscale + Settings_button_height [i ]* WindowScale2 / 2 , "center" , 255 )
928940 pygame .draw .rect (screen , (30 , 30 , 30 ), (900 * WindowXscale + CamPos [0 ]* WindowXscale , WindowHeight * 0.35 + CamPos [1 ]* WindowYscale , 380 * WindowXscale , WindowHeight * 1 ))
929941 pygame .draw .rect (screen , (30 , 30 , 30 ), (900 * WindowXscale + CamPos [0 ]* WindowXscale , WindowHeight * 0.0 + CamPos [1 ]* WindowYscale , 380 * WindowXscale , WindowHeight * 0.1 ))
930- draw_text (f"Options" , pygame .font .Font ("./assets/fonts/Lato/Lato-Bold.ttf" , int (36 * WindowScale2 )), WHITE , 1110 * WindowXscale + CamPos [0 ]* WindowXscale , 18 * WindowYscale + CamPos [1 ]* WindowYscale , "center" , 255 )
931- draw_text (f"Log" , pygame .font .Font ("./assets/fonts/Lato/Lato-Bold.ttf" , int (36 * WindowScale2 )), WHITE , 1110 * WindowXscale + CamPos [0 ]* WindowXscale , 318 * WindowYscale + CamPos [1 ]* WindowYscale , "center" , 255 ) # IT'S CLONE RIGGY!
932- draw_text (f"Upgrades" , pygame .font .Font ("./assets/fonts/Lato/Lato-Bold.ttf" , int (36 * WindowScale2 )), WHITE , 30 * WindowXscale + CamPos [0 ]* WindowXscale , 540 * WindowYscale + CamPos [1 ]* WindowYscale , "left" , 255 )
942+ draw_text (f"Options" , pygame .font .Font (resource_path ( "./assets/fonts/Lato/Lato-Bold.ttf" ) , int (36 * WindowScale2 )), WHITE , 1110 * WindowXscale + CamPos [0 ]* WindowXscale , 18 * WindowYscale + CamPos [1 ]* WindowYscale , "center" , 255 )
943+ draw_text (f"Log" , pygame .font .Font (resource_path ( "./assets/fonts/Lato/Lato-Bold.ttf" ) , int (36 * WindowScale2 )), WHITE , 1110 * WindowXscale + CamPos [0 ]* WindowXscale , 318 * WindowYscale + CamPos [1 ]* WindowYscale , "center" , 255 ) # IT'S CLONE RIGGY!
944+ draw_text (f"Upgrades" , pygame .font .Font (resource_path ( "./assets/fonts/Lato/Lato-Bold.ttf" ) , int (36 * WindowScale2 )), WHITE , 30 * WindowXscale + CamPos [0 ]* WindowXscale , 540 * WindowYscale + CamPos [1 ]* WindowYscale , "left" , 255 )
933945 for i , button in enumerate (upgrade_buttons ):
934946 def calcmax ():
935947 return constrain (Decimal .__floor__ ( Decimal .log10 ( (Decimal (score ) * (Decimal (upgrades [i ]["costcoefficient" ]) - 1 )) / Decimal (upgrades [i ]["startcost" ] * (Decimal (upgrades [i ]["costcoefficient" ]) ** Decimal (upgrades [i ]["bought" ]))) + 1 ) / Decimal .log10 (Decimal (upgrades [i ]["costcoefficient" ]))), Decimal (1 ), math .inf )
@@ -971,8 +983,8 @@ def distance_to(ax, ay, bx, by):
971983 offlineBox_rect_surface = pygame .Surface ((960 * WindowScale2 , 360 * WindowScale2 ), pygame .SRCALPHA )
972984 offlineBox_rect_surface .fill ((0 , 64 , 128 , offlineBoxAlpha )) # Fill with red and set alpha to 128 (50% transparent)
973985 screen .blit (offlineBox_rect_surface , ((640 * WindowXscale ) - (480 * WindowScale2 ), (360 * WindowYscale ) - (180 * WindowScale2 )))
974- draw_text (f"While you were away for { abbreviate ((Decimal (offlineCurrentTime ) - Decimal (offlineOldTime )), "s" , 3 , 10000 , False )} seconds," , pygame .font .Font ("./assets/fonts/Lato/Lato-Bold.ttf" , int (30 * WindowScale2 )), (255 , 64 , 128 , offlineBoxAlpha ), 640 * WindowXscale , 330 * WindowYscale , "center" , offlineBoxAlpha )
975- draw_text (f"You earned { abbreviate (Decimal (differenceTimeOffline ) * Decimal (auto_click_value ) * Decimal (auto_click_rate ) * Decimal (gemboost ), "s" , 3 , 100000 , False )} clicks." , pygame .font .Font ("./assets/fonts/Lato/Lato-Bold.ttf" , int (30 * WindowScale2 )), (255 , 64 , 128 , offlineBoxAlpha ), 640 * WindowXscale , 390 * WindowYscale , "center" , offlineBoxAlpha )
986+ draw_text (f"While you were away for { abbreviate ((Decimal (offlineCurrentTime ) - Decimal (offlineOldTime )), "s" , 3 , 10000 , False )} seconds," , pygame .font .Font (resource_path ( "./assets/fonts/Lato/Lato-Bold.ttf" ) , int (30 * WindowScale2 )), (255 , 64 , 128 , offlineBoxAlpha ), 640 * WindowXscale , 330 * WindowYscale , "center" , offlineBoxAlpha )
987+ draw_text (f"You earned { abbreviate (Decimal (differenceTimeOffline ) * Decimal (auto_click_value ) * Decimal (auto_click_rate ) * Decimal (gemboost ), "s" , 3 , 100000 , False )} clicks." , pygame .font .Font (resource_path ( "./assets/fonts/Lato/Lato-Bold.ttf" ) , int (30 * WindowScale2 )), (255 , 64 , 128 , offlineBoxAlpha ), 640 * WindowXscale , 390 * WindowYscale , "center" , offlineBoxAlpha )
976988 offlineBoxAlpha = constrain (offlineBoxAlpha - 51 * delta_time , 0 , 255 )
977989 YouWillNotUpgradeUnlessToldTo_Time -= delta_time
978990 # Update display
0 commit comments