From 383e3be080b94573b846618d03805434310b3770 Mon Sep 17 00:00:00 2001 From: pixlmaster Date: Thu, 13 Dec 2018 18:17:18 +0530 Subject: [PATCH 1/3] power layout added --- game/constants.py | 1 + game/global_objects.py | 16 ++++++++++++++++ game/main.py | 4 +++- game/main.pyc | Bin 8224 -> 8117 bytes 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/game/constants.py b/game/constants.py index 310ef6c..8b83bd3 100644 --- a/game/constants.py +++ b/game/constants.py @@ -51,6 +51,7 @@ #game constants busts=0 escapes=0 +spawn=0 # text formats game_title_text_large = pygame.font.Font( diff --git a/game/global_objects.py b/game/global_objects.py index 1f9fc8e..ef2e327 100644 --- a/game/global_objects.py +++ b/game/global_objects.py @@ -281,6 +281,22 @@ def draw(self, screen, color): pygame.draw.circle(screen, wall_silver, (int( self.x), int(self.y)), self.radius - 30, 1) +class Powerup(object): + #randomly spawning powerups + def __init__(self): + self.x = random.randrange(300,600) + self.y = random.randrange(300,500) + def update(self, screen): + global spawn + if spawn!=0: + #powerup appears for 3 seconds + if spawn<300: + pygame.draw.circle(screen,red,(self.x,self.y),15) + spawn-=1 + else: + #random cooldown period b/w 6-15 seconds + spawn=random.randrange(900,1800) + class Bricks(pygame.sprite.Sprite): def __init__(self, x, y, VH): diff --git a/game/main.py b/game/main.py index 3572cfe..ca5dbc4 100644 --- a/game/main.py +++ b/game/main.py @@ -21,7 +21,7 @@ def init(): global screen, clock, flip_image, score, seconds_first, seconds_second, minutes_first, minutes_second, \ - count_to_seconds, ball, striker, time_count, score_time, hit_count, brick_point, choice, bricks + count_to_seconds, ball, striker, time_count, score_time, hit_count, brick_point, choice, bricks, powerup mute=1 hit_count = 0 # stores number of bricks hit brick_point = 0 # stores the score accumulated by hitting brick @@ -30,6 +30,7 @@ def init(): ball = Ball(main_game_middle_x + 50, main_game_middle_y + strike_bound_radius - 75) striker = Striker(main_game_middle_x, main_game_middle_y) + powerup = Powerup() seconds_first, seconds_second = 0, 0 minutes_first, minutes_second = 0, 0 count_to_seconds = 0 @@ -206,6 +207,7 @@ def render_field(): # drawing striker boundary pygame.draw.circle(screen, light_black, (main_game_middle_x, main_game_middle_y), strike_bound_radius) + powerup.update(screen) # main game loop diff --git a/game/main.pyc b/game/main.pyc index 5c73012d9b55385213fda22c9c469c787ff6f5f9..91afcca42cb30d2b7e9f437cf6f90afeb7acbbf9 100644 GIT binary patch delta 1973 zcmaJ?-A`Oa6hCwCez4zPunW7(E>M=GeA+@qtA?f&v_?!Bv_*@;g?k};fo0h{2u(1U z5Th}g)J$UQgNbi#OiVPJCMLf6Y7<{-{4X@>i!sJ?=0dlzrn%W4XXebDIUm1s`0~QN zNx%MkBxv*GxBi@Vr~!Z%e^bi<&KLtQ8N7?Af#D)kvZhc6;Q`?VQ-_T3f$&4d^g#O& z9&P~qS)0BWw>a6Gr!RZ2W&6JTpsSfT}mbz{rg++N@AM;R12;p6SmEu&H$somf` zxY33`=PUwveC*^4vIL8bGM`(XYeh^ynkX8A2D9emSCj2#fE>Ef{0(IyTNz()rAfG|# zr?l`FNy6VFk;z0f#||39(Hm^6X@R`rLj(_PA+Ipxnq`@;)yt%vk-x+yU3U`EjF+^x zU;{%t6VB}tW`EQRro8L#_9&|BxMmn zDb2dEr-Zt-D)_Lxnc6AvG#yz$XlA=fCRuLn$x*4n6Y)m1FgvaFxv0nWB#SgwT0dc| zD1U8BGcNt<3mvMeXUJv&LA^Hj`sLSnNiL^9omi(m#qGM~IF{Lb^D*vXmI17Htg3Jx zG|p%4Yd(sDcgbk>RJoVL5&>0@_Ysr{t`S@%P+4BgmdfOe+c1_`5|u5BuaO>W<@(4e z<$OWj&5p3^^5^W}+9=&1Mz5YBmn&t4f>AZ?_oDPzol-aXm{3X)7LNG@# zi{KVx*AWh!2Zs7x0h{ z`#-{gn&sFA&JrBxQ2&e2IfN72>Yn^5pE>-F(o7GjUciAaunQs}qV%+gfrzW72$A{f zv&yip`s=roim=|QQ@QmBN3x(c%yB=n7 z&Bxks#`;+bS2`O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@Qxvga%`zbW9bA;)$_n&YSfn OafG} Date: Thu, 13 Dec 2018 20:08:32 +0530 Subject: [PATCH 2/3] power-ups layout --- game/constants.py | 1 + game/global_objects.py | 28 ++++++++++++++++++++++++---- game/main.py | 3 ++- game/main.pyc | Bin 8117 -> 8147 bytes 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/game/constants.py b/game/constants.py index 8b83bd3..e665dfd 100644 --- a/game/constants.py +++ b/game/constants.py @@ -52,6 +52,7 @@ busts=0 escapes=0 spawn=0 +power_picked=0 # text formats game_title_text_large = pygame.font.Font( diff --git a/game/global_objects.py b/game/global_objects.py index ef2e327..f39c5b7 100644 --- a/game/global_objects.py +++ b/game/global_objects.py @@ -284,18 +284,38 @@ def draw(self, screen, color): class Powerup(object): #randomly spawning powerups def __init__(self): - self.x = random.randrange(300,600) - self.y = random.randrange(300,500) + distance=1000 + while distance>strike_bound_radius: + self.x=random.randrange(265,635) + self.y=random.randrange(185,555) + dx=self.x-main_game_middle_x + dy=self.y - main_game_middle_y + distance=math.hypot(dx, dy) def update(self, screen): - global spawn + global spawn, power_picked if spawn!=0: #powerup appears for 3 seconds - if spawn<300: + if spawn<300 and power_picked==0: pygame.draw.circle(screen,red,(self.x,self.y),15) spawn-=1 else: + power_picked=0 #random cooldown period b/w 6-15 seconds + distance=1000 + while distance>strike_bound_radius: + self.x=random.randrange(265,635) + self.y=random.randrange(185,555) + dx=self.x-main_game_middle_x + dy=self.y - main_game_middle_y + distance=math.hypot(dx, dy) spawn=random.randrange(900,1800) + def touch(self,striker): + global spawn, power_picked + dx=abs(self.x-striker.x) + dy=abs(self.y-striker.y) + distance=math.hypot(dx, dy) + if(distance<=(striker_radius+15) and spawn<300): + power_picked=1 class Bricks(pygame.sprite.Sprite): diff --git a/game/main.py b/game/main.py index ca5dbc4..ba6d55d 100644 --- a/game/main.py +++ b/game/main.py @@ -182,7 +182,7 @@ def check_collisions(): def render_field(): - global flip_image,screen + global flip_image,screen, striker screen.fill(black) @@ -208,6 +208,7 @@ def render_field(): pygame.draw.circle(screen, light_black, (main_game_middle_x, main_game_middle_y), strike_bound_radius) powerup.update(screen) + powerup.touch(striker) # main game loop diff --git a/game/main.pyc b/game/main.pyc index 91afcca42cb30d2b7e9f437cf6f90afeb7acbbf9..d73f0e0eb430910c4892da42e0122e5d0389dfd1 100644 GIT binary patch delta 193 zcmdmLf7zam`7kjP{od6mgOg+&>qCi9C(Z`Kf*z{Hp_d8e2u#1`-Bo51Kjoqp-^4K6yKK Lc}_Xb7*16H{>d-N From a848840cd10f988066fbf357a2788f008fb6c1c7 Mon Sep 17 00:00:00 2001 From: pixlmaster Date: Thu, 13 Dec 2018 20:44:36 +0530 Subject: [PATCH 3/3] powerup layout --- game/constants.py | 3 +++ game/global_objects.py | 14 ++++++++------ game/main.pyc | Bin 8147 -> 8147 bytes 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/game/constants.py b/game/constants.py index e665dfd..2babad9 100644 --- a/game/constants.py +++ b/game/constants.py @@ -51,8 +51,11 @@ #game constants busts=0 escapes=0 + +#powerup constants spawn=0 power_picked=0 +power_radius=15 # text formats game_title_text_large = pygame.font.Font( diff --git a/game/global_objects.py b/game/global_objects.py index f39c5b7..f658730 100644 --- a/game/global_objects.py +++ b/game/global_objects.py @@ -282,39 +282,41 @@ def draw(self, screen, color): self.x), int(self.y)), self.radius - 30, 1) class Powerup(object): - #randomly spawning powerups def __init__(self): distance=1000 while distance>strike_bound_radius: + #randomly spawning powerups in rectangle until in circle self.x=random.randrange(265,635) self.y=random.randrange(185,555) dx=self.x-main_game_middle_x dy=self.y - main_game_middle_y distance=math.hypot(dx, dy) def update(self, screen): - global spawn, power_picked + global spawn, power_picked, pwoer_radius if spawn!=0: #powerup appears for 3 seconds if spawn<300 and power_picked==0: - pygame.draw.circle(screen,red,(self.x,self.y),15) + pygame.draw.circle(screen,red,(self.x,self.y),power_radius) spawn-=1 else: power_picked=0 - #random cooldown period b/w 6-15 seconds + #random cooldown period b/w 6-9 seconds distance=1000 while distance>strike_bound_radius: + #randomly spawning powerups in rectangle until in circle self.x=random.randrange(265,635) self.y=random.randrange(185,555) dx=self.x-main_game_middle_x dy=self.y - main_game_middle_y distance=math.hypot(dx, dy) - spawn=random.randrange(900,1800) + spawn=random.randrange(900,1200) def touch(self,striker): global spawn, power_picked dx=abs(self.x-striker.x) dy=abs(self.y-striker.y) distance=math.hypot(dx, dy) - if(distance<=(striker_radius+15) and spawn<300): + if(distance<=(striker_radius+power_radius) and spawn<300): + #power has been picked power_picked=1 diff --git a/game/main.pyc b/game/main.pyc index d73f0e0eb430910c4892da42e0122e5d0389dfd1..3faf28c3f0f0ff8698596c3c109942fa706f3bfb 100644 GIT binary patch delta 15 Wcmca?f7zam`7