From 97ae892f2d134e81a48805dc77b2893f912352b9 Mon Sep 17 00:00:00 2001 From: David Raison Date: Sat, 30 Aug 2014 18:46:55 +0200 Subject: [PATCH 1/4] Added lawyer class --- game.py | 40 ++++++++++++++++++++++++++++++++-------- img/lawyer.png | Bin 0 -> 23424 bytes interface/hud.py | 2 +- lawyer.py | 20 ++++++++++++++++++++ 4 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 img/lawyer.png create mode 100644 lawyer.py diff --git a/game.py b/game.py index a848c2a..b10aeee 100755 --- a/game.py +++ b/game.py @@ -5,26 +5,43 @@ Avocados and stuff import os, random import pygame -import avocado +import avocado, lawyer from pygame.locals import * from support.colors import * from interface import hud +def initialize_screen(): + displayInfo = pygame.display.Info() + zoom = 1.3 + + WIDTH = int(displayInfo.current_w / zoom) + HEIGHT = int(displayInfo.current_h / zoom) + return (WIDTH, HEIGHT) + + def main(): pygame.init() pygame.display.set_caption('Pin the Avocados!') clock = pygame.time.Clock() - # Move this outside the main code? - screen_width = 800 - screen_height = 600 - screen = pygame.display.set_mode((screen_width,screen_height)) + # initialize_screen() won't work for dualscreen + #size = initialize_screen() + size = (800, 600) bg = BLACK desired_fps = 60 - font = pygame.font.Font(None, 40) + + # I don't know, should we move this text out of the way? game_over = font.render('GAME OVER', 0, RED) - my_hud = hud.Hud((screen_width, screen_height)) + + # initialize the game canvas + screen = pygame.display.set_mode(size) + + # initialize the HUD class + my_hud = hud.Hud(size) + + # initialize our lawyer + fullegast = lawyer.Lawyer(screen) score = 0 time = 15 @@ -37,10 +54,14 @@ def main(): fps = clock.get_fps() screen.fill(bg) + # Let's add the lawyer + fullegast.blitme() + timeleft -= time_passed / 1000 timeleft = round(timeleft, 2) if timeleft <= 0: + screen_width, screen_height = size screen.blit(game_over, (screen_width/3, screen_height/2)) displaytime = 'Timed out!' else: @@ -53,15 +74,18 @@ def main(): # Initialize a number of avocados, depending on the level avocados = [] for i in range(0, level): - a = avocado.Avocado((screen_width, screen_height)) + a = avocado.Avocado(size) avocados.append(a) # Catch events for event in pygame.event.get(): + # Collision detection if event.type == MOUSEBUTTONDOWN: for avo in avocados: if avo.collides(pygame.mouse.get_pos()): score += 100 + + # Had enough of this? if event.type == pygame.QUIT: running = False diff --git a/img/lawyer.png b/img/lawyer.png new file mode 100644 index 0000000000000000000000000000000000000000..55e2f644ec66883cf1dc13652eb866379d2f6fd6 GIT binary patch literal 23424 zcmafbc|4Te7x<7VQL5LHEJ?~b_K+b&QkHDRWS#6~eXR{bQ&NP4VeCtmvNZN4imBH+ zmQZRet!AW9nNm~I?>yf3`}zI;`@Nq}uX&z(@44rkd$xP-xz9D56J}fa#Q0Ds)Yjw2 zj@Y44JQU;~FAuyqEFW_O{&0I(n8DvWsWKYyv^nJ1>9GHGL)}o?sfI#1-8g>a@X7O& zi@&1^DjBZ3&$|n^-!VBAvD9CFTr5>qK4ISmV-4d3WsQ^$DbIj63D5mMO=4QV_-mj4 z8z=rI$4fjQvf&Kv0%;DK%MZ=}~H)Gfrr;Fd| zW_OQSZ+o9YL}zJbd<=CBqSvtRbnJ81$p51Ci{Tpz05dvtq=q~R`+Cg{PnYcE6R{ca zs;7Tk&g;NNdCg(}IQuS#7~J^In&E_;@VWifev?xbo=ZGf){$w!_6?1yA70(K*6zzb zxqC2}`FuH~Na6Qhl(Ib~AvMCvEnkOaMcqH1_?JtcCg<_0&zihcKY2`b(-T=V{|kA0 z>LK@H9j352w&i|SxBd;oK2=udEOpE_VMQL-bu@Rxm2)NbLj8!>yu512f%x1%xrT$~ z^>l93xklwzxy1war^VjC3s_T&S8d~55=2!$URibIWJ@TzmDPVen7NG^6Y4B$-ib${ za+A2XNgW!DfaTC?JIaG?wW&DNY==6Aoz)nW_kEAwZpdy#_Mr3rRJ?yKRPZ2_55sFKs31lN}tVckkk zej4r`e$_WIrmBN_^3aOIitRZ6jZxkEWwpk|{^$Nps7dXd&f-hm{v$^XhFNoAj`KN^ zD8J`RvGHj;@9K;H#tlj_Ei~MIc5gyCh1dOaq!L^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AYbSA&U)D(IC z;*ID=VrIe}lG`b4_wz?I+endaB1v|K)RPt9aWD#r_c#z{FsE2QlS@1kDWV+mm)Iyz zy=YT+BGmSUUapz^CpoUxQ{sIER>1ErpO2_@y zmc0M{ib|$fD}O|@@^DV$ch?Tq!iHgQ9Cw9#=HWF6;zuV2X9u@Rznk-dGFmJQ zsqJnii?0HD*`-<=mNh98+q_?DgdmiY1WZ)|)`MvORy_2)pEN&66I(`b0LwNqiYRm*bKO0HE+YBH^K zAWa7fBy`j~(LPlwpo;L~ctH*P19r!ha^d2dG+m}}AT98G*ON1k&;k~Dh(@1r@Qs|v zi$RT)MaH7dQj6(Og`*#P6|i(pvN!B*^C*u?C%xLgNE8PScV^@w zQ7+rT0@fyiWBM!B_T6{SK?Kn<6IcZQV_)69rz$6!KCwRQ+C<>1L;=;0}Ss{yWqptma(!)x-n zgg-~K2Rvq!X{#x>ud2U=PmAC+M_t075(l>S0s7DCR>Gdx*^?okzW5!#U}S8{e{-8= z_ntMjhkuqvt)WEGLZU)lwlhQF3&G>;9WXe149?jHk8`nibg{={aE>lGTz=KjIbU>$ zh@|bLv;Von|0KkG=&(#P0xO!~vMq!airEME+4P;^p)Ob~HY#F|=CjY&*=Y;I4w}@J S_nK>FyKc?K)kQy15C0#4wQO|& literal 0 HcmV?d00001 diff --git a/interface/hud.py b/interface/hud.py index 99d2c0f..e8ac8a6 100644 --- a/interface/hud.py +++ b/interface/hud.py @@ -10,7 +10,7 @@ class Hud: def __init__(self, screensize): self.screen_width, self.screen_height = screensize self.font = pygame.font.Font(None, 30) - self.screen = pygame.Surface((self.screen_width, self.screen_height / 6)) + self.screen = pygame.Surface((self.screen_width, self.screen_height / 8)) def draw_hud(self, score, timeleft, fps): self.screen.fill(BLACK) diff --git a/lawyer.py b/lawyer.py new file mode 100644 index 0000000..98bdbcf --- /dev/null +++ b/lawyer.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +import os, pygame +from support import operations +from support.colors import * + +class Lawyer: + + def __init__(self, screen): + self.screen = screen + screen_width, screen_height = screen.get_size() + temp_image = pygame.image.load(os.path.join('img', 'lawyer.png')) + # WARNING!! Absolute sizes + self.image = pygame.transform.scale(temp_image, (200, 400)) + rect = self.image.get_rect() + self.pos = (screen_width - rect.w, screen_height - rect.h) + + def blitme(self): + operations.color_surface(self.image, WHITE) + self.screen.blit(self.image, self.pos) From ddebb1a4527cf4249cdfc9e402e84cd31a5b20bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sat, 30 Aug 2014 18:50:21 +0200 Subject: [PATCH 2/4] Use proper image --- avocado.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/avocado.py b/avocado.py index f0e5710..edebdb2 100644 --- a/avocado.py +++ b/avocado.py @@ -5,14 +5,14 @@ import random class Avocado: - def __init__(self, screensize, filename='avocado-01.jpg'): + def __init__(self, screensize, filename='img/AvoCado_0.png'): self.screen_width, self.screen_height = screensize self.x = random.randint(0, self.screen_width) self.y = 0 # change this to start somewhere above the screen self.w = 100 self.y = 100 self.i = pygame.image.load(filename).convert_alpha() - self.image = pygame.transform.scale(self.i, (20, 20)) + self.image = pygame.transform.scale(self.i, (30, 30)) self.pycard = self.image.get_rect() self.pycard.x = random.randint(0, self.screen_width) From b41c4a318008cd4a4ca51112b9675111994ce6f4 Mon Sep 17 00:00:00 2001 From: David Raison Date: Sat, 30 Aug 2014 18:53:38 +0200 Subject: [PATCH 3/4] Added comments to lawyer class --- lawyer.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lawyer.py b/lawyer.py index 98bdbcf..a34624b 100644 --- a/lawyer.py +++ b/lawyer.py @@ -1,4 +1,7 @@ #!/usr/bin/env python3 +""" +A class that represents a lawyer +""" import os, pygame from support import operations @@ -10,11 +13,15 @@ class Lawyer: self.screen = screen screen_width, screen_height = screen.get_size() temp_image = pygame.image.load(os.path.join('img', 'lawyer.png')) - # WARNING!! Absolute sizes + # WARNING!! FIXME Absolute sizes FIXME self.image = pygame.transform.scale(temp_image, (200, 400)) rect = self.image.get_rect() self.pos = (screen_width - rect.w, screen_height - rect.h) def blitme(self): + """ Blit this object to the screen """ operations.color_surface(self.image, WHITE) self.screen.blit(self.image, self.pos) + + def announce(self): + """ Announces the color to pin """ From 3e84222003101e489c97ff105c0266700dbf0916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sat, 30 Aug 2014 19:01:48 +0200 Subject: [PATCH 4/4] cleanup avocado --- avocado.py | 13 +++++++------ game.py | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/avocado.py b/avocado.py index edebdb2..6262365 100644 --- a/avocado.py +++ b/avocado.py @@ -3,10 +3,12 @@ import pygame import random + class Avocado: - def __init__(self, screensize, filename='img/AvoCado_0.png'): - self.screen_width, self.screen_height = screensize + def __init__(self, screen, filename='img/AvoCado_0.png'): + self.screen = screen + self.screen_width, self.screen_height = screen.get_size() self.x = random.randint(0, self.screen_width) self.y = 0 # change this to start somewhere above the screen self.w = 100 @@ -15,15 +17,14 @@ class Avocado: self.image = pygame.transform.scale(self.i, (30, 30)) self.pycard = self.image.get_rect() - self.pycard.x = random.randint(0, self.screen_width) - self.pycard.y = random.randint(20, 70) + self.init_pos() self.step_x = 10 self.step_y = 10 self.is_falling = True - def reset(self): + def init_pos(self): self.pycard.x = random.randint(0, self.screen_width) - self.pycard.y = random.randint(0, 50) + self.pycard.y = random.randint(20, 70) def collides(self, click): """ diff --git a/game.py b/game.py index 84064f0..0cd5ace 100755 --- a/game.py +++ b/game.py @@ -76,12 +76,12 @@ def main(): if len(avocados) != level: avocados = [] for i in range(0, level): - a = avocado.Avocado(size) + a = avocado.Avocado(screen) avocados.append(a) for a in avocados: if not a.move(): - a.reset() + a.init_pos() screen.blit(a.image, a.pycard) # Catch events