repl.it
@p_loo/

Swamp_Game Ask

Pygame

No description

fork
loading
Files
  • main.py
  • pics
  • boss.py
  • character.py
  • nohup.out
  • z_nohup.out
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import pygame
import random
from character import Char
from boss import Boss
 
# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (118,238,0)
RED = (255,48,48)
 
pygame.init()

swamp = pygame.image.load("pics/swamp.png")
swamp = pygame.transform.scale(swamp, (800,600))

# Set the height and width of the screen
size = [800,600]
screen = pygame.display.set_mode(size)

boss_list = pygame.sprite.Group()
all_sprites_list = pygame.sprite.Group() 

player = Char(BLACK, 30, 30)
all_sprites_list.add(player)

boss_player = Boss(BLACK, 30, 30)
boss_list.add(boss_player)
all_sprites_list.add(boss_player)

# Loop until the user clicks the close button.
done = False
 
# Used to manage how fast the screen updates
clock = pygame.time.Clock()
 
health = 200

# -------- Main Program Loop -----------
while not done:
    for event in pygame.event.get():  # User did something
        if event.type == pygame.QUIT:  # If user clicked close
            done = True  
    
    screen.blit(swamp, (0,0))

    all_sprites_list.update()

    pygame.draw.rect(screen, RED, (20,10,200,20))
    pygame.draw.rect(screen, GREEN, (20,10,health,20))

    keys = pygame.key.get_pressed()
    if keys[pygame.K_LEFT]:
        player.moveLeft(20)
    if keys[pygame.K_RIGHT]:
          player.moveRight(20)

    all_sprites_list.draw(screen)
    
    clock.tick(60)
 
    # Go ahead and update the screen with what we've drawn.
    pygame.display.flip()
 
# Be IDLE friendly. If you forget this line, the program will 'hang'
# on exit.
pygame.quit()