repl.it
@joshwood/

The Journey of Bella Shores-5

Pygame

No description

fork
loading
Files
  • main.py
  • assets
  • engine.py
  • entity.py
  • game_manager.py
  • map_manager.py
  • nohup.out
  • README.txt
  • sprite_manager.py
  • user_interface.py
  • Packager files
  • requirements.txt
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
69
import pygame
import time
from game_manager import GameManager
import random
import replit

# Global Constants
SCREEN_W = 800
SCREEN_H = 600
FPS = 60  # FPS cap (speed of game events is based on time, not fps)
random.seed(43252003274489856000)

def main():
    """Main Program"""
    print('Starting game...')
    pygame.init()

    size = (SCREEN_W, SCREEN_H)
    flags = pygame.DOUBLEBUF | pygame.FULLSCREEN
    screen = pygame.display.set_mode(size, flags)
    pygame.display.set_caption("The Adventures of Bella Shores")
    icon = pygame.image.load("assets/sprites/boats/uboat2.png")
    pygame.display.set_icon(icon)
    pygame.mouse.set_visible(False)

    clock = pygame.time.Clock()

    # makes loading screen for map generation
    screen.fill((66, 206, 244))
    font = pygame.font.Font("/home/runner/assets/fonts/6809 chargen.ttf", 36)
    big_font = pygame.font.Font("/home/runner/assets/fonts/6809 chargen.ttf", 40)
    textsurface = big_font.render("THE JOURNEY OF BELLA SHORES", False, (255, 255, 255))
    textsurface1 = font.render("GENERATING MAP...", False, (255, 255, 255))
    textsurface2 = font.render("(THIS MAY TAKE A MINUTE)", False, (255, 255, 255))
    screen.blit(textsurface, (16, 16))
    screen.blit(textsurface1, (16, 66))
    screen.blit(textsurface2, (16, 102))
    pygame.display.flip()

    replit.clear()
    game_manager = GameManager(SCREEN_W, SCREEN_H) # creation of this object takes a bit

    prev_time = time.time()  # for printing fps
    delta_time = 0
    fps_list = []

    while game_manager.running:
        time_frame_start = pygame.time.get_ticks()

        game_manager.update(delta_time)

        game_manager.draw(screen)
        pygame.display.flip()

        clock.tick(FPS)
        delta_time = pygame.time.get_ticks() - time_frame_start

        # this just prints the fps every second
        fps_list.append(clock.get_fps())
        if time.time() - prev_time > 5:
            avg_fps = sum(fps_list) / len(fps_list)
            print("FPS: " + str(int(avg_fps)))
            fps_list.clear()
            prev_time = time.time()


if __name__ == "__main__":
    main()