├── audio ├── jump.wav ├── music2.mp3 ├── shot.wav └── grenade.wav ├── img ├── exit_btn.png ├── tile │ ├── 0.png │ ├── 1.png │ ├── 10.png │ ├── 11.png │ ├── 12.png │ ├── 13.png │ ├── 14.png │ ├── 15.png │ ├── 16.png │ ├── 17.png │ ├── 18.png │ ├── 19.png │ ├── 2.png │ ├── 20.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ └── 9.png ├── start_btn.png ├── enemy │ ├── Death │ │ ├── 0.png │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ ├── 5.png │ │ ├── 6.png │ │ └── 7.png │ ├── Idle │ │ ├── 0.png │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ └── 4.png │ ├── Jump │ │ └── 0.png │ └── Run │ │ ├── 0.png │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ └── 5.png ├── icons │ ├── bullet.png │ ├── grenade.png │ ├── ammo_box.png │ ├── grenade_box.png │ └── health_box.png ├── player │ ├── Idle │ │ ├── 0.png │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ └── 4.png │ ├── Jump │ │ └── 0.png │ ├── Run │ │ ├── 0.png │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ └── 5.png │ └── Death │ │ ├── 0.png │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ ├── 5.png │ │ ├── 6.png │ │ └── 7.png ├── restart_btn.png ├── explosion │ ├── exp1.png │ ├── exp2.png │ ├── exp3.png │ ├── exp4.png │ └── exp5.png └── background │ ├── pine1.png │ ├── pine2.png │ ├── mountain.png │ └── sky_cloud.png ├── __pycache__ └── button.cpython-312.pyc ├── button.py ├── level1_data.csv ├── level2_data.csv └── shooter.py /audio/jump.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/audio/jump.wav -------------------------------------------------------------------------------- /audio/music2.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/audio/music2.mp3 -------------------------------------------------------------------------------- /audio/shot.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/audio/shot.wav -------------------------------------------------------------------------------- /img/exit_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/exit_btn.png -------------------------------------------------------------------------------- /img/tile/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/0.png -------------------------------------------------------------------------------- /img/tile/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/1.png -------------------------------------------------------------------------------- /img/tile/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/10.png -------------------------------------------------------------------------------- /img/tile/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/11.png -------------------------------------------------------------------------------- /img/tile/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/12.png -------------------------------------------------------------------------------- /img/tile/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/13.png -------------------------------------------------------------------------------- /img/tile/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/14.png -------------------------------------------------------------------------------- /img/tile/15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/15.png -------------------------------------------------------------------------------- /img/tile/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/16.png -------------------------------------------------------------------------------- /img/tile/17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/17.png -------------------------------------------------------------------------------- /img/tile/18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/18.png -------------------------------------------------------------------------------- /img/tile/19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/19.png -------------------------------------------------------------------------------- /img/tile/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/2.png -------------------------------------------------------------------------------- /img/tile/20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/20.png -------------------------------------------------------------------------------- /img/tile/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/3.png -------------------------------------------------------------------------------- /img/tile/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/4.png -------------------------------------------------------------------------------- /img/tile/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/5.png -------------------------------------------------------------------------------- /img/tile/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/6.png -------------------------------------------------------------------------------- /img/tile/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/7.png -------------------------------------------------------------------------------- /img/tile/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/8.png -------------------------------------------------------------------------------- /img/tile/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/tile/9.png -------------------------------------------------------------------------------- /audio/grenade.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/audio/grenade.wav -------------------------------------------------------------------------------- /img/start_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/start_btn.png -------------------------------------------------------------------------------- /img/enemy/Death/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Death/0.png -------------------------------------------------------------------------------- /img/enemy/Death/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Death/1.png -------------------------------------------------------------------------------- /img/enemy/Death/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Death/2.png -------------------------------------------------------------------------------- /img/enemy/Death/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Death/3.png -------------------------------------------------------------------------------- /img/enemy/Death/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Death/4.png -------------------------------------------------------------------------------- /img/enemy/Death/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Death/5.png -------------------------------------------------------------------------------- /img/enemy/Death/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Death/6.png -------------------------------------------------------------------------------- /img/enemy/Death/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Death/7.png -------------------------------------------------------------------------------- /img/enemy/Idle/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Idle/0.png -------------------------------------------------------------------------------- /img/enemy/Idle/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Idle/1.png -------------------------------------------------------------------------------- /img/enemy/Idle/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Idle/2.png -------------------------------------------------------------------------------- /img/enemy/Idle/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Idle/3.png -------------------------------------------------------------------------------- /img/enemy/Idle/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Idle/4.png -------------------------------------------------------------------------------- /img/enemy/Jump/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Jump/0.png -------------------------------------------------------------------------------- /img/enemy/Run/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Run/0.png -------------------------------------------------------------------------------- /img/enemy/Run/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Run/1.png -------------------------------------------------------------------------------- /img/enemy/Run/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Run/2.png -------------------------------------------------------------------------------- /img/enemy/Run/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Run/3.png -------------------------------------------------------------------------------- /img/enemy/Run/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Run/4.png -------------------------------------------------------------------------------- /img/enemy/Run/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/enemy/Run/5.png -------------------------------------------------------------------------------- /img/icons/bullet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/icons/bullet.png -------------------------------------------------------------------------------- /img/icons/grenade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/icons/grenade.png -------------------------------------------------------------------------------- /img/player/Idle/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Idle/0.png -------------------------------------------------------------------------------- /img/player/Idle/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Idle/1.png -------------------------------------------------------------------------------- /img/player/Idle/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Idle/2.png -------------------------------------------------------------------------------- /img/player/Idle/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Idle/3.png -------------------------------------------------------------------------------- /img/player/Idle/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Idle/4.png -------------------------------------------------------------------------------- /img/player/Jump/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Jump/0.png -------------------------------------------------------------------------------- /img/player/Run/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Run/0.png -------------------------------------------------------------------------------- /img/player/Run/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Run/1.png -------------------------------------------------------------------------------- /img/player/Run/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Run/2.png -------------------------------------------------------------------------------- /img/player/Run/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Run/3.png -------------------------------------------------------------------------------- /img/player/Run/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Run/4.png -------------------------------------------------------------------------------- /img/player/Run/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Run/5.png -------------------------------------------------------------------------------- /img/restart_btn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/restart_btn.png -------------------------------------------------------------------------------- /img/explosion/exp1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/explosion/exp1.png -------------------------------------------------------------------------------- /img/explosion/exp2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/explosion/exp2.png -------------------------------------------------------------------------------- /img/explosion/exp3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/explosion/exp3.png -------------------------------------------------------------------------------- /img/explosion/exp4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/explosion/exp4.png -------------------------------------------------------------------------------- /img/explosion/exp5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/explosion/exp5.png -------------------------------------------------------------------------------- /img/icons/ammo_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/icons/ammo_box.png -------------------------------------------------------------------------------- /img/player/Death/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Death/0.png -------------------------------------------------------------------------------- /img/player/Death/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Death/1.png -------------------------------------------------------------------------------- /img/player/Death/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Death/2.png -------------------------------------------------------------------------------- /img/player/Death/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Death/3.png -------------------------------------------------------------------------------- /img/player/Death/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Death/4.png -------------------------------------------------------------------------------- /img/player/Death/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Death/5.png -------------------------------------------------------------------------------- /img/player/Death/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Death/6.png -------------------------------------------------------------------------------- /img/player/Death/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/player/Death/7.png -------------------------------------------------------------------------------- /img/background/pine1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/background/pine1.png -------------------------------------------------------------------------------- /img/background/pine2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/background/pine2.png -------------------------------------------------------------------------------- /img/icons/grenade_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/icons/grenade_box.png -------------------------------------------------------------------------------- /img/icons/health_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/icons/health_box.png -------------------------------------------------------------------------------- /img/background/mountain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/background/mountain.png -------------------------------------------------------------------------------- /img/background/sky_cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/img/background/sky_cloud.png -------------------------------------------------------------------------------- /__pycache__/button.cpython-312.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustGabrro/Pygame-Shooter/HEAD/__pycache__/button.cpython-312.pyc -------------------------------------------------------------------------------- /button.py: -------------------------------------------------------------------------------- 1 | import pygame 2 | 3 | #button class 4 | class Button(): 5 | def __init__(self,x, y, image, scale): 6 | width = image.get_width() 7 | height = image.get_height() 8 | self.image = pygame.transform.scale(image, (int(width * scale), int(height * scale))) 9 | self.rect = self.image.get_rect() 10 | self.rect.topleft = (x, y) 11 | self.clicked = False 12 | 13 | def draw(self, surface): 14 | action = False 15 | 16 | #get mouse position 17 | pos = pygame.mouse.get_pos() 18 | 19 | #check mouseover and clicked conditions 20 | if self.rect.collidepoint(pos): 21 | if pygame.mouse.get_pressed()[0] == 1 and self.clicked == False: 22 | action = True 23 | self.clicked = True 24 | 25 | if pygame.mouse.get_pressed()[0] == 0: 26 | self.clicked = False 27 | 28 | #draw button 29 | surface.blit(self.image, (self.rect.x, self.rect.y)) 30 | 31 | return action -------------------------------------------------------------------------------- /level1_data.csv: -------------------------------------------------------------------------------- 1 | -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-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,10,10,3,4,4,4,4,4,5,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,3,4,4,4,4,4,4,4,4,4,4,4,4,4,5,10,10,10,10,10,10,10,10,10,10,10,10,10,10 17 | -------------------------------------------------------------------------------- /level2_data.csv: -------------------------------------------------------------------------------- 1 | -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 2 | -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-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-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,7,7,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 15 | 4,5,-1,-1,12,-1,13,15,14,14,14,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,7,7,7,7,7,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 16 | 4,4,0,0,0,0,0,0,0,0,0,2,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9 17 | -------------------------------------------------------------------------------- /shooter.py: -------------------------------------------------------------------------------- 1 | import pygame 2 | from pygame import mixer 3 | import os 4 | import random 5 | import csv 6 | import button 7 | 8 | mixer.init() 9 | pygame.init() 10 | 11 | 12 | SCREEN_WIDTH = 800 13 | SCREEN_HEIGHT = int(SCREEN_WIDTH * 0.8) 14 | 15 | screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) 16 | pygame.display.set_caption('Shooter') 17 | 18 | #set framerate 19 | clock = pygame.time.Clock() 20 | FPS = 60 21 | 22 | #define game variables 23 | GRAVITY = 0.65 24 | SCROLL_THRESH = 200 25 | ROWS = 16 26 | COLS = 150 27 | TILE_SIZE = SCREEN_HEIGHT // ROWS 28 | TILE_TYPES = 21 29 | MAX_LEVELS = 2 30 | screen_scroll = 0 31 | bg_scroll = 0 32 | level = 1 33 | start_game = False 34 | start_intro = False 35 | 36 | 37 | #define player action variables 38 | moving_left = False 39 | moving_right = False 40 | shoot = False 41 | grenade = False 42 | grenade_thrown = False 43 | 44 | 45 | #load music and sounds 46 | #pygame.mixer.music.load('audio/music2.mp3') 47 | #pygame.mixer.music.set_volume(0.3) 48 | #pygame.mixer.music.play(-1, 0.0, 5000) 49 | jump_fx = pygame.mixer.Sound('audio/jump.wav') 50 | jump_fx.set_volume(0.05) 51 | shot_fx = pygame.mixer.Sound('audio/shot.wav') 52 | shot_fx.set_volume(0.05) 53 | grenade_fx = pygame.mixer.Sound('audio/grenade.wav') 54 | grenade_fx.set_volume(0.05) 55 | 56 | 57 | #load images 58 | #button images 59 | start_img = pygame.image.load('img/start_btn.png').convert_alpha() 60 | exit_img = pygame.image.load('img/exit_btn.png').convert_alpha() 61 | restart_img = pygame.image.load('img/restart_btn.png').convert_alpha() 62 | #background 63 | pine1_img = pygame.image.load('img/Background/pine1.png').convert_alpha() 64 | pine2_img = pygame.image.load('img/Background/pine2.png').convert_alpha() 65 | mountain_img = pygame.image.load('img/Background/mountain.png').convert_alpha() 66 | sky_img = pygame.image.load('img/Background/sky_cloud.png').convert_alpha() 67 | #store tiles in a list 68 | img_list = [] 69 | for x in range(TILE_TYPES): 70 | img = pygame.image.load(f'img/Tile/{x}.png') 71 | img = pygame.transform.scale(img, (TILE_SIZE, TILE_SIZE)) 72 | img_list.append(img) 73 | #bullet 74 | bullet_img = pygame.image.load('img/icons/bullet.png').convert_alpha() 75 | #grenade 76 | grenade_img = pygame.image.load('img/icons/grenade.png').convert_alpha() 77 | #pick up boxes 78 | health_box_img = pygame.image.load('img/icons/health_box.png').convert_alpha() 79 | ammo_box_img = pygame.image.load('img/icons/ammo_box.png').convert_alpha() 80 | grenade_box_img = pygame.image.load('img/icons/grenade_box.png').convert_alpha() 81 | item_boxes = { 82 | 'Health' : health_box_img, 83 | 'Ammo' : ammo_box_img, 84 | 'Grenade' : grenade_box_img 85 | } 86 | 87 | 88 | #define colours 89 | BG = (144, 201, 120) 90 | RED = (255, 0, 0) 91 | WHITE = (255, 255, 255) 92 | GREEN = (0, 255, 0) 93 | BLACK = (0, 0, 0) 94 | PINK = (235, 65, 54) 95 | 96 | #define font 97 | font = pygame.font.SysFont('Futura', 30) 98 | 99 | def draw_text(text, font, text_col, x, y): 100 | img = font.render(text, True, text_col) 101 | screen.blit(img, (x, y)) 102 | 103 | 104 | def draw_bg(): 105 | screen.fill(BG) 106 | width = sky_img.get_width() 107 | for x in range(5): 108 | screen.blit(sky_img, ((x * width) - bg_scroll * 0.5, 0)) 109 | screen.blit(mountain_img, ((x * width) - bg_scroll * 0.6, SCREEN_HEIGHT - mountain_img.get_height() - 300)) 110 | screen.blit(pine1_img, ((x * width) - bg_scroll * 0.7, SCREEN_HEIGHT - pine1_img.get_height() - 150)) 111 | screen.blit(pine2_img, ((x * width) - bg_scroll * 0.8, SCREEN_HEIGHT - pine2_img.get_height())) 112 | 113 | 114 | #function to reset level 115 | def reset_level(): 116 | enemy_group.empty() 117 | bullet_group.empty() 118 | grenade_group.empty() 119 | explosion_group.empty() 120 | item_box_group.empty() 121 | decoration_group.empty() 122 | water_group.empty() 123 | exit_group.empty() 124 | 125 | #create empty tile list 126 | data = [] 127 | for row in range(ROWS): 128 | r = [-1] * COLS 129 | data.append(r) 130 | 131 | return data 132 | 133 | 134 | 135 | 136 | class Soldier(pygame.sprite.Sprite): 137 | def __init__(self, char_type, x, y, scale, speed, ammo, grenades): 138 | pygame.sprite.Sprite.__init__(self) 139 | self.alive = True 140 | self.char_type = char_type 141 | self.speed = speed 142 | self.ammo = ammo 143 | self.start_ammo = ammo 144 | self.shoot_cooldown = 0 145 | self.grenades = grenades 146 | self.health = 100 147 | self.max_health = self.health 148 | self.direction = 1 149 | self.vel_y = 0 150 | self.jump = False 151 | self.in_air = True 152 | self.flip = False 153 | self.animation_list = [] 154 | self.frame_index = 0 155 | self.action = 0 156 | self.update_time = pygame.time.get_ticks() 157 | #ai specific variables 158 | self.move_counter = 0 159 | self.vision = pygame.Rect(0, 0, 150, 20) 160 | self.idling = False 161 | self.idling_counter = 0 162 | 163 | #load all images for the players 164 | animation_types = ['Idle', 'Run', 'Jump', 'Death'] 165 | for animation in animation_types: 166 | #reset temporary list of images 167 | temp_list = [] 168 | #count number of files in the folder 169 | num_of_frames = len(os.listdir(f'img/{self.char_type}/{animation}')) 170 | for i in range(num_of_frames): 171 | img = pygame.image.load(f'img/{self.char_type}/{animation}/{i}.png').convert_alpha() 172 | img = pygame.transform.scale(img, (int(img.get_width() * scale), int(img.get_height() * scale))) 173 | temp_list.append(img) 174 | self.animation_list.append(temp_list) 175 | 176 | self.image = self.animation_list[self.action][self.frame_index] 177 | self.rect = self.image.get_rect() 178 | self.rect.center = (x, y) 179 | self.width = self.image.get_width() 180 | self.height = self.image.get_height() 181 | 182 | 183 | def update(self): 184 | self.update_animation() 185 | self.check_alive() 186 | #update cooldown 187 | if self.shoot_cooldown > 0: 188 | self.shoot_cooldown -= 1 189 | 190 | 191 | def move(self, moving_left, moving_right): 192 | #reset movement variables 193 | screen_scroll = 0 194 | dx = 0 195 | dy = 0 196 | 197 | #assign movement variables if moving left or right 198 | if moving_left: 199 | dx = -self.speed 200 | self.flip = True 201 | self.direction = -1 202 | if moving_right: 203 | dx = self.speed 204 | self.flip = False 205 | self.direction = 1 206 | 207 | #jump 208 | if self.jump == True and self.in_air == False: 209 | self.vel_y = -11 210 | self.jump = False 211 | self.in_air = True 212 | 213 | #apply gravity 214 | self.vel_y += GRAVITY 215 | if self.vel_y > 10: 216 | self.vel_y 217 | dy += self.vel_y 218 | 219 | #check for collision 220 | for tile in world.obstacle_list: 221 | #check collision in the x direction 222 | if tile[1].colliderect(self.rect.x + dx, self.rect.y, self.width, self.height): 223 | dx = 0 224 | #if the ai has hit a wall then make it turn around 225 | if self.char_type == 'enemy': 226 | self.direction *= -1 227 | self.move_counter = 0 228 | #check for collision in the y direction 229 | if tile[1].colliderect(self.rect.x, self.rect.y + dy, self.width, self.height): 230 | #check if below the ground, i.e. jumping 231 | if self.vel_y < 0: 232 | self.vel_y = 0 233 | dy = tile[1].bottom - self.rect.top 234 | #check if above the ground, i.e. falling 235 | elif self.vel_y >= 0: 236 | self.vel_y = 0 237 | self.in_air = False 238 | dy = tile[1].top - self.rect.bottom 239 | 240 | 241 | #check for collision with water 242 | if pygame.sprite.spritecollide(self, water_group, False): 243 | self.health = 0 244 | 245 | #check for collision with exit 246 | level_complete = False 247 | if pygame.sprite.spritecollide(self, exit_group, False): 248 | level_complete = True 249 | 250 | #check if fallen off the map 251 | if self.rect.bottom > SCREEN_HEIGHT: 252 | self.health = 0 253 | 254 | 255 | #check if going off the edges of the screen 256 | if self.char_type == 'player': 257 | if self.rect.left + dx < 0 or self.rect.right + dx > SCREEN_WIDTH: 258 | dx = 0 259 | 260 | #update rectangle position 261 | self.rect.x += dx 262 | self.rect.y += dy 263 | 264 | #update scroll based on player position 265 | if self.char_type == 'player': 266 | if (self.rect.right > SCREEN_WIDTH - SCROLL_THRESH and bg_scroll < (world.level_length * TILE_SIZE) - SCREEN_WIDTH)\ 267 | or (self.rect.left < SCROLL_THRESH and bg_scroll > abs(dx)): 268 | self.rect.x -= dx 269 | screen_scroll = -dx 270 | 271 | return screen_scroll, level_complete 272 | 273 | 274 | 275 | def shoot(self): 276 | if self.shoot_cooldown == 0 and self.ammo > 0: 277 | self.shoot_cooldown = 20 278 | bullet = Bullet(self.rect.centerx + (0.75 * self.rect.size[0] * self.direction), self.rect.centery, self.direction) 279 | bullet_group.add(bullet) 280 | #reduce ammo 281 | self.ammo -= 1 282 | shot_fx.play() 283 | 284 | 285 | def ai(self): 286 | if self.alive and player.alive: 287 | if self.idling == False and random.randint(1, 200) == 1: 288 | self.update_action(0)#0: idle 289 | self.idling = True 290 | self.idling_counter = 50 291 | #check if the ai in near the player 292 | if self.vision.colliderect(player.rect): 293 | #stop running and face the player 294 | self.update_action(0)#0: idle 295 | #shoot 296 | self.shoot() 297 | else: 298 | if self.idling == False: 299 | if self.direction == 1: 300 | ai_moving_right = True 301 | else: 302 | ai_moving_right = False 303 | ai_moving_left = not ai_moving_right 304 | self.move(ai_moving_left, ai_moving_right) 305 | self.update_action(1)#1: run 306 | self.move_counter += 1 307 | #update ai vision as the enemy moves 308 | self.vision.center = (self.rect.centerx + 75 * self.direction, self.rect.centery) 309 | 310 | if self.move_counter > TILE_SIZE: 311 | self.direction *= -1 312 | self.move_counter *= -1 313 | else: 314 | self.idling_counter -= 1 315 | if self.idling_counter <= 0: 316 | self.idling = False 317 | 318 | #scroll 319 | self.rect.x += screen_scroll 320 | 321 | 322 | def update_animation(self): 323 | #update animation 324 | ANIMATION_COOLDOWN = 100 325 | #update image depending on current frame 326 | self.image = self.animation_list[self.action][self.frame_index] 327 | #check if enough time has passed since the last update 328 | if pygame.time.get_ticks() - self.update_time > ANIMATION_COOLDOWN: 329 | self.update_time = pygame.time.get_ticks() 330 | self.frame_index += 1 331 | #if the animation has run out the reset back to the start 332 | if self.frame_index >= len(self.animation_list[self.action]): 333 | if self.action == 3: 334 | self.frame_index = len(self.animation_list[self.action]) - 1 335 | else: 336 | self.frame_index = 0 337 | 338 | 339 | 340 | def update_action(self, new_action): 341 | #check if the new action is different to the previous one 342 | if new_action != self.action: 343 | self.action = new_action 344 | #update the animation settings 345 | self.frame_index = 0 346 | self.update_time = pygame.time.get_ticks() 347 | 348 | 349 | 350 | def check_alive(self): 351 | if self.health <= 0: 352 | self.health = 0 353 | self.speed = 0 354 | self.alive = False 355 | self.update_action(3) 356 | 357 | 358 | def draw(self): 359 | screen.blit(pygame.transform.flip(self.image, self.flip, False), self.rect) 360 | 361 | 362 | class World(): 363 | def __init__(self): 364 | self.obstacle_list = [] 365 | 366 | def process_data(self, data): 367 | self.level_length = len(data[0]) 368 | #iterate through each value in level data file 369 | for y, row in enumerate(data): 370 | for x, tile in enumerate(row): 371 | if tile >= 0: 372 | img = img_list[tile] 373 | img_rect = img.get_rect() 374 | img_rect.x = x * TILE_SIZE 375 | img_rect.y = y * TILE_SIZE 376 | tile_data = (img, img_rect) 377 | if tile >= 0 and tile <= 8: 378 | self.obstacle_list.append(tile_data) 379 | elif tile >= 9 and tile <= 10: 380 | water = Water(img, x * TILE_SIZE, y * TILE_SIZE) 381 | water_group.add(water) 382 | elif tile >= 11 and tile <= 14: 383 | decoration = Decoration(img, x * TILE_SIZE, y * TILE_SIZE) 384 | decoration_group.add(decoration) 385 | elif tile == 15:#create player 386 | player = Soldier('player', x * TILE_SIZE, y * TILE_SIZE, 1.65, 5, 20, 5) 387 | health_bar = HealthBar(10, 10, player.health, player.health) 388 | elif tile == 16:#create enemies 389 | enemy = Soldier('enemy', x * TILE_SIZE, y * TILE_SIZE, 1.65, 2, 20, 0) 390 | enemy_group.add(enemy) 391 | elif tile == 17:#create ammo box 392 | item_box = ItemBox('Ammo', x * TILE_SIZE, y * TILE_SIZE) 393 | item_box_group.add(item_box) 394 | elif tile == 18:#create grenade box 395 | item_box = ItemBox('Grenade', x * TILE_SIZE, y * TILE_SIZE) 396 | item_box_group.add(item_box) 397 | elif tile == 19:#create health box 398 | item_box = ItemBox('Health', x * TILE_SIZE, y * TILE_SIZE) 399 | item_box_group.add(item_box) 400 | elif tile == 20:#create exit 401 | exit = Exit(img, x * TILE_SIZE, y * TILE_SIZE) 402 | exit_group.add(exit) 403 | 404 | return player, health_bar 405 | 406 | 407 | def draw(self): 408 | for tile in self.obstacle_list: 409 | tile[1][0] += screen_scroll 410 | screen.blit(tile[0], tile[1]) 411 | 412 | 413 | class Decoration(pygame.sprite.Sprite): 414 | def __init__(self, img, x, y): 415 | pygame.sprite.Sprite.__init__(self) 416 | self.image = img 417 | self.rect = self.image.get_rect() 418 | self.rect.midtop = (x + TILE_SIZE // 2, y + (TILE_SIZE - self.image.get_height())) 419 | 420 | def update(self): 421 | self.rect.x += screen_scroll 422 | 423 | 424 | class Water(pygame.sprite.Sprite): 425 | def __init__(self, img, x, y): 426 | pygame.sprite.Sprite.__init__(self) 427 | self.image = img 428 | self.rect = self.image.get_rect() 429 | self.rect.midtop = (x + TILE_SIZE // 2, y + (TILE_SIZE - self.image.get_height())) 430 | 431 | def update(self): 432 | self.rect.x += screen_scroll 433 | 434 | class Exit(pygame.sprite.Sprite): 435 | def __init__(self, img, x, y): 436 | pygame.sprite.Sprite.__init__(self) 437 | self.image = img 438 | self.rect = self.image.get_rect() 439 | self.rect.midtop = (x + TILE_SIZE // 2, y + (TILE_SIZE - self.image.get_height())) 440 | 441 | def update(self): 442 | self.rect.x += screen_scroll 443 | 444 | 445 | class ItemBox(pygame.sprite.Sprite): 446 | def __init__(self, item_type, x, y): 447 | pygame.sprite.Sprite.__init__(self) 448 | self.item_type = item_type 449 | self.image = item_boxes[self.item_type] 450 | self.rect = self.image.get_rect() 451 | self.rect.midtop = (x + TILE_SIZE // 2, y + (TILE_SIZE - self.image.get_height())) 452 | 453 | 454 | def update(self): 455 | #scroll 456 | self.rect.x += screen_scroll 457 | #check if the player has picked up the box 458 | if pygame.sprite.collide_rect(self, player): 459 | #check what kind of box it was 460 | if self.item_type == 'Health': 461 | player.health += 25 462 | if player.health > player.max_health: 463 | player.health = player.max_health 464 | elif self.item_type == 'Ammo': 465 | player.ammo += 15 466 | elif self.item_type == 'Grenade': 467 | player.grenades += 3 468 | #delete the item box 469 | self.kill() 470 | 471 | 472 | class HealthBar(): 473 | def __init__(self, x, y, health, max_health): 474 | self.x = x 475 | self.y = y 476 | self.health = health 477 | self.max_health = max_health 478 | 479 | def draw(self, health): 480 | #update with new health 481 | self.health = health 482 | #calculate health ratio 483 | ratio = self.health / self.max_health 484 | pygame.draw.rect(screen, BLACK, (self.x - 2, self.y - 2, 154, 24)) 485 | pygame.draw.rect(screen, RED, (self.x, self.y, 150, 20)) 486 | pygame.draw.rect(screen, GREEN, (self.x, self.y, 150 * ratio, 20)) 487 | 488 | 489 | class Bullet(pygame.sprite.Sprite): 490 | def __init__(self, x, y, direction): 491 | pygame.sprite.Sprite.__init__(self) 492 | self.speed = 10 493 | self.image = bullet_img 494 | self.rect = self.image.get_rect() 495 | self.rect.center = (x, y) 496 | self.direction = direction 497 | 498 | def update(self): 499 | #move bullet 500 | self.rect.x += (self.direction * self.speed) + screen_scroll 501 | #check if bullet has gone off screen 502 | if self.rect.right < 0 or self.rect.left > SCREEN_WIDTH: 503 | self.kill() 504 | #check for collision with level 505 | for tile in world.obstacle_list: 506 | if tile[1].colliderect(self.rect): 507 | self.kill() 508 | 509 | #check collision with characters 510 | if pygame.sprite.spritecollide(player, bullet_group, False): 511 | if player.alive: 512 | player.health -= 5 513 | self.kill() 514 | for enemy in enemy_group: 515 | if pygame.sprite.spritecollide(enemy, bullet_group, False): 516 | if enemy.alive: 517 | enemy.health -= 25 518 | self.kill() 519 | 520 | 521 | 522 | class Grenade(pygame.sprite.Sprite): 523 | def __init__(self, x, y, direction): 524 | pygame.sprite.Sprite.__init__(self) 525 | self.timer = 100 526 | self.vel_y = -11 527 | self.speed = 7 528 | self.image = grenade_img 529 | self.rect = self.image.get_rect() 530 | self.rect.center = (x, y) 531 | self.width = self.image.get_width() 532 | self.height = self.image.get_height() 533 | self.direction = direction 534 | 535 | def update(self): 536 | self.vel_y += GRAVITY 537 | dx = self.direction * self.speed 538 | dy = self.vel_y 539 | 540 | #check for collision with level 541 | for tile in world.obstacle_list: 542 | #check collision with walls 543 | if tile[1].colliderect(self.rect.x + dx, self.rect.y, self.width, self.height): 544 | self.direction *= -1 545 | dx = self.direction * self.speed 546 | #check for collision in the y direction 547 | if tile[1].colliderect(self.rect.x, self.rect.y + dy, self.width, self.height): 548 | self.speed = 0 549 | #check if below the ground, i.e. thrown up 550 | if self.vel_y < 0: 551 | self.vel_y = 0 552 | dy = tile[1].bottom - self.rect.top 553 | #check if above the ground, i.e. falling 554 | elif self.vel_y >= 0: 555 | self.vel_y = 0 556 | dy = tile[1].top - self.rect.bottom 557 | 558 | 559 | #update grenade position 560 | self.rect.x += dx + screen_scroll 561 | self.rect.y += dy 562 | 563 | #countdown timer 564 | self.timer -= 1 565 | if self.timer <= 0: 566 | self.kill() 567 | grenade_fx.play() 568 | explosion = Explosion(self.rect.x, self.rect.y, 0.5) 569 | explosion_group.add(explosion) 570 | #do damage to anyone that is nearby 571 | if abs(self.rect.centerx - player.rect.centerx) < TILE_SIZE * 2 and \ 572 | abs(self.rect.centery - player.rect.centery) < TILE_SIZE * 2: 573 | player.health -= 50 574 | for enemy in enemy_group: 575 | if abs(self.rect.centerx - enemy.rect.centerx) < TILE_SIZE * 2 and \ 576 | abs(self.rect.centery - enemy.rect.centery) < TILE_SIZE * 2: 577 | enemy.health -= 50 578 | 579 | 580 | 581 | class Explosion(pygame.sprite.Sprite): 582 | def __init__(self, x, y, scale): 583 | pygame.sprite.Sprite.__init__(self) 584 | self.images = [] 585 | for num in range(1, 6): 586 | img = pygame.image.load(f'img/explosion/exp{num}.png').convert_alpha() 587 | img = pygame.transform.scale(img, (int(img.get_width() * scale), int(img.get_height() * scale))) 588 | self.images.append(img) 589 | self.frame_index = 0 590 | self.image = self.images[self.frame_index] 591 | self.rect = self.image.get_rect() 592 | self.rect.center = (x, y) 593 | self.counter = 0 594 | 595 | 596 | def update(self): 597 | #scroll 598 | self.rect.x += screen_scroll 599 | 600 | EXPLOSION_SPEED = 4 601 | #update explosion amimation 602 | self.counter += 1 603 | 604 | if self.counter >= EXPLOSION_SPEED: 605 | self.counter = 0 606 | self.frame_index += 1 607 | #if the animation is complete then delete the explosion 608 | if self.frame_index >= len(self.images): 609 | self.kill() 610 | else: 611 | self.image = self.images[self.frame_index] 612 | 613 | 614 | class ScreenFade(): 615 | def __init__(self, direction, colour, speed): 616 | self.direction = direction 617 | self.colour = colour 618 | self.speed = speed 619 | self.fade_counter = 0 620 | 621 | 622 | def fade(self): 623 | fade_complete = False 624 | self.fade_counter += self.speed 625 | if self.direction == 1:#whole screen fade 626 | pygame.draw.rect(screen, self.colour, (0 - self.fade_counter, 0, SCREEN_WIDTH // 2, SCREEN_HEIGHT)) 627 | pygame.draw.rect(screen, self.colour, (SCREEN_WIDTH // 2 + self.fade_counter, 0, SCREEN_WIDTH, SCREEN_HEIGHT)) 628 | pygame.draw.rect(screen, self.colour, (0, 0 - self.fade_counter, SCREEN_WIDTH, SCREEN_HEIGHT // 2)) 629 | pygame.draw.rect(screen, self.colour, (0, SCREEN_HEIGHT // 2 +self.fade_counter, SCREEN_WIDTH, SCREEN_HEIGHT)) 630 | if self.direction == 2:#vertical screen fade down 631 | pygame.draw.rect(screen, self.colour, (0, 0, SCREEN_WIDTH, 0 + self.fade_counter)) 632 | if self.fade_counter >= SCREEN_WIDTH: 633 | fade_complete = True 634 | 635 | return fade_complete 636 | 637 | 638 | #create screen fades 639 | intro_fade = ScreenFade(1, BLACK, 4) 640 | death_fade = ScreenFade(2, PINK, 4) 641 | 642 | 643 | #create buttons 644 | start_button = button.Button(SCREEN_WIDTH // 2 - 130, SCREEN_HEIGHT // 2 - 150, start_img, 1) 645 | exit_button = button.Button(SCREEN_WIDTH // 2 - 110, SCREEN_HEIGHT // 2 + 50, exit_img, 1) 646 | restart_button = button.Button(SCREEN_WIDTH // 2 - 100, SCREEN_HEIGHT // 2 - 50, restart_img, 2) 647 | 648 | #create sprite groups 649 | enemy_group = pygame.sprite.Group() 650 | bullet_group = pygame.sprite.Group() 651 | grenade_group = pygame.sprite.Group() 652 | explosion_group = pygame.sprite.Group() 653 | item_box_group = pygame.sprite.Group() 654 | decoration_group = pygame.sprite.Group() 655 | water_group = pygame.sprite.Group() 656 | exit_group = pygame.sprite.Group() 657 | 658 | 659 | 660 | #create empty tile list 661 | world_data = [] 662 | for row in range(ROWS): 663 | r = [-1] * COLS 664 | world_data.append(r) 665 | #load in level data and create world 666 | with open(f'level{level}_data.csv', newline='') as csvfile: 667 | reader = csv.reader(csvfile, delimiter=',') 668 | for x, row in enumerate(reader): 669 | for y, tile in enumerate(row): 670 | world_data[x][y] = int(tile) 671 | world = World() 672 | player, health_bar = world.process_data(world_data) 673 | 674 | 675 | 676 | run = True 677 | while run: 678 | 679 | clock.tick(FPS) 680 | 681 | if start_game == False: 682 | #draw menu 683 | screen.fill(BG) 684 | #add buttons 685 | if start_button.draw(screen): 686 | start_game = True 687 | start_intro = True 688 | if exit_button.draw(screen): 689 | run = False 690 | else: 691 | #update background 692 | draw_bg() 693 | #draw world map 694 | world.draw() 695 | #show player health 696 | health_bar.draw(player.health) 697 | #show ammo 698 | draw_text('AMMO: ', font, WHITE, 10, 35) 699 | for x in range(player.ammo): 700 | screen.blit(bullet_img, (90 + (x * 10), 40)) 701 | #show grenades 702 | draw_text('GRENADES: ', font, WHITE, 10, 60) 703 | for x in range(player.grenades): 704 | screen.blit(grenade_img, (135 + (x * 15), 60)) 705 | 706 | 707 | player.update() 708 | player.draw() 709 | 710 | for enemy in enemy_group: 711 | enemy.ai() 712 | enemy.update() 713 | enemy.draw() 714 | 715 | #update and draw groups 716 | bullet_group.update() 717 | grenade_group.update() 718 | explosion_group.update() 719 | item_box_group.update() 720 | decoration_group.update() 721 | water_group.update() 722 | exit_group.update() 723 | bullet_group.draw(screen) 724 | grenade_group.draw(screen) 725 | explosion_group.draw(screen) 726 | item_box_group.draw(screen) 727 | decoration_group.draw(screen) 728 | water_group.draw(screen) 729 | exit_group.draw(screen) 730 | 731 | #show intro 732 | if start_intro == True: 733 | if intro_fade.fade(): 734 | start_intro = False 735 | intro_fade.fade_counter = 0 736 | 737 | 738 | #update player actions 739 | if player.alive: 740 | #shoot bullets 741 | if shoot: 742 | player.shoot() 743 | #throw grenades 744 | elif grenade and grenade_thrown == False and player.grenades > 0: 745 | grenade = Grenade(player.rect.centerx + (0.5 * player.rect.size[0] * player.direction),\ 746 | player.rect.top, player.direction) 747 | grenade_group.add(grenade) 748 | #reduce grenades 749 | player.grenades -= 1 750 | grenade_thrown = True 751 | if player.in_air: 752 | player.update_action(2)#2: jump 753 | elif moving_left or moving_right: 754 | player.update_action(1)#1: run 755 | else: 756 | player.update_action(0)#0: idle 757 | screen_scroll, level_complete = player.move(moving_left, moving_right) 758 | bg_scroll -= screen_scroll 759 | #check if player has completed the level 760 | if level_complete: 761 | start_intro = True 762 | level += 1 763 | bg_scroll = 0 764 | world_data = reset_level() 765 | if level <= MAX_LEVELS: 766 | #load in level data and create world 767 | with open(f'level{level}_data.csv', newline='') as csvfile: 768 | reader = csv.reader(csvfile, delimiter=',') 769 | for x, row in enumerate(reader): 770 | for y, tile in enumerate(row): 771 | world_data[x][y] = int(tile) 772 | world = World() 773 | player, health_bar = world.process_data(world_data) 774 | else: 775 | screen_scroll = 0 776 | if death_fade.fade(): 777 | if restart_button.draw(screen): 778 | death_fade.fade_counter = 0 779 | start_intro = True 780 | bg_scroll = 0 781 | world_data = reset_level() 782 | #load in level data and create world 783 | with open(f'level{level}_data.csv', newline='') as csvfile: 784 | reader = csv.reader(csvfile, delimiter=',') 785 | for x, row in enumerate(reader): 786 | for y, tile in enumerate(row): 787 | world_data[x][y] = int(tile) 788 | world = World() 789 | player, health_bar = world.process_data(world_data) 790 | 791 | 792 | for event in pygame.event.get(): 793 | #quit game 794 | if event.type == pygame.QUIT: 795 | run = False 796 | #keyboard presses 797 | if event.type == pygame.KEYDOWN: 798 | if event.key == pygame.K_a: 799 | moving_left = True 800 | if event.key == pygame.K_d: 801 | moving_right = True 802 | if event.key == pygame.K_k: 803 | shoot = True 804 | if event.key == pygame.K_l: 805 | grenade = True 806 | if event.key == pygame.K_SPACE and player.alive: 807 | player.jump = True 808 | jump_fx.play() 809 | if event.key == pygame.K_ESCAPE: 810 | run = False 811 | 812 | 813 | #keyboard button released 814 | if event.type == pygame.KEYUP: 815 | if event.key == pygame.K_a: 816 | moving_left = False 817 | if event.key == pygame.K_d: 818 | moving_right = False 819 | if event.key == pygame.K_k: 820 | shoot = False 821 | if event.key == pygame.K_l: 822 | grenade = False 823 | grenade_thrown = False 824 | 825 | 826 | pygame.display.update() 827 | 828 | pygame.quit() --------------------------------------------------------------------------------