Last active
April 4, 2021 19:49
-
-
Save p-acDev/78bafc285018022ea8ea51a149394d7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "appName": "War Game", | |
| "windowSettings": { | |
| "WIDTH": 900, | |
| "HEIGHT": 500 | |
| }, | |
| "FPS": 60 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class WarGameUI: | |
| def __init__(self, config_file): | |
| # import the input data | |
| with open(config_file, "r") as f: | |
| self.CONFIG = json.load(f) | |
| # setup initial windows | |
| self.WIN = pygame.display.set_mode((self.CONFIG["windowSettings"]["WIDTH"], | |
| self.CONFIG["windowSettings"]["HEIGHT"])) | |
| pygame.display.set_caption(self.CONFIG["appName"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Player: | |
| def __init__(self, player_profile): | |
| with open(player_profile, "r") as f: | |
| profile = json.load(f) | |
| self.player_image = pygame.image.load(os.path.join('assets', | |
| profile["player_picture"])) | |
| self.player_image = pygame.transform.scale(self.player_image,(profile["width"], | |
| profile["height"])) | |
| self.name = profile["playerName"] | |
| self.width = profile["width"] | |
| self.height = profile["height"] | |
| self.initialX = profile["initialX"] - self.width / 2 | |
| self.initialY = profile["initialY"] - self.height / 2 | |
| self.x = self.initialX | |
| self.y = self.initialY | |
| self.keyUp = profile["keyUp"] | |
| self.keyDown = profile["keyDown"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "player_picture": "bar.png", | |
| "playerName": "left", | |
| "initialX": 10, | |
| "initialY": 250, | |
| "width": 15, | |
| "height": 50, | |
| "keyUp": "a", | |
| "keyDown": "q", | |
| "fire": "s" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment