From 42959f84b1aa7aa1d454ddbc266ee950170c327c Mon Sep 17 00:00:00 2001 From: Skullheadx <704277@pdsb.net> Date: Wed, 31 Aug 2022 00:13:29 -0400 Subject: [PATCH] Basket Ball Created --- .gitignore | 17 ++ .idea/.gitignore | 8 + .idea/BasketBall.iml | 10 + .idea/inspectionProfiles/Project_Default.xml | 44 +++ .../inspectionProfiles/profiles_settings.xml | 6 + .idea/misc.xml | 4 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + game.py | 266 ++++++++++++++++++ gomarice_no_continue.ttf | Bin 0 -> 20120 bytes main.py | 20 ++ setup.py | 28 ++ 12 files changed, 417 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/BasketBall.iml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 game.py create mode 100644 gomarice_no_continue.ttf create mode 100644 main.py create mode 100644 setup.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c0499af --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ + +.idea/BasketBall.iml +.idea/BasketBall.iml +.idea/inspectionProfiles/profiles_settings.xml +.idea/inspectionProfiles/Project_Default.xml +.idea/misc.xml +.idea/modules.xml +.idea/vcs.xml +__pycache__/game.cpython-310.pyc +__pycache__/setup.cpython-39.pyc +__pycache__/setup.cpython-310.pyc +.idea/vcs.xml +.idea/modules.xml +.idea/misc.xml +.idea/inspectionProfiles/Project_Default.xml +.idea/inspectionProfiles/profiles_settings.xml +.idea/BasketBall.iml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/BasketBall.iml b/.idea/BasketBall.iml new file mode 100644 index 0000000..eb88b39 --- /dev/null +++ b/.idea/BasketBall.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..38750a3 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,44 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..b3d05c2 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..26d1198 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/game.py b/game.py new file mode 100644 index 0000000..9c15a87 --- /dev/null +++ b/game.py @@ -0,0 +1,266 @@ +import pygame.draw + +from setup import * + + +class Ball: + radius = 15 + gravity = 9.81 / 1000 + + def __init__(self, pos, vel, collide_list): + self.position = pygame.Vector2(pos) + self.velocity = pygame.Vector2(vel) + self.acceleration = pygame.Vector2(0, self.gravity) + + self.angle = 0 + + self.shot_taken = False + self.on_ground = False + + self.collide_list = collide_list + + def get_input(self): + if pygame.mouse.get_pressed(3)[0]: + self.shoot() + + def shoot(self): + if not self.shot_taken: + self.shot_taken = True + + self.velocity, self.angle = self.get_initial() + + def get_initial(self): + mouse_position = pygame.Vector2(pygame.mouse.get_pos()) + velocity = pygame.Vector2( + mouse_position.x - self.position.x, mouse_position.y - self.position.y).normalize() + + distance = math.sqrt(pow(mouse_position.x - self.position.x, 2) + pow(mouse_position.y - self.position.y, 2)) + + # print(distance) + + distance /= 45 + + distance = min(distance, 12) + + velocity.x *= distance + velocity.y *= distance + + # angle = math.atan((mouse_position.y - self.position.y) / (mouse_position.x - self.position.x)) # radians + angle = 0 + return velocity, angle + + def update(self, delta): + + self.get_input() + + if self.shot_taken: + self.position, self.velocity = self.get_movement(delta, self.collide_list) + + def get_movement(self, delta, collide_list): + position, velocity = self.position.copy(), self.velocity.copy() + + self.on_ground = False + position.y += velocity.y + for thing in collide_list: + if thing.get_rect().colliderect(self.get_rect(position.x, position.y)): + if velocity.y > 0: + position.y = thing.position.y - self.radius + self.on_ground = True + else: + position.y = thing.position.y + thing.height + self.radius + velocity.y *= -0.7 + + velocity.y += self.acceleration.y * delta + if self.on_ground and abs(velocity.y) < 0.6: + velocity.y = 0 + + position.x += velocity.x + for thing in collide_list: + if thing.get_rect().colliderect(self.get_rect(position.x, position.y)): + if velocity.x > 0: + position.x = thing.position.x - self.radius + else: + position.x = thing.position.x + thing.width + self.radius + velocity.x *= -0.7 + velocity.x += self.acceleration.x * delta + + if self.on_ground: + velocity.x *= 0.9 + if self.on_ground and abs(velocity.x) < 0.1: + velocity.x = 0 + + return position, velocity + + def get_rect(self, x=None, y=None): + if x is None: + x = self.position.x + if y is None: + y = self.position.y + return pygame.Rect(x - self.radius, y - self.radius, self.radius * 2, self.radius * 2) + + def draw(self, surf): + pygame.draw.circle(surf, Colour.ORANGE, self.position, self.radius) + + +class BallPath(Ball): + num_dots = 5 + # separation_distance = 0 gets too long to calc when bounce on floor + separation_counts = 6 + radius = Ball.radius * 0.85 + + def __init__(self, pos, vel, collide_list): + super().__init__(pos, vel, collide_list) + + self.path = [] + self.initial_position = pygame.Vector2(pos) + + def update(self, delta): + self.position = self.initial_position.copy() + self.velocity, self.angle = self.get_initial() + + self.path = [self.position] + time = (1000 / fps) # for a smoother result + dots = 0 + counter = 0 + while (-self.radius < self.position.x < SCREEN_WIDTH + self.radius and + self.position.y < SCREEN_HEIGHT + self.radius): + + self.position, self.velocity = self.get_movement(time, self.collide_list) + counter += 1 + if counter % self.separation_counts == 0: + # if len(self.path) == 0 or ( + # pow(self.path[-1].y - self.position.y, 2) + pow(self.path[-1].x - self.position.x, 2) > pow( + # self.separation_distance, 2)): + self.path.append(self.position) + dots += 1 + + if dots == self.num_dots: + break + # print(self.path, self.position, self.velocity) + + def draw(self, surf): + for pos in self.path: + pygame.draw.circle(surf, Colour.LIGHT_GRAY, pos, self.radius) + + +class Net: + width, height = Ball.radius * 2 * 2, Ball.radius * 3 + rim_width = 2 + pole_width = 30 + backboard_height = Ball.radius * 5 + + def __init__(self, pos): + self.position = pygame.Vector2(pos) + self.can_score = False + self.left_wall = Wall((self.position.x - self.rim_width / 2, self.position.y), self.rim_width, self.height, + Colour.WHITE) + self.right_wall = Wall((self.position.x + self.width - self.rim_width / 2, self.position.y), self.rim_width, + self.height, Colour.WHITE) + self.pole = Wall((self.right_wall.position.x + self.rim_width, self.position.y - self.backboard_height), + self.pole_width, SCREEN_HEIGHT - self.position.y, Colour.DARK_GRAY) + self.scored = False + + def update(self, ball): + if not self.can_score and ball.position.y < self.position.y: + self.can_score = True + if self.can_score and self.get_rect().colliderect(ball.get_rect()): + self.scored = True + return self.scored + + def get_rect(self): + return pygame.Rect(self.position.x, self.position.y, self.width, self.height) + + def draw(self, surf): + pygame.draw.rect(surf, Colour.WHITE, self.get_rect()) + + +class Wall: + + def __init__(self, pos, width, height, colour): + self.position = pygame.Vector2(pos) + self.width = width + self.height = height + self.colour = colour + + def get_rect(self): + return pygame.Rect(self.position, (self.width, self.height)) + + def draw(self, surf): + pygame.draw.rect(surf, self.colour, self.get_rect()) + + +class Game: + font = pygame.font.Font('gomarice_no_continue.ttf', 64) + small_font = pygame.font.Font('gomarice_no_continue.ttf', 32) + points = 0 + attempts = 0 + + def __init__(self): + self.net = Net((SCREEN_WIDTH * 4 / 5, SCREEN_HEIGHT / 3)) + + self.collision_list = [self.net.left_wall, self.net.right_wall, self.net.pole, + Wall((0, SCREEN_HEIGHT * 4 / 5), SCREEN_WIDTH, SCREEN_HEIGHT / 5, Colour.TAN)] + + self.ball = Ball((random.randint(SCREEN_WIDTH/10, SCREEN_WIDTH/1.5), SCREEN_HEIGHT * 2 / 3), (0, 0), self.collision_list) + self.ball_path = BallPath(self.ball.position, self.ball.velocity, self.collision_list) + + self.scored = False + self.points_added = False + self.attempt_added = False + self.game_over = False + self.timer = 2000 + + def update(self, delta): + self.ball.update(delta) + if not self.ball.shot_taken: + self.ball_path.update(delta) + + self.scored = self.net.update(self.ball) + + if not self.points_added and self.scored: + self.points += 1 + self.points_added = True + + if not self.attempt_added and pygame.mouse.get_pressed(3)[0]: + self.attempts += 1 + self.attempt_added = True + + if not self.game_over and self.ball.shot_taken and (self.ball.velocity == pygame.Vector2(0, 0) or not ( + -self.ball.radius < self.ball.position.x < SCREEN_WIDTH + self.ball.radius and + self.ball.position.y < SCREEN_HEIGHT + self.ball.radius)): + self.game_over = True + if self.game_over: + self.timer -= delta + if self.timer <= 0: + self.__init__() + + def draw(self, surf): + surf.fill(Colour.BLUE) + if not self.ball.shot_taken: + self.ball_path.draw(surf) + + for thing in self.collision_list: + thing.draw(surf) + # self.net.draw(surf) + + self.ball.draw(surf) + + if self.game_over: + if self.scored: + text = self.font.render("YOU SCORED", True, Colour.WHITE) + text_rect = text.get_rect(center=center) + text2 = self.font.render("YOU SCORED", True, Colour.DARK_GRAY) + text_rect2 = text.get_rect(center=center-pygame.Vector2(-10,-10)) + else: + text = self.font.render("YOU MISSED", True, Colour.WHITE) + text_rect = text.get_rect(center=center) + text2 = self.font.render("YOU SCORED", True, Colour.DARK_GRAY) + text_rect2 = text.get_rect(center=center-pygame.Vector2(-10,-10)) + surf.blit(text2, text_rect2) + surf.blit(text, text_rect) + text3 = self.small_font.render(f"POINTS: {self.points}", True, Colour.WHITE) + text_rect3 = text3.get_rect() + surf.blit(text3, text_rect3) + text4 = self.small_font.render(f"ATTEMPT #{self.attempts}", True, Colour.WHITE) + text_rect4 = text4.get_rect(top = text_rect3.height) + surf.blit(text4, text_rect4) diff --git a/gomarice_no_continue.ttf b/gomarice_no_continue.ttf new file mode 100644 index 0000000000000000000000000000000000000000..c55e4465fac9556de0bfecb331a853282cfd3722 GIT binary patch literal 20120 zcmZQzWME+6V`yMtW=QZ4);FrY>Uy4mfw6;ufgvn8H?hF%=%$Md4DxRn7#L3_mz5~+ z9}r+*V369vz`(?iR*;^{7&J$Mfk9>q0|Ue6^u*!<26hH^1_r4W3=9lB={c2Yb^O0G z7#K8`Ffgco$w*C1u~4<}Vqjo+!@$5`mXVQ~$j;9q#K6F)!oa|wl95|dvBXI-lYv3i zfPsOzBqu*PkwM`80tN=f9SjW26}gEO1rpyG8WtQ)fkf*~P%X_<(^y z;#fg`amoM13zol^Ob>-g#j5{ zZRNf8|JZ*c=6%ff85kJY85qGj7(gU*$Nvrn2Ign~kNrQ!ybmOTtdrp`SmZ8400S#n z92BYy3?d8+5)2IbU=e08$?$&x$bAqt3dzWLhH(M|D+31;0}}%S17iV{-oaqP$icwC z#LWg(-T*NX6pCPxki_g%1_uTOB}u3oI~Xb)z-|UhGcX7+90R)!#N`AT4Pr1bGH^4( zR53BIGr`!*4BX5xHVXqc3yjUmAkPY8voU~N1Mwp}12;PZ12Y373&?CC4j7w}L5vH= zW@6yufw7qx#Q0!r76vf^7@L*BP6)yEbn27Nry%7LKxA8r5BDs+d2xl9Zk3{3z3GeBojhK8eQcCI)5( z76w)ZHU@SE4hBvJE(UG}9tK_pJ_ddU0R}+^AqHUv5e88PF$Qr42?j|9DF$f<83tJf zIR<$K1qMY1B?e^%6$VuXH3oGC4F*jHEe34{9R^(nJ#fuw$Y8`^%wWP`%3#J|&S1e{ z$za7`&0xb|%V5V~&)~q|$l%1_%;3V{%HYP}&fvk|$>7D{&EUh}%izc0&k(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Xa6)EfKPH8X?8|4WP?m_Z{%eDK&)1Wj}ZDzYovGn%q9 zi<)aNYVpMJIQ+ZE7sq$ORoRc}o|@WUB|W_f4<9n_`}-Ht7YB`*K+9-QZ6XZqwSsy$ zpxFQCL5=*!tMV(a2d+S09v5~9W4Y6NSJ~~l?8>(K?B+v3mC;BBcE9)Ss1CwSt&6kEco{& zCGy|v2_-83wlUsPDFTgd6RIacc?hLkAFXde`%D>@W-!e03F(fh8F;yYAlT3|8Sxps1S&c=NYc~A*#~AYO--Zp0 zuO>`5GGT%VXf$xNt_77E@S2*=buFUa2i4n1*U>3k7swRYhO$8gw#Gvti3u7L5jRwSA@G1=?wV>4+V5Ok8|Nj@v`dI`Q zY*4Blm#=jNJde9ysvtYxl0Uwp}0`#}pfG zFE7O}9V98n#$_T|$il`eBqhpzUqFEwhtvap1;({|89Dy_*t_@N4@Qo?EjxC!wCvcy zZ5YAGXlBkNC@QPrX2YbyEzHl%s>m56ENg~cCXz=Mysklufq@CM4hu3a2I>EUyYHZp qF;I9Zf=0$bI0lpljEszoKx0K98Z;JQ*5KD*mG$dXgI@y!0|NkCXyHQu literal 0 HcmV?d00001 diff --git a/main.py b/main.py new file mode 100644 index 0000000..6ea3dcb --- /dev/null +++ b/main.py @@ -0,0 +1,20 @@ +from setup import * +from game import Game + +screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT), pygame.RESIZABLE) +delta = 1000/fps +is_running = True + +scene = Game() + +while is_running: + if pygame.event.peek(pygame.QUIT): + is_running = False + + scene.update(delta) + scene.draw(screen) + + pygame.display.update() + delta = clock.tick(fps) + +pygame.quit() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..410e284 --- /dev/null +++ b/setup.py @@ -0,0 +1,28 @@ +import pygame +import math +import random +pygame.init() + +SCREEN_WIDTH, SCREEN_HEIGHT = 1920/2, 1080/2 +dimensions = (SCREEN_WIDTH, SCREEN_HEIGHT) +center = pygame.Vector2(SCREEN_WIDTH/2, SCREEN_HEIGHT/2) + +pygame.display.set_caption("Basketball") +# icon = pygame.image.load("logo.ico") +# icon = pygame.transform.scale(icon, (32, 32)) +# pygame.display.set_icon(icon) + +clock = pygame.time.Clock() +fps = 120 + + +class Colour: + BLACK = (0, 0, 0) + WHITE = (255, 255, 255) + GRAY = (127, 127, 127) + DARK_GRAY = (40, 40, 40) + LIGHT_GRAY = (200,200,200) + RED = (204, 0, 0) + BLUE = (100, 149, 237) + ORANGE = (244, 187, 68) + TAN = (242, 210, 189) -- 2.54.0