-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ajinkya
committed
Nov 14, 2023
1 parent
9121692
commit 8bb7d2e
Showing
20 changed files
with
315 additions
and
121 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import os | ||
|
||
ASSETS_PATH = os.path.abspath('.') + '/assets/' | ||
|
||
from .panel import * # noqa: F403 | ||
from .dialogue_panel import * # noqa: F403 | ||
from .selections import * # noqa: F403 | ||
from .select_item import * # noqa: F403 | ||
from .progress_bar import * # noqa: F403 | ||
from .textbox import * # noqa: F403 | ||
from .text import * # noqa: F403 | ||
from .icons import * # noqa: F403 | ||
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
The icon texture is 180x180 pixels and each icon is 18x18 pixels. Therefore, the texture | ||
sheet can contain up to 100 icons. That’s more than enough for our needs! What we | ||
want to do is take this texture, split it up into 18 x 18 pixels chunks, and create a sprite | ||
for each icon we want to use. Each icon is given a simple id. | ||
Icon Category: | ||
usable = 1, | ||
accessory = 2, | ||
weapon = 3, | ||
armor = 4, | ||
up_arrow = 5, | ||
down_arrow = 6 | ||
""" | ||
from enum import Enum, auto | ||
from typing import Dict | ||
|
||
import pygame | ||
|
||
from sprite_utils import load_sprite_sheet | ||
|
||
|
||
class Icons: | ||
def __init__(self, spritesheet_path: str): | ||
self.spritesheet = load_sprite_sheet(spritesheet_path, 18, 18, 2, 10) | ||
self.icon_category = { | ||
"usable": 1, | ||
"accessory": 2, | ||
"weapon": 3, | ||
"armor": 4, | ||
"up_arrow": 5, | ||
"down_arrow": 6 | ||
} | ||
self.icons: Dict[str, pygame.Surface] = {} | ||
self.create_icons() | ||
|
||
def create_icons(self): | ||
for category, idx in self.icon_category.items(): | ||
self.icons[category] = self.spritesheet[idx] | ||
|
||
def get_icon(self, category: str) -> pygame.Surface: | ||
assert category in self.icons, f"Icon id {category} not found" | ||
return self.icons[category] |
This file contains 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
This file contains 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
Oops, something went wrong.