diff --git a/.gitignore b/.gitignore index ed8ebf5..1814464 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -__pycache__ \ No newline at end of file +__pycache__ +/desktop.ini \ No newline at end of file diff --git a/Hang Man/desktop.ini b/Hang Man/desktop.ini new file mode 100644 index 0000000..d957fd1 --- /dev/null +++ b/Hang Man/desktop.ini @@ -0,0 +1,4 @@ +[ViewState] +Mode= +Vid= +FolderType=Generic diff --git a/No Way Down/desktop.ini b/No Way Down/desktop.ini new file mode 100644 index 0000000..d957fd1 --- /dev/null +++ b/No Way Down/desktop.ini @@ -0,0 +1,4 @@ +[ViewState] +Mode= +Vid= +FolderType=Generic diff --git a/Ping-Pong/desktop.ini b/Ping-Pong/desktop.ini new file mode 100644 index 0000000..d957fd1 --- /dev/null +++ b/Ping-Pong/desktop.ini @@ -0,0 +1,4 @@ +[ViewState] +Mode= +Vid= +FolderType=Generic diff --git a/Space Invaders type-2/desktop.ini b/Space Invaders type-2/desktop.ini new file mode 100644 index 0000000..d957fd1 --- /dev/null +++ b/Space Invaders type-2/desktop.ini @@ -0,0 +1,4 @@ +[ViewState] +Mode= +Vid= +FolderType=Generic diff --git a/Space Invaders/desktop.ini b/Space Invaders/desktop.ini new file mode 100644 index 0000000..d957fd1 --- /dev/null +++ b/Space Invaders/desktop.ini @@ -0,0 +1,4 @@ +[ViewState] +Mode= +Vid= +FolderType=Generic diff --git a/Tank Maniac/Buttons.py b/Tank Maniac/Buttons.py new file mode 100644 index 0000000..1dde190 --- /dev/null +++ b/Tank Maniac/Buttons.py @@ -0,0 +1,134 @@ +import pygame +from pygame import mouse, BLEND_RGB_ADD +from pygame import mixer + +mixer.init() + +Colours = {"red":[(255,0,0),(255,77,77),(220,0,0)],"white":[(240,240,240),(250,250,250),(210,215,220)],"green":[(0,255,0),(77,255,77),(38,128,38)]} +#================================================================================================== +path = "E:/Python Programs/Projects/Self-Projects/Tank_maniac/Assets" +Button_pressed_sound = mixer.Sound(f"{path}/Music/Button_pressed.wav") +Button_pressed_sound.set_volume(0.4) +Hover_sound = mixer.Sound(f"{path}/Music/hover.wav") +Hover_sound.set_volume(0.2) +#================================================================================================== +class Show_Text(): + def __init__(self,Display,Text,Size,Colour,PosX,PosY,Font="georgia",Bold=False,Italic=False): + self.display = Display + self.text = Text + self.Colour = Colour + self.Posx,self.Posy = PosX, PosY + self.font = pygame.font.SysFont(Font, Size ,bold=Bold,italic=Italic) + + def Update(self, text): + self.text = text + + def Draw(self): + self.Update(self.text) + txt = self.font.render(self.text,True,self.Colour) + self.display.blit(txt,(self.Posx,self.Posy)) + + def Delete(self): + del self +#================================================================================================== +class Button(): + """ Used to Create a button with parameters -> colour, x , y, width , height, **text""" + def __init__(self,Display, colour, x, y, width, height, text="",font='rockwell', font_size=30, font_colour=(0,0,0),fill=(177,167,166), Hover_colour=None,Fill=True, Command=None,Bold=False): + self.x, self.y = x, y + self.window = Display + self.width, self.height = width, height + self.colour = colour + self.pos = [0,0] + self.cmd_done, self.cur_press, self.pressed = False, False, False + self.rect = pygame.Rect(self.x, self.y, self.width, self.height) + self.hover_rect = pygame.Rect(0, 0, self.width, self.height) + self.main_rect_width = 2 + if Hover_colour: self.hover_colour = Hover_colour + else: self.hover_colour = colour + if Command: self.command = Command + else: self.command = None + But_font = pygame.font.SysFont(font,font_size, bold=Bold) + if text != "": self.text = But_font.render(text, 1 ,font_colour) + else : self.text = None + self.surf = pygame.Surface((width,height)) + self.surf.set_colorkey((0,0,0)) + self.fill_button = fill + + def Draw(self): + self.pos = pygame.mouse.get_pos() + mouse_rect = pygame.Rect(self.pos[0],self.pos[1], 1, 1) + if self.rect.colliderect(mouse_rect): + self.cur_press = pygame.mouse.get_pressed()[0] + pygame.draw.rect(self.surf, self.fill_button, self.hover_rect) + self.window.blit(self.surf, (self.rect.x,self.rect.y), special_flags=BLEND_RGB_ADD) + if self.cur_press: + self.pressed = True + Button_pressed_sound.play() + if self.command: + self.command() + self.cmd_done = True + else: self.cmd_done = False + pygame.draw.rect(self.window, self.colour, self.rect,self.main_rect_width) + if self.text: self.window.blit(self.text,( self.x + (self.width/2 - self.text.get_width()/2),self.y + (self.height/2 - self.text.get_height()/2))) + + def Pressed(self): + if self.pressed: return True + return False + + def Delete(self): + del self +#================================================================================================== +class Hover_button(): + def __init__(self,Display, colour, x, y, width, height, text="",font='bookmanoldstlye', font_size=30, font_colour=(0,0,0), Hover_colour=None,bold=False, Command=None): + self.x, self.y = x, y + self.window = Display + self.width, self.height = width, height + self.text ,self.font = text, font + self.font_size, self.font_colour = font_size, font_colour + self.colour, self.bold = colour, bold + self.pos = [0,0] + self.rect = pygame.Rect(self.x, self.y, self.width, self.height) + self.cmd_done , self.press = False, False + if Hover_colour: self.hover_colour = Hover_colour + else: self.hover_colour = Colours[self.colour] + if Command: self.command = Command + else: self.command = None + self.hoverred = 0 + + def Draw(self): + self.pos = pygame.mouse.get_pos() + mouse_rect = pygame.Rect(self.pos[0],self.pos[1], 1, 1) + But_font = pygame.font.SysFont(self.font,self.font_size, bold=self.bold) + if self.text != "": + pressed = pygame.mouse.get_pressed()[0] + if self.rect.colliderect(mouse_rect): + self.hoverred += 1 + if self.hoverred == 1: Hover_sound.play() + + But_text = But_font.render(self.text, 1 ,self.hover_colour) + self.window.blit(But_text,( self.x + (self.width/2 - But_text.get_width()/2),self.y + (self.height/2 - But_text.get_height()/2))) + if pressed: + self.press = True + Button_pressed_sound.play() + if self.command: + self.command() + self.cmd_done = True + else: self.cmd_done = False + else: + self.hoverred = 0 + But_text = But_font.render(self.text, 1 ,self.font_colour) + self.window.blit(But_text,( self.x + (self.width/2 - But_text.get_width()/2),self.y + (self.height/2 - But_text.get_height()/2))) + + def Hover(self): + self.pos = pygame.mouse.get_pos() + mouse_rect = pygame.Rect(self.pos[0],self.pos[1], 1, 1) + if self.rect.colliderect(mouse_rect): return True + return False + + def Pressed(self): + if self.press: return True + return False + + def Delete(self): + del self +#================================================================================================== \ No newline at end of file diff --git a/Tank Maniac/Game_player.py b/Tank Maniac/Game_player.py new file mode 100644 index 0000000..73290d0 --- /dev/null +++ b/Tank Maniac/Game_player.py @@ -0,0 +1,295 @@ +from time import sleep +import pygame +from pygame import BLEND_RGB_ADD +from math import sin, cos, radians, atan2, degrees +#================================================================================================== +path = "E:/Python Programs/Projects/Self-Projects/Tank_maniac/Assets" # If path changed goto Load_map and set path their too +#================================================================================================== +WID, HIE = 32, 32 +def load_burst_animation(): + burst_image = pygame.image.load(f"{path}/Burst/burst.png") + burst_image_width = burst_image.get_width() + total_image = burst_image_width // WID + img_list = [] + for img_no in range(total_image): + image = pygame.Surface((WID,HIE)) + image.blit(burst_image, (0,0), ( (img_no * WID), 0, WID, HIE) ) + image.set_colorkey((0,0,0)) + img_list.append(image) + return img_list +#================================================================================================== +class Player: + def __init__(self,display,initial_x,intial_y,X_limit_left,X_limit_right,X_movement_speed=2,Vessle_rotate_speed=0.5,type_char="player1") -> None: + self.screen = display + self.x, self.y = initial_x, intial_y + self.Movement_speed = X_movement_speed + self.Player_width, self.Player_height = 60, 40 + self.rect = pygame.Rect(self.x, self.y,self.Player_width,self.Player_height) + self.left_limit, self.right_limit = X_limit_left, (X_limit_right - self.Player_width) + + self.damage_rect = pygame.Rect(self.x, self.y,self.Player_width+2,self.Player_height+2) + self.live = True + + self.rotate_speed = Vessle_rotate_speed + self.angle = 10 + self.shoot_thrust = 5 + + self.health = 100 + self.play_damage_animation = True + self.animation_frame = 0 + self.Current_thrust_percnt, self.change_thrust_frame = 0, 0 + + self.player_type = type_char + if self.player_type == 'player1': + self.lower_angle, self.higher_angle = 10, 60 + self.image = pygame.image.load(f"{path}/Players/player.png") + self.gun_vessle = pygame.image.load(f"{path}/Players/player_gun.png") + else: + self.lower_angle, self.higher_angle = -60, -10 + self.image = pygame.image.load(f"{path}/Players/enemy.png") + self.gun_vessle = pygame.image.load(f"{path}/Players/enemy_gun.png") + self.image = pygame.transform.scale(self.image,(self.Player_width,self.Player_height)) + self.gun_vessle = pygame.transform.scale(self.gun_vessle,(80,15)) + self.burst_animation = load_burst_animation() + + def rotate_gun_vessle(self,direction=""): + # limiting the angle of the Gun Vessle + if self.player_type == 'player1': + if direction == "up": self.angle += self.rotate_speed + elif direction == "down": self.angle -= self.rotate_speed + else: + if direction == "up": self.angle -= self.rotate_speed + elif direction == "down": self.angle += self.rotate_speed + + def _limit_vessle_angle(self): + # limiting the angle of the Gun Vessle + if self.angle >= self.higher_angle: + self.angle = self.higher_angle + elif self.angle <= self.lower_angle: + self.angle = self.lower_angle + + def _get_vessle_point(self): + if self.player_type == 'player1': + self.image_centre_x = self.x + (self.Player_width - 22) + self.image_centre_y = self.y + 7 + else: + self.image_centre_x = self.x + 22 + self.image_centre_y = self.y + 7 + self.gun_vessle_copy = pygame.transform.rotate(self.gun_vessle, int(self.angle)) + vessle_rect = self.gun_vessle_copy.get_rect() + vessle_rect.center = (self.image_centre_x, self.image_centre_y) + return vessle_rect.x, vessle_rect.y + + def adjust_shoot_thrust(self,input=0): + Lower_limit, Higher_limit = 1, 8 + thrust_change_speed = 0.1 + if (input != 0) and (self.change_thrust_frame % 6 == 0): + if input == 1: self.shoot_thrust += thrust_change_speed + elif input == -1: self.shoot_thrust -= thrust_change_speed + + if self.shoot_thrust <= Lower_limit: self.shoot_thrust = Lower_limit + elif self.shoot_thrust >= Higher_limit: self.shoot_thrust = Higher_limit + + self.shoot_thrust = float( int(self.shoot_thrust * 100) / 100) + self.Current_thrust_percnt = (self.shoot_thrust ) / Higher_limit + self.Current_thrust_percnt = int(self.Current_thrust_percnt * 100) + return str(self.Current_thrust_percnt) + + def Shoot(self): + if self.angle > 0: rad = radians(self.angle) + else: rad = radians( self.angle * -1) + + X_power, Y_power = self.shoot_thrust * cos(rad), self.shoot_thrust * sin(rad) + X_power, Y_power= float(int(X_power*100)/100),float(int(Y_power*100)/100) + if self.angle < 0: X_power = X_power * -1 + + length = self.gun_vessle.get_width() // 2 + x_add = length * cos(rad) + y_sub = length * sin(rad) + + if self.player_type == 'player1': blt_x = self.image_centre_x + x_add + else: blt_x = self.image_centre_x - x_add + blt_y = self.image_centre_y - y_sub + + return X_power, Y_power, blt_x, blt_y, (self.shoot_thrust*2) + + def get_damage(self, damage): + self.health = self.health - int(damage) + + def player_life_state(self): + if self.health < 2: self.live = False + + def play_destruction_animation(self): + destroyed_image = pygame.transform.scale(self.burst_animation[self.animation_frame],(self.Player_width,self.Player_height)) + self.screen.blit( destroyed_image ,(self.x,self.y)) + if (self.change_thrust_frame % 6 == 0): + self.animation_frame += 1 + if self.animation_frame == len(self.burst_animation): + self.play_damage_animation = False + + def finished_animation(self): + if self.play_damage_animation: + return False + return True + + def get_rect(self): + return self.damage_rect + + def get_health(self): + return self.health + + def get_states(self,angles=False): + center_coord = self.rect.center + player_state = [int(center_coord[0]),int(self.angle*10),int(self.shoot_thrust*10)] + if angles: + return [self.lower_angle, self.higher_angle] + return player_state + + def Move(self,dir=0): + if dir!=0: + if dir == -1: self.x -= self.Movement_speed + elif dir == 1: self.x += self.Movement_speed + + if self.x >= self.right_limit: self.x = self.right_limit + elif self.x <= self.left_limit : self.x = self.left_limit + self.rect.x = self.x + self.rect.y = self.y + self.damage_rect.center = self.rect.center + + def Draw(self): + self.change_thrust_frame += 1 + self.player_life_state() + if self.live: + self._limit_vessle_angle() + X, Y = self._get_vessle_point() + self.screen.blit(self.gun_vessle_copy, (X, Y)) + self.screen.blit( self.image ,(self.x,self.y)) + else: + self.play_destruction_animation() + if (self.change_thrust_frame % 6 == 0): + self.change_thrust_frame = 0 + + def Delete(self): + del self +#================================================================================================== +class Cannon_ball(): + def __init__(self, screen): + self.screen = screen + self.PositionX, self.PositionY = 500, 300 + self.cur_pos_x, self.cur_pos_y = float(self.PositionX), float(self.PositionY) + self.velocityx, self.velocityy = 0.0, 0.0 + self.gravity = 0.08 + self.colour = (200,200,200) + + self.size = 5 + self.burst = False + self.framee = 0 + + self.theta, self.anglee = 0.0, 0 + self.cannon_image = pygame.image.load(f"{path}/Players/Cannon.png") + self.image_width , self.image_height = self.cannon_image.get_width(), self.cannon_image.get_height() + self.image_rect = pygame.Rect(0,0, self.image_width, self.image_width) + + self.path_trace_particles = [] + self.should_move = True + + self.burst_animation = load_burst_animation() + self.play_burst_animation, self.finished = False, False + self.animation_frame = 0 + + def set_velocity(self,x,y): + self.velocityx = x + self.velocityy = (-1 * y) + self.burst, self.finished = False, False + self.path_trace_particles = [] + + def Move(self): + self.PositionX = int(self.cur_pos_x) + self.PositionY = int(self.cur_pos_y) + self.cur_pos_x += self.velocityx + self.cur_pos_y += self.velocityy + self.velocityy += self.gravity + + self.theta = atan2(self.velocityy,self.velocityx) + self.anglee = int(degrees(self.theta)) + + def stop(self): + self.cur_pos_x, self.cur_pos_y = 1000,1000 + self.should_move = False + + def set_position(self,x,y): + self.should_move = True + self.cur_pos_x, self.cur_pos_y = x, y + + def Position(self): + return self.PositionX, self.PositionY + + def check_collision(self,turn,player_rects=[],rects=[]): + if not self.burst: + collided_ply = -1 + turn_no = turn - 1 + if self.image_rect.colliderect(player_rects[turn_no]): + turn_no *= -1 + collided_ply = turn_no + self.burst = True + if rects: + for r in rects: + if self.image_rect.colliderect(r): + self.burst = True + return collided_ply, self.burst, self.finished + return -1, self.burst, self.finished + + def path_traceses(self): + part_x, part_y = self.image_rect.center + particle = [part_x,part_y,self.size] + self.path_trace_particles.append(particle) + + for partcl in self.path_trace_particles: + partcl[2] -= 0.1 + if partcl[2] <= 3.5: self.path_trace_particles.remove(partcl) + + def draw_path_traceses(self): + for particle in self.path_trace_particles: + s = int(particle[2]) + 5 + surf = pygame.Surface((s,s)) + pygame.draw.circle(surf, (20,20,15), ( int(particle[2]) , int(particle[2]) ), s) + surf.set_colorkey((0,0,0)) + self.screen.blit(surf, (particle[0]-s+2, particle[1]-s+2 ), special_flags=BLEND_RGB_ADD) + + def collide_animation(self): + if self.burst: + self.play_burst_animation = True + self.should_move = False + if self.play_burst_animation and (not self.finished): + self.screen.blit(self.burst_animation[self.animation_frame], self.image_rect.center) + self.framee += 1 + + if (self.framee % 8 == 0): + self.framee = 0 + if self.play_burst_animation: + self.animation_frame += 1 + if self.animation_frame == (len(self.burst_animation) - 1): + self.finished = True + if self.animation_frame == len(self.burst_animation): + self.animation_frame = 0 + self.play_burst_animation, self.burst = False, False + self.stop() + + def rotate_cannon_ball(self): + self.cannon = pygame.transform.rotate(self.cannon_image, int(-1* self.anglee)) + self.image_rect = self.cannon.get_rect() + self.image_rect.center = (self.PositionX, self.PositionY) + + def Draw(self): + if self.burst: + self.collide_animation() + if self.should_move: + self.Move() + self.rotate_cannon_ball() + self.path_traceses() + self.draw_path_traceses() + self.screen.blit(self.cannon,(self.image_rect.x, self.image_rect.y)) + + def Delete(self): + del self +#================================================================================================== \ No newline at end of file diff --git a/Tank Maniac/Platform_loader.py b/Tank Maniac/Platform_loader.py new file mode 100644 index 0000000..49cd1a5 --- /dev/null +++ b/Tank Maniac/Platform_loader.py @@ -0,0 +1,79 @@ +import csv, pygame +from random import randint + +path = "E:/Python Programs/Projects/Self-Projects/Tank_maniac/Assets" +Tile_size = 24 + +# Path for Level Files +levels = [f"{path}\Level\level_1.csv",f"{path}\Level\level_2.csv",f"{path}\Level\level_3.csv"] +#================================================================================================== +class Tiles: + def __init__(self,Surface): + self.path = f"{path}/Tile" + self.screen = Surface + self.level = '' + self.tiles_list = self.load_tile_sprites() + self.tiles_rects = [] + + def load_tile_sprites(self): + tile_image = pygame.image.load(f"{self.path}/tiles_sprite.png") + tiles_set = tile_image.get_width() + total_image = tiles_set // Tile_size + img_list = [] + for img_no in range(total_image): + image = pygame.Surface((Tile_size,Tile_size)) + image.blit(tile_image, (0,0), ( (img_no * Tile_size), 0, Tile_size,Tile_size) ) + image.set_colorkey((0,0,0)) + img_list.append(image) + image = pygame.Surface((Tile_size,Tile_size)) + tile_image = pygame.image.load(f"{self.path}/tile.png") + image.blit(tile_image, (0,0), ( (img_no * Tile_size), 0, Tile_size,Tile_size) ) + image.set_colorkey((0,0,0)) + img_list.append(image) + + return img_list + + def load_level(self): + global levels + no = randint(0, 2) + f = open(levels[no],"r") + rd = csv.reader(f) + lvl = [] + for line in rd: + x = line + lvl.append(x) + self.level = lvl + + def get_tile_rect(self): + return self.tiles_rects + + def Draw(self): + Level = self.level + tiles_rect = [] + y = 0 + for row in Level: + x = 0 + for tile in row: + if tile == "0": + self.screen.blit(self.tiles_list[1],(x*Tile_size, y*Tile_size)) + if tile == "1": + left_rotate = pygame.transform.rotate(self.tiles_list[4],90) + self.screen.blit(left_rotate,(x*Tile_size, y*Tile_size)) + if tile == "2": + right_rotate = pygame.transform.rotate(self.tiles_list[4],-90) + self.screen.blit(right_rotate,(x*Tile_size, y*Tile_size)) + if tile == "4": + self.screen.blit(self.tiles_list[4],(x*Tile_size, y*Tile_size)) + if tile == "5": + self.screen.blit(self.tiles_list[3],(x*Tile_size, y*Tile_size)) + if tile == "6": + self.screen.blit(self.tiles_list[5],(x*Tile_size, y*Tile_size)) + if tile in ["0","1","2","4","5","6"]: + tiles_rect.append(pygame.Rect(x*Tile_size,y * Tile_size, Tile_size, Tile_size)) + x+=1 + y+=1 + self.tiles_rects = tiles_rect + + def Delete(self): + del self +#================================================================================================== \ No newline at end of file diff --git a/Tank Maniac/desktop.ini b/Tank Maniac/desktop.ini new file mode 100644 index 0000000..d957fd1 --- /dev/null +++ b/Tank Maniac/desktop.ini @@ -0,0 +1,4 @@ +[ViewState] +Mode= +Vid= +FolderType=Generic diff --git a/Tank Maniac/main.py b/Tank Maniac/main.py index e69de29..07e57e2 100644 --- a/Tank Maniac/main.py +++ b/Tank Maniac/main.py @@ -0,0 +1,732 @@ +import pygame + +from pygame import * +from pygame import mixer +from pygame import K_UP, K_DOWN, K_RIGHT, K_LEFT, K_SPACE, K_UP, K_ESCAPE, K_BACKSPACE +from pygame import K_q, K_s, K_a, K_d, K_h, KEYUP, KEYDOWN, QUIT, init, Surface + +from Buttons import Hover_button, Button, Show_Text +from Game_player import Player, Cannon_ball +from Platform_loader import Tiles + +from random import randint +# ============================================ Initialise Pygame ============================================ +init() +mixer.init() +# ============================================ Path for the assets ================================= +# If path changed goto Load_map and set path their too +path = "E:/Python Programs/Games on PC/Tank_maniac/Assets" +# ============================================ Create the screen ============================================ +Width, Height = 912, 504 +WindowSize = (Width, Height) +screen = pygame.display.set_mode(WindowSize) +icon = pygame.image.load(f"{path}/icon.png") +pygame.display.set_icon(icon) +# ============================================ Caption and Icon ============================================= +pygame.display.set_caption('Tank Battle') +# ============================================ Game Surface to render ======================================= +Game_Surface = Surface(WindowSize) +# ============================================ ============== ====================================== +# FPS Setting +Clock = pygame.time.Clock() +FPS = 60 +# ================================================================================================== +burst_music = mixer.Sound(f"{path}/Music/burst_sound.wav") +shoot_music = mixer.Sound(f"{path}/Music/shoot_music.wav") +shoot_music.set_volume(0.4) +burst_music.set_volume(0.4) +# Playing the Background Music +mixer.music.load(f"{path}/Music/background_music.mp3") +mixer.music.set_volume(0.2) +mixer.music.play(-1) +# ================================================================================================== +BG = (110, 110, 110) +BACK_IMAGE = pygame.image.load(f"{path}/background/background.png").convert_alpha() +BACK_IMAGE = pygame.transform.scale(BACK_IMAGE, (Width, Height)) +WINNER = "" +MODE_TYPE = "oneplayer" +exit_func_loop = False +# ================================================================================================== + +def exiit(): + """ Will set the Exit_fun_loop value -> True; thus the game will be finished/destroyed """ + global exit_func_loop + exit_func_loop = True + +def Hovver(*args): + """Will check whether the Mouse pointer is on Hover Button or not + Returns: + True: If mouse is on any hover buton + """ + n = 0 + for object in args: + x = object.Hover() + n += 1 + if x: + return n + else: + return 0 + +def Draw_object(*args): + """ Will Draw all the Object entity that are passed into the Arguments; Drawing of Object depends on the game-surface given to them at initialisation + """ + for Object in args: + Object.Draw() + +def Del_objects(*args): + """ Will Delete all the Object entity that are passed into the Arguments. + """ + for Obeject in args: + Obeject.Delete() + +def Check_Mouse_button_down(*args): + """ Will check whether the button is Pressed or not; + Returns: + True: if any Button pressed + """ + for Object in args: + x = Object.Pressed() + if x: + return True + else: + return False +# ================================================================================================== + +def collision_check_rect(player1: Player, player2: Player): + """ + Args: + player1 , player2 : Player class entity from 'the_player' module + Returns: + List of the Rect of the Players + """ + rect_list = [] + rect_list.append(player1.get_rect()) + rect_list.append(player2.get_rect()) + return rect_list +# ================================================================================================== + +def Enemy_controls(list_of_state: list, State_to_do: list, shoot: bool): + """ Generates the Controls for the Enemy [to move, rotate it's vessle, and change it's thrust] + Args: + list_of_state [list]: the current state of the Enemy + State_to_do [list]: the state of Enemy to be set + shoot : the current value of shoot in the function + Returns: + [List]: Automated-Controls list for the Enemy (Played by Comp.) + """ + [Center, angle, thrust_per] = list_of_state + [set_Center_x, set_angle, set_thrust_per] = State_to_do + [Vessle_Rotating_direction, Movement_direction, change_shoot_thrust] = [0, 0, 0] + C, A, T = True, True, True + + if (Center != set_Center_x): + if Center > set_Center_x: + Movement_direction = -1 + elif Center < set_Center_x: + Movement_direction = 1 + else: + C = False + + if angle < 0: + angle *= -1 + set_angle *= -1 + if (angle != set_angle): + if angle > set_angle: + Vessle_Rotating_direction = -1 + elif angle < set_angle: + Vessle_Rotating_direction = 1 + else: + A = False + + if (thrust_per != set_thrust_per): + if thrust_per > set_thrust_per: + change_shoot_thrust = -1 + elif thrust_per < set_thrust_per: + change_shoot_thrust = 1 + else: + T = False + + z = (C == A == T == False) + if z: + shoot = True + return [Vessle_Rotating_direction, Movement_direction, change_shoot_thrust, shoot] +# ================================================================================================== + +def Generate_controls(anglee: list): + """When their is Chance of Comp./Automated Enemy + it will generate the random Value for the Enemy to be done + Args: + anglee: List of Max. and Min. andgle of the Enemy + + Returns: + State_to_do [list]: The state to which the Enemy have to obtain for it's next Shoot + """ + lower, higher = anglee + set_Center_x = randint(540, 820) + set_angle = randint(lower*10, higher*10) + set_thrust = randint(40, 75) + + if (set_Center_x % 5 != 0): + x = set_Center_x//5 + set_Center_x = x * 5 + if (set_Center_x % 2 == 1): + set_Center_x -= 1 + + if (set_thrust % 2 == 0): + set_thrust = set_thrust - 1 + + if (set_angle % 5 != 0): + set_angle = (set_angle//5) * 5 + + return [set_Center_x, set_angle, set_thrust] +# ================================================================================================== + +def game_requirements(): + """ + Returns: + [list]: Assets list required for the Game-screen [include home/exit button, Players; their health-status,power status bars] + """ + Home_but = Hover_button(Game_Surface, "white", 20, 10, 90, 20, "Home", 'Georgia', + 20, (255, 55, 55), Hover_colour=(212, 21, 24), bold=True) # ,(200,37,2) + Exit_but = Hover_button(Game_Surface, "white", 800, 10, 90, 20, "Exit", 'Georgia', 20, ( + 255, 55, 55), Hover_colour=(255, 5, 5), bold=True, Command=exiit) # ,(200,37,2) + + health_bar_color = (90, 100, 80) + plyr = Player(Game_Surface, 90, 350, 40, 400, type_char='player1') + health_show_1 = Show_Text( + Game_Surface, f"Health Player 1:{plyr.get_health()}", 18, health_bar_color, 20, 50, 'Georgia') + enmy = Player(Game_Surface, 750, 350, 512, 872, type_char='player2') + health_show_2 = Show_Text( + Game_Surface, f"Health Player 2 :{enmy.get_health()}", 18, health_bar_color, 720, 50, 'Georgia') + + Players = [plyr, enmy] + Turn_no = 0 + + Cannon = Cannon_ball(Game_Surface) + Cannon.stop() + play_burst_music = True + sht_per = '0' + Shoot_thrust_percent = Show_Text( + Game_Surface, sht_per, 34, (68, 69, 92), 360, 10, 'forte') + + platform = Tiles(Game_Surface) + + quit_count = 0 + exit_func_loop, shoot, shooted = False, False, False + wait_over = True + Vessle_Rotating_direction, Movement_direction, change_shoot_thrust = 0, 0, 0 + return [Home_but, Exit_but, plyr, health_show_1, enmy, health_show_2, Players, Turn_no, Cannon, sht_per, Shoot_thrust_percent, quit_count, shoot, shooted, wait_over, exit_func_loop, play_burst_music, Vessle_Rotating_direction, Movement_direction, change_shoot_thrust, platform] +# ================================================================================================== + +def controls(Vessle_Rotating_direction, Movement_direction, change_shoot_thrust, quit_count, wait_over, exit_func_loop, shoot): + """ Func that used will take Commands from the Players(s) + Returns: + list of command that are generated by user + """ + shoot, Go_to_home = False, False + for event in pygame.event.get(): + if event.type == QUIT: + exit_func_loop = True + + if event.type == KEYDOWN: + if event.key == K_q: + exit_func_loop = True if quit_count == 2 else False + if wait_over and (WINNER == ""): + if event.key == K_LEFT: + Movement_direction = -1 + if event.key == K_RIGHT: + Movement_direction = 1 + + if event.key == K_UP: + Vessle_Rotating_direction = 1 + if event.key == K_DOWN: + Vessle_Rotating_direction = -1 + + if event.key == K_a: + change_shoot_thrust = -1 + if event.key == K_d: + change_shoot_thrust = 1 + + if event.type == KEYUP: + if event.key == K_h: + Go_to_home = True + + if event.key == K_q: + quit_count += 1 + + if (event.key == K_LEFT) or (event.key == K_RIGHT): + Movement_direction = 0 + if (event.key == K_UP) or (event.key == K_DOWN): + Vessle_Rotating_direction = 0 + if (event.key == K_a) or (event.key == K_d): + change_shoot_thrust = 0 + + if event.key == K_SPACE: + if wait_over: + shoot = True + + return [[Vessle_Rotating_direction, Movement_direction, change_shoot_thrust, shoot], [quit_count, wait_over, exit_func_loop, Go_to_home]] +# ================================================================================================== + +def One_player_mode(): + """ Game-Function used for only Single Player game""" + global WINNER, exit_func_loop + WINNER = "" + Game_assests = game_requirements() + Home_but, Exit_but, plyr, health_show_1, enmy, health_show_2, Players, Turn_no, Cannon, sht_per, Shoot_thrust_percent, quit_count, shoot, shooted, wait_over, exit_func_loop, play_burst_music, Vessle_Rotating_direction, Movement_direction, change_shoot_thrust, platform = Game_assests + platform.load_level() + Game_assests = [] + Player_Can_shoot = True + Enemy_can_shoot = True + State_to_do = [0, 0, 0] + # ============================================================================================= + Go_to_home, Go_to_win_screen, Go_home_screen = False, False, False + # ============================================================================================== + while True: + # Game_Surface.fill(BG) + Game_Surface.blit(BACK_IMAGE, (0, 0)) + # Taking Input from the Player + Game_Controlls = controls(Vessle_Rotating_direction, Movement_direction, + change_shoot_thrust, quit_count, wait_over, exit_func_loop, shoot) + if Player_Can_shoot and (Turn_no == 0): + [Vessle_Rotating_direction, Movement_direction, change_shoot_thrust, shoot], [ + quit_count, wait_over, exit_func_loop, Go_home_screen] = Game_Controlls + else: + _, [quit_count, wait_over, exit_func_loop, + Go_home_screen] = Game_Controlls + # ========================================================================================== + if Turn_no == 1: + [Vessle_Rotating_direction, Movement_direction, change_shoot_thrust, + shoot] = Enemy_controls(Players[Turn_no].get_states(), State_to_do, shoot) + if shoot: + Player_Can_shoot = True + # ========================================================================================== + if exit_func_loop: break + # ========================================================================================== + if shoot and ((Player_Can_shoot and Turn_no == 0) or (Player_Can_shoot and Enemy_can_shoot)): + X_thrust, Y_thrust, blt_x, blt_y, shot_power = Players[Turn_no].Shoot() + Cannon.set_velocity(X_thrust, Y_thrust) + Cannon.set_position(blt_x, blt_y) + shoot, wait_over = False, False + shooted, play_burst_music = True, True + shoot_music.play() + if Turn_no == 0: + Genrate_Enemy_controls = True + if Enemy_can_shoot: + Enemy_can_shoot = False + # ========================================================================================== + else: + # Checking for collision + Damage_plyr_no, bursted, cannon_fin = Cannon.check_collision(Turn_no, collision_check_rect(plyr, enmy), platform.get_tile_rect()) + + if Damage_plyr_no != -1: + Players[Damage_plyr_no].get_damage(shot_power) + ply1 = plyr.get_health() + ply2 = enmy.get_health() + health_show_1.Update(f"Health Player 1:{ply1}") + health_show_2.Update(f"Health Player 2:{ply2}") + if ply1 < 2: + WINNER = "Player 2" + elif ply2 < 2: + WINNER = "Player 1" + if WINNER: + wait_over = True + + if bursted: + if play_burst_music: + burst_music.play() + play_burst_music = False + if cannon_fin: + wait_over = True + + if (wait_over and shooted): + Turn_no += 1 + Turn_no = Turn_no % len(Players) + if Turn_no == 0: + Player_Can_shoot = True + elif Turn_no == 1: + Player_Can_shoot = False + if Genrate_Enemy_controls: + Enemy_can_shoot = True + State_to_do = Generate_controls( + Players[Turn_no].get_states(True)) + Genrate_Enemy_controls = False + shooted = False + # ====================================================================================== + if Vessle_Rotating_direction == 1: + Players[Turn_no].rotate_gun_vessle('up') + elif Vessle_Rotating_direction == -1: + Players[Turn_no].rotate_gun_vessle('down') + Players[Turn_no].Move(Movement_direction) + sht_per = f"Power :- {Players[Turn_no].adjust_shoot_thrust(change_shoot_thrust)}" + Shoot_thrust_percent.Update(sht_per) + # ========================================================================================== + # Drawing he players and the oblect of the level + Draw_object(platform, Home_but, Exit_but, plyr, enmy, Cannon, + Shoot_thrust_percent, health_show_1, health_show_2) + # ========================================================================================== + # Keeping the Frames on Limit, And Updating the Display + Clock.tick(FPS) + # Updating the Game Surface/Screen + if not exit_func_loop: + screen.blit(Game_Surface, (0, 0)) + pygame.display.update() + # ========================================================================================== + if WINNER: + fin = Players[Turn_no].finished_animation() + if fin: + Go_to_win_screen = True + # ========================================================================================== + Go_to_home = (Check_Mouse_button_down(Home_but) or Go_home_screen) + # ================================================================================================== + if exit_func_loop or Go_to_home or Go_to_win_screen: + Del_objects(Home_but, Exit_but, plyr, enmy, health_show_1, + health_show_2, Cannon, Shoot_thrust_percent, platform) + # ========================================================================================== + if Go_to_home: + Home_screen() + if Go_to_win_screen: + win_screen() + # ========================================================================================== + if exit_func_loop or Go_to_home or Go_to_win_screen: break +# ================================================================================================== + +def double_player_offline(): + """ Game function used for Two-Players Game """ + global WINNER, exit_func_loop + WINNER = "" + Game_assests = game_requirements() + Home_but, Exit_but, plyr, health_show_1, enmy, health_show_2, Players, Turn_no, Cannon, sht_per, Shoot_thrust_percent, quit_count, shoot, shooted, wait_over, exit_func_loop, play_burst_music, Vessle_Rotating_direction, Movement_direction, change_shoot_thrust, platform = Game_assests + Game_assests = [] + platform.load_level() + # ============================================================================================= + Go_to_home, Go_to_win_screen, Go_home_screen = False, False, False + # ============================================================================================== + while True: + Game_Surface.blit(BACK_IMAGE, (0, 0)) + # Taking Input from the Player(s) + Game_Controlls = controls(Vessle_Rotating_direction, Movement_direction, + change_shoot_thrust, quit_count, wait_over, exit_func_loop, shoot) + [Vessle_Rotating_direction, Movement_direction, change_shoot_thrust, shoot], [ + quit_count, wait_over, exit_func_loop, Go_home_screen] = Game_Controlls + # ========================================================================================== + if shoot: + X_thrust, Y_thrust, blt_x, blt_y, shot_power = Players[Turn_no].Shoot() + Cannon.set_velocity(X_thrust, Y_thrust) + Cannon.set_position(blt_x, blt_y) + shoot, wait_over = False, False + shooted, play_burst_music = True, True + shoot_music.play() + # ========================================================================================== + else: + # Checking for collision + Damage_plyr_no, bursted, cannon_fin = Cannon.check_collision( + Turn_no, collision_check_rect(plyr, enmy), platform.get_tile_rect()) + # ====================================================================================== + if Damage_plyr_no != -1: + Players[Damage_plyr_no].get_damage(shot_power) + ply1 = plyr.get_health() + ply2 = enmy.get_health() + health_show_1.Update(f"Health Player 1:{ply1}") + health_show_2.Update(f"Health Player 2:{ply2}") + + if ply1 < 2: + WINNER = "Player 2" + elif ply2 < 2: + WINNER = "Player 1" + if WINNER: + wait_over = True + + if bursted: + if play_burst_music: + burst_music.play() + play_burst_music = False + if cannon_fin: + wait_over = True + + if (wait_over and shooted): + Turn_no += 1 + Turn_no = Turn_no % len(Players) + shooted = False + # ====================================================================================== + if Vessle_Rotating_direction == 1: + Players[Turn_no].rotate_gun_vessle('up') + elif Vessle_Rotating_direction == -1: + Players[Turn_no].rotate_gun_vessle('down') + Players[Turn_no].Move(Movement_direction) + + sht_per = f"Power :- {Players[Turn_no].adjust_shoot_thrust(change_shoot_thrust)}" + Shoot_thrust_percent.Update(sht_per) + # ========================================================================================== + # Drawing he players and the oblect of the level + Draw_object(platform, Home_but, Exit_but, plyr, enmy, Cannon, + Shoot_thrust_percent, health_show_1, health_show_2) + # ========================================================================================== + # Keeping the Frames on Limit, And Updating the Display + Clock.tick(FPS) + # Updating the Game Surface/Screen + if not exit_func_loop: + screen.blit(Game_Surface, (0, 0)) + pygame.display.update() + # ========================================================================================== + if WINNER: + fin = Players[Turn_no].finished_animation() + if fin: + Go_to_win_screen = True + # ========================================================================================== + Go_to_home = (Check_Mouse_button_down(Home_but) or Go_home_screen) + # ========================================================================================== + if exit_func_loop or Go_to_home or Go_to_win_screen: + Del_objects(Home_but, Exit_but, plyr, enmy, health_show_1, + health_show_2, Cannon, Shoot_thrust_percent, platform) + # ========================================================================================== + if Go_to_home: + Home_screen() + if Go_to_win_screen: + win_screen() + # ========================================================================================== + if exit_func_loop or Go_to_home or Go_to_win_screen: break +# ================================================================================================== + +def game_screen(): + """ Will use Game-Mode-Function according to Mode_type selected by the Player(s) """ + global WINNER + WINNER = "" + + if MODE_TYPE == 'oneplayer': + One_player_mode() + + elif MODE_TYPE == 'twoplayers': + double_player_offline() +# ================================================================================================== + +def set_game_mode(): + """Game-Screen used to set the Game-Mode according to the Player(s)""" + global MODE_TYPE, exit_func_loop + + def One_Player_offline(): + global MODE_TYPE + MODE_TYPE = 'oneplayer' + + def Two_Player_offline(): + global MODE_TYPE + MODE_TYPE = 'twoplayers' + # ============================================================================================== + # Game name text that to be shown in the Home Screen + gmtxt = '- Tank Battle -' + Game_nm_text = Show_Text(Game_Surface, gmtxt, 70, + (20, 20, 20), 240, 130, 'forte') + # ============================================================================================== + Font_sizze = 24 + Font_type = 'Georgia' + Font_colour = (144, 106, 80) + Hover_color = (120, 80, 60) + # ============================================================================================== + option_text = Show_Text(Game_Surface, 'Select a mode', 30, + (120, 80, 60), 330, 300, Font_type, Bold=True, Italic=True) + set_one_player = Hover_button(Game_Surface, "white", 350, 360, 180, 20, "Single Player", Font_type, + Font_sizze, Font_colour, Hover_colour=Hover_color, bold=True, Command=One_Player_offline) + set_two_offline = Hover_button(Game_Surface, "white", 350, 410, 180, 20, "Double Players", Font_type, + Font_sizze, Font_colour, Hover_colour=Hover_color, bold=True, Command=Two_Player_offline) + # ============================================================================================== + quit_count = 0 + Pressed, exit_func_loop = False, False + Go_to_home, One_player_game, Two_player_game = False, False, False + # ================================================================================================== + while True: + Game_Surface.blit(BACK_IMAGE, (0, 0)) + Pressed = Check_Mouse_button_down(set_one_player, set_two_offline) + # ========================================================================================== + # Taking the input from the user + for event in pygame.event.get(): + if event.type == QUIT: + exit_func_loop = True + if event.type == KEYDOWN: + if event.key == K_q: + if quit_count == 2: + exit_func_loop = True + if event.type == KEYUP: + if event.key in [K_d, K_s]: + exit_func_loop, Pressed = True, True + if event.key == K_s: + One_player_game = True + if event.key == K_d: + Two_player_game = True + + if event.key == K_h: + exit_func_loop, Go_to_home = True, True + if event.key == K_q: + quit_count += 1 + # ========================================================================================== + Draw_object(set_one_player, set_two_offline, Game_nm_text, option_text) + # ========================================================================================== + # Keeping the Frames on Limit, And Updating the Display + Clock.tick(FPS) + # Updating the Game Surface/Screen + if not exit_func_loop: + screen.blit(Game_Surface, (0, 0)) + pygame.display.update() + # ================================================================================================== + if exit_func_loop or Pressed or Go_to_home or One_player_game or Two_player_game: + Del_objects(set_one_player, set_two_offline, + Game_nm_text, option_text) + # ========================================================================================== + if Go_to_home: + Home_screen() + if One_player_game: + One_Player_offline() + if Two_player_game: + Two_Player_offline() + if Pressed: + game_screen() + # ========================================================================================== + if exit_func_loop or Pressed or Go_to_home or One_player_game or Two_player_game: break +# ================================================================================================== + +def Home_screen(): + """ Home Screen of the Game """ + global exit_func_loop + Font_colour = (55, 55, 55) + # Game name text that to be shown in the Home Screen + gmtxt = '- Tank Battle -' + Game_nm_text = Show_Text(Game_Surface, gmtxt, 70, + (20, 20, 20), 240, 130, 'forte') + # ============================================================================================== + Start = Button(Game_Surface, (200, 200, 200), 290, 370, 120, + 45, "Start", 'bookmanoldstlye', 35, Font_colour, (15, 18, 25)) + Exitt = Button(Game_Surface, (250, 70, 70), 460, 370, 120, 45, "Exit", + 'bookmanoldstlye', 35, Font_colour, (250, 0, 0), Command=exiit) + # ============================================================================================== + Control_color = (68, 69, 92) + control_x = 230 + control_font_type = 'Georgia' + # Hover Button --> If mouse hover on this button Below written Controls will be Shown in the Screen + Show_Control = Hover_button(Game_Surface, "white", 400, 435, 90, 20, + "Controls", 'Georgia', 20, Font_colour, bold=True) # ,(200,37,2) + # Controls texts + ply_m = "Player & Gun Vessle Movements " + ply = Show_Text(Game_Surface, ply_m, 32, Control_color, 190, 80, Bold=True) + Player_movement = "To Move :- Left/Right arrow key" + Plyr_movmnt_show = Show_Text( + Game_Surface, Player_movement, 24, Control_color, control_x, 140, control_font_type) + vssl_movmnt = "Vessle Movement :- UP/DOWN arrow key" + vssl_movmnt_show = Show_Text( + Game_Surface, vssl_movmnt, 24, Control_color, control_x, 185, control_font_type) + power_chng = "Adjust Shoot Power :- 'A' / 'D' keys" + Change_power_show = Show_Text( + Game_Surface, power_chng, 24, Control_color, control_x, 230, control_font_type) + go_home_shortcut = "Home shortcut :- 'H' key" + go_home_shortcut_show = Show_Text( + Game_Surface, go_home_shortcut, 24, Control_color, control_x, 275, control_font_type) + sht = "Space Bar: To-Shoot/Start Game" + shoot = Show_Text(Game_Surface, sht, 24, Control_color, + control_x, 320, control_font_type) + qgt = "To exit :- Press 'Q'--> 3 Times" + qgt_s = Show_Text(Game_Surface, qgt, 24, Control_color, + control_x, 365, control_font_type) + # ============================================================================================== + i, quit_count = 0, 0 + Pressed, exit_func_loop, Go_to_set_game_mode = False, False, False + # ============================================================================================== + while True: + Game_Surface.blit(BACK_IMAGE, (0, 0)) + i = Hovver(Show_Control) + if i == 0: + Draw_object(Start, Show_Control, Exitt, Game_nm_text) + Pressed = Check_Mouse_button_down(Start) + else: + Draw_object(ply, Plyr_movmnt_show, Change_power_show, + vssl_movmnt_show, go_home_shortcut_show, shoot, qgt_s) + # ========================================================================================== + # Taking the input from the user + for event in pygame.event.get(): + if event.type == QUIT: + exit_func_loop = True + if event.type == KEYDOWN: + if event.key == K_q: + if quit_count == 2: + exit_func_loop = True + if event.type == KEYUP: + if event.key == K_SPACE: + exit_func_loop, Go_to_set_game_mode = True, True + if event.key == K_q: + quit_count += 1 + # ========================================================================================== + # Keeping the Frames on Limit, And Updating the Display + Clock.tick(FPS) + # Updating the Game Surface/Screen + if not exit_func_loop: + screen.blit(Game_Surface, (0, 0)) + pygame.display.update() + # ========================================================================================== + Go_to_set_game_mode = (Pressed or Go_to_set_game_mode) + # ========================================================================================== + if exit_func_loop or Go_to_set_game_mode: + Del_objects(ply, Plyr_movmnt_show, Change_power_show, vssl_movmnt_show, + go_home_shortcut_show, shoot, qgt_s, Start, Show_Control, Exitt, Game_nm_text) + # ========================================================================================== + if Go_to_set_game_mode: + set_game_mode() + # ========================================================================================== + if exit_func_loop or Go_to_set_game_mode: break +# ================================================================================================== + +def win_screen(): + """ Win-Screen of the Game """ + global WINNER, exit_func_loop + Font_colour = (55, 55, 55) + # Game name text that to be shown in the Home Screen + winnertext = f"Winner is :- {WINNER}" + winner_text_show = Show_Text( + Game_Surface, winnertext, 70, (60, 60, 80), 170, 140, 'forte') + # ============================================================================================== + Home_but = Button(Game_Surface, (200, 200, 200), 250, 370, 100, + 45, "Home", 'bookmanoldstlye', 35, Font_colour, (15, 8, 35)) + ReStart_but = Button(Game_Surface, (200, 250, 200), 370, 370, 120, + 45, "Restart", 'bookmanoldstlye', 35, Font_colour, (15, 18, 35)) + Exitt = Button(Game_Surface, (250, 70, 70), 530, 370, 100, 45, "Exit", + 'bookmanoldstlye', 35, Font_colour, (250, 0, 0), Command=exiit) + # ============================================================================================== + quit_count = 0 + Go_to_home, Go_to_game, exit_func_loop = False, False, False + # ============================================================================================== + while True: + Game_Surface.blit(BACK_IMAGE, (0, 0)) + Draw_object(Home_but, ReStart_but, Exitt, winner_text_show) + # ========================================================================================== + # Taking the input from the user + for event in pygame.event.get(): + if event.type == QUIT: + exit_func_loop = True + if event.type == KEYDOWN: + if event.key == K_q: + if quit_count == 2: + exit_func_loop = True + if event.type == KEYUP: + if event.key == K_q: + quit_count += 1 + # ========================================================================================== + # Keeping the Frames on Limit, And Updating the Display + Clock.tick(FPS) + # Updating the Game Surface/Screen + if not exit_func_loop: + screen.blit(Game_Surface, (0, 0)) + pygame.display.update() + # ========================================================================================== + Go_to_home = Check_Mouse_button_down(Home_but) + Go_to_game = Check_Mouse_button_down(ReStart_but) + # ========================================================================================== + if exit_func_loop or Go_to_home or Go_to_game: + Del_objects(Home_but, ReStart_but, Exitt, winner_text_show) + # ========================================================================================== + if Go_to_home: + Home_screen() + if Go_to_game: + game_screen() + # ========================================================================================== + if exit_func_loop or Go_to_home or Go_to_game: + break + +# ================================================================================================== +if __name__ == "__main__": + Home_screen()