-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.py
78 lines (62 loc) · 1.94 KB
/
settings.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
70
71
72
73
74
75
76
77
78
"""Game settings
This file contains all game settings such window dimensions, resolution,
default objects values, textures, sounds, fonts, etc.
Author: Alejandro Mujica (aledrums@gmail.com)
Date: 07/11/2020
"""
import pygame
pygame.init()
# Physical screen dimensions
WINDOW_WIDTH = 1280
WINDOW_HEIGHT = 720
# Virtual resolution dimensions
VIRTUAL_WIDTH = 512
VIRTUAL_HEIGHT = 288
# Point where the background image is repeated
BACKGROUND_LOOP_POINT = 1157
# Height of the ground image
GROUND_HEIGHT = 16
GROUND_SPEED = 60
# Log speed is the same as the ground
LOG_SPEED = 60
# Background speed is lower to give the feeling that it is the horizon
BACKGROUND_SPEED = 30
# Log dimensions
LOG_WIDTH = 70
LOG_HEIGHT = 288
# The gap between the upper and lower log
LOG_GAP = 80
# GRAVITY is an acceleration value
GRAVITY = 980
# Dictionary of sound effects
GAME_SOUNDS = {
'jump': pygame.mixer.Sound('sounds/jump.wav'),
'score': pygame.mixer.Sound('sounds/score.wav'),
'death': pygame.mixer.Sound('sounds/death.wav'),
'pause': pygame.mixer.Sound('sounds/pause.wav'),
}
# Dictionary of different sizes for fonts
GAME_FONTS = {
'medium': pygame.font.Font('fonts/flappy.ttf', 18),
'large': pygame.font.Font('fonts/flappy.ttf', 30),
'huge': pygame.font.Font('fonts/flappy.ttf', 60),
}
# Dictionary of game images
GAME_TEXTURES = {
'background': pygame.image.load('graphics/background.png'),
'ground': pygame.image.load('graphics/ground.png'),
'bird': pygame.image.load('graphics/bird.png'),
'log': pygame.image.load('graphics/log.png'),
}
# This dictionary is initialized empty.
# When a key is pressed (detected by the KEYDOWN event),
# it will be added to this dictionary associating it the value True.
#
# Usage:
# To check whether the key "return" has been pressed
#
# if pressed_keys.get(pygame.K_RETURN):
# # Action for RETURN key presed
pressed_keys = {}
# Global variable to indicate that the game is paused
paused = False