A gamepad usage example
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Pandemic_Pong/game_objects/pong_constants.py

86 lines
2.4 KiB

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
pong_constants.py
Pandemic Pong global constants
"""
DEVLOCAL = False # TODO: For client/server local development set to 'True'! For publication to 'False'!
"""Buttons in 'state<n>'"""
BTN_STATE_NONE = 0 # No Button pressed ...
BTN_TRIGGER = 1 # [Blue/X]
BTN_THUMB = 2 # [Red/A]
BTN_THUMB2 = 4 # [Yellow/B]
BTN_TOP = 8 # [Green/Y]
BTN_TOP2 = 16 # [Frontal left]
BTN_PINKIE = 32 # [Frontal right]
BTN_BASE3 = 64 # [Centre left]
BTN_BASE4 = 128 # [Centre right]
# Colors to be used
COL_WHITE = 0 # White = not infectious
COL_BLUE = 1 # Virus color
COL_GREEN = 2 # Virus color
COL_RED = 3 # Virus color
COL_YELLOW = 4 # virus color
"""Infectiousness time"""
COLORDELAY = 100
"""Game states"""
STATE_WELCOME = 0
STATE_START = 1
STATE_PLAY = 2
STATE_GAMERESULTS = 3
STATE_FINALRESULTS = 4
STATE_RESTART = 5
STATE_EXIT = 6
"""File paths"""
wall_contact = './sounds/contact.ogg' # player & wall actually
player_contact = wall_contact
player_miss = './sounds/miss.wav'
game_splash = './sounds/splash.wav'
game_exit = './sounds/bye.wav'
game_win = './sounds/gamewin.wav'
match_win = './sounds/matchwin.wav'
NOSOUND = 0
WALLCONTACTSOUND = 1
PLAYERCONTACTSOUND = 2
PLAYERMISSSOUND = 3
GAMESPLASHSOUND = 4
GAMEEXITSOUND = 5
GAMEWINSOUND = 6
MATCHWINSOUND = 7
"""IP network access"""
PANDEMIC_PONG_PORT = 5050 # PP (Pandemic Pong!)
PACKETTYPE_ALLDATA = 0xffa0 # Packet start indicator
PACKETTYPE_PLAYER = 1
UDP_TRANSFER_FORMAT = "iiiffffii"
TCP_TRANSFER_FORMAT = "i"+"iiiii"+"iiffffiii"+"iiffffiii"+"ffffffiii"
# Game: state, delay, p1_game, p2_game, playsound
# Player1: player_index, state, x, y, delta_x, delta_y, color, delay, score
# Player2: player_index, state, x, y, delta_x, delta_y, color, delay, score
# Ball: x, y, w, h, delta_x, delta_y, color, delay, playsound
""" Sounds """
sounds = {
WALLCONTACTSOUND : wall_contact,
PLAYERCONTACTSOUND : player_contact,
PLAYERMISSSOUND : player_miss,
GAMESPLASHSOUND : game_splash,
GAMEEXITSOUND : game_exit,
GAMEWINSOUND : game_win,
MATCHWINSOUND : match_win
}
""" Game area dimensions, shall be mutable to adjust for window resize (later)"""
GAMEAREA_MIN_X = 0 # Game area left border
GAMEAREA_MAX_X = 1920 # Assume FHD resolution by default
GAMEAREA_MIN_Y = 15 # Game area top border
GAMEAREA_MAX_Y = 940 # Game area bottom range