diff --git a/__pycache__/colours.cpython-37.pyc b/__pycache__/colours.cpython-37.pyc index bb8f06b..bcc151a 100644 Binary files a/__pycache__/colours.cpython-37.pyc and b/__pycache__/colours.cpython-37.pyc differ diff --git a/__pycache__/config.cpython-37.pyc b/__pycache__/config.cpython-37.pyc index 452a61e..be4139e 100644 Binary files a/__pycache__/config.cpython-37.pyc and b/__pycache__/config.cpython-37.pyc differ diff --git a/__pycache__/events.cpython-37.pyc b/__pycache__/events.cpython-37.pyc index e450c01..cf24544 100644 Binary files a/__pycache__/events.cpython-37.pyc and b/__pycache__/events.cpython-37.pyc differ diff --git a/__pycache__/maps.cpython-37.pyc b/__pycache__/maps.cpython-37.pyc index 243fdd1..07b85ce 100644 Binary files a/__pycache__/maps.cpython-37.pyc and b/__pycache__/maps.cpython-37.pyc differ diff --git a/__pycache__/sprites.cpython-37.pyc b/__pycache__/sprites.cpython-37.pyc index 40742d5..c289118 100644 Binary files a/__pycache__/sprites.cpython-37.pyc and b/__pycache__/sprites.cpython-37.pyc differ diff --git a/config.py b/config.py index fc4a99c..e010d4e 100644 --- a/config.py +++ b/config.py @@ -4,7 +4,7 @@ from pygame.locals import * # Runtime settings WINDOW_WIDTH = 720 -WINDOW_HEIGHT = 720 +WINDOW_HEIGHT = 1000 FPS = 30 WIN_NAME = "Kostschevsky's shooter" diff --git a/data/graphics/asd.png b/data/graphics/asd.png deleted file mode 100644 index 94f214b..0000000 Binary files a/data/graphics/asd.png and /dev/null differ diff --git a/data/graphics/bg.png b/data/graphics/bg.png index e061aff..e5de3ca 100644 Binary files a/data/graphics/bg.png and b/data/graphics/bg.png differ diff --git a/data/graphics/bullet.png b/data/graphics/bullet.png index 80b77dd..0cc828d 100644 Binary files a/data/graphics/bullet.png and b/data/graphics/bullet.png differ diff --git a/data/graphics/p1.png b/data/graphics/p1.png index 084830e..df31e05 100644 Binary files a/data/graphics/p1.png and b/data/graphics/p1.png differ diff --git a/data/graphics/p2.png b/data/graphics/p2.png index 2c48ebf..9d903fb 100644 Binary files a/data/graphics/p2.png and b/data/graphics/p2.png differ diff --git a/data/graphics/splash.png b/data/graphics/splash.png new file mode 100644 index 0000000..2c09e72 Binary files /dev/null and b/data/graphics/splash.png differ diff --git a/events.py b/events.py index 899980f..60fed3a 100644 --- a/events.py +++ b/events.py @@ -24,6 +24,11 @@ clock2=pygame.time.Clock() clock2.tick() timer2=1000 +bars=[] + +bars.append(HPBar(200,886)) +bars.append(HPBar(570,886)) + def events(): global running for event in pygame.event.get(): @@ -57,8 +62,10 @@ def bullethits(): hits2=pygame.sprite.groupcollide(p1_group, p2_bullet_group, False, True) if hits1: players[1].gothit() + bars[1].gothit() if hits2: players[0].gothit() + bars[0].gothit() def player1_input(keys): if keys[P1_SHOOT]: diff --git a/mygame.py b/mygame.py index 11b7edf..95cea72 100644 --- a/mygame.py +++ b/mygame.py @@ -1,6 +1,6 @@ # import all files from config import * -from sprites import Player, all_sprites, load_img, screen +from sprites import Player, all_sprites, load_img, screen, HPBar, load_img_noalpha from colours import * import maps import events @@ -25,7 +25,7 @@ events.p1_group.add(events.players[0]) events.p2_group.add(events.players[1]) all_sprites.add(events.players) events.running=True - +all_sprites.add(events.bars) # debug text font=pygame.font.SysFont("Arial", 12) @@ -40,14 +40,25 @@ def draw_debug_text(): screen.blit(text, (0,count*12)) count+=1 -bg, bg_rect=load_img("bg.png") +bg, bg_rect=load_img_noalpha("bg.png") +splash, splash_rect=load_img_noalpha("splash.png") + +def waitforkey(): + waiting=True + while waiting: + clock.tick(FPS) + keys=pygame.key.get_pressed() + if keys[pygame.K_SPACE]: + waiting=False def startscreen(): - screen.fill(BGCOLOR) - + screen.blit(splash,(0,0)) + pygame.display.flip() + waitforkey() + # game loop while events.mainloop: - print('asd') + #startscreen() while events.running: clock.tick(FPS) # events @@ -60,7 +71,7 @@ while events.mainloop: break # draw screen.blit(bg,(0,0)) - draw_debug_text() + #draw_debug_text() all_sprites.draw(screen) pygame.display.flip() print('asd') diff --git a/sprites.py b/sprites.py index 188de1a..122a297 100644 --- a/sprites.py +++ b/sprites.py @@ -17,6 +17,12 @@ def load_img(name): image.set_colorkey(colorkey, RLEACCEL) return image, image.get_rect() +def load_img_noalpha(name): + img_path=os.path.join('data/graphics', name) + image=pygame.image.load(img_path).convert() + colorkey=image.get_at((0,0)) + return image, image.get_rect() + def load_sound(name): sound_path=os.path.join('data/sounds') sound=pygame.mixer.Sound(sound_path) @@ -25,7 +31,6 @@ def load_sound(name): # sprite groups all_sprites=pygame.sprite.Group() - # sprites classes vec=pygame.math.Vector2 @@ -130,3 +135,19 @@ class Bullet(pygame.sprite.Sprite): self.shoot() if not pygame.sprite.spritecollideany(self, maps.bwalls, collided = None)==None: self.kill() + +class HPBar(pygame.sprite.Sprite): + def __init__(self, x, y): + pygame.sprite.Sprite.__init__(self) + self.image=pygame.Surface((150, 30)) + self.image.fill((87,156,135)) + self.rect=self.image.get_rect() + self.rect.center=((x, y)) + self.width=150 + + def gothit(self): + self.width-=int(150*(BULLET_DMG/100)) + self.image=pygame.transform.scale(self.image, (self.width, 30)) + + def update(self): + self.gothit \ No newline at end of file