Skip to content

fix: fix clipping display issues and add layer support#11

Open
jatoothless wants to merge 4 commits intomainfrom
fix/fix-display
Open

fix: fix clipping display issues and add layer support#11
jatoothless wants to merge 4 commits intomainfrom
fix/fix-display

Conversation

@jatoothless
Copy link
Copy Markdown
Member

  • Naprawiłam clippowanie przez podłoge
  • Lekko poprawiłam rysowanie mapy
  • Dodałam warstwy

@jatoothless jatoothless requested a review from bnszky March 9, 2026 13:44
@jatoothless jatoothless linked an issue Mar 11, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Member

@bnszky bnszky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super, właśnie też nad tym się zastanawiałem, żeby przenieść tworzenie mapy do osobnej klasy. Odnośnie zmian z dodawaniem nowym obiektów i refactoringiem zmiany są tutaj: refactor/add-srp-and-ocp. To myślę, że można zmergować

@bnszky
Copy link
Copy Markdown
Member

bnszky commented Mar 16, 2026

Na mainie są teraz jeszcze kable, więc możesz również je dodać do warst i wtedy rebase

Copy link
Copy Markdown
Member

@bnszky bnszky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stwórzmy strukturę danych, która pozwoli w łatwy sposób dodawać nowe layery i priorytetować ich kolejność, nazwy powinny znaleźć się w pliku globalnym np constants/global

Tam tworzymy np. listę:
layers = ["background", "floor_decoys", "entities", "wall decoys", "effects"]

automatycznie indeksy oznaczają kolejność i setDepth

Wyobraźmy sobie sytuację, że chcemy dodać nową warstwę np. "entities2" i wiemy, że powinna znaleźć się po "entities". Wtedy w tej liście po prostu wstawimy "entities2" i displayer sam to posortuje.

W kodzie dodamy wtedy tylko add(object, "entities2") i tyle

W tym momencie musielibyśmy zmieniać wiele linijek żeby wprowadzić nową warstwę
CEL: dodawać warstwę tylko w liście layers

I tak dużo już się udało zrobić. Ta zmiana zaoszczędzi później czas i odchudzi jeszcze bardziej kod

Comment on lines +3 to +16
const TILE_MAPPING: Record<
string,
{ frame: number; isTall?: boolean; frameSecond?: number }
> = {
w1t: { frame: 0, frameSecond: 10, isTall: true },
w1: { frame: 0 },
w13: { frame: 9 },
w2t: { frame: 2, frameSecond: 4, isTall: true },
w2: { frame: 2 },
w3t: { frame: 3, frameSecond: 4, isTall: true },
w3: { frame: 3 },
w21: { frame: 8 },
f1: { frame: 6 },
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usuń TILE_MAPPING i importuj z constants/blocks. Tam już jest

Comment on lines +21 to +25
private BACKGROUND: Phaser.GameObjects.Layer;
private FLOOR_DECOYS: Phaser.GameObjects.Layer;
private ENTITIES: Phaser.GameObjects.Layer;
private WALL_DECOYS: Phaser.GameObjects.Layer;
private EFFECTS: Phaser.GameObjects.Layer;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zamiast tego można napisać
private LAYERS: Phaser.GameObjects.Layer[]

Comment on lines +49 to +54
layer:
| "background"
| "floor decoys"
| "entities"
| "wall decoys"
| "effects",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stwórz interface LayerNames z tymi nowymi nazwami i wtedy wszędzie:

layer: LayerNames

Comment on lines +65 to +70
layer: //Layery są tu poukładane od najgłębszego do najpłytszego
| "background" //ściany i podłoga
| "floor decoys" //wszystko co na podłodze - venty, guziki, kable
| "entities" //gracz kapibara i rzeczy które "stoją na podłodze"
| "wall decoys" //rzeczy typu drzwi
| "effects", //efekty - np dymki
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

layer: LayerNames

Comment on lines +75 to +80
layer:
| "background"
| "floor decoys"
| "entities"
| "wall decoys"
| "effects",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LayerNames

@bnszky
Copy link
Copy Markdown
Member

bnszky commented Apr 2, 2026

i jeszcze zamiast stringów najlepiej zrobić słownik, bo będzie problem jak zmienimy "wall_decoys" na "walls_decoy", więc
np.
LayerNamesEnum = {
BACKGROUND: "background",
etc...
}

add(object, LayerNamesEnum.BACKGROUND)

*Komentarze po angielsku

@jatoothless jatoothless requested a review from bnszky April 3, 2026 16:14
Copy link
Copy Markdown
Member

@bnszky bnszky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Właśnie o to chodziło, jeszcze tylko dopisałem, żeby nie używać hardkodowanych stringów w kodzie, tylko stworzyć jakiś słownik, gdyby ktoś się pomylił, wpisując np. "entitties" zamiast "entities". Aktualnie linter nam tego nie podświetli z taką literówką, ale kod nie będzie poprawnie działał.

Nie musisz tego poprawiać, mogę to zrobić ja już w osobnym branchu, więc daje approve


for (const crate of message.crates) {
this.spawnEntity(this.crates, Crate, crate);
this.spawnEntity(this.crates, Crate, crate, "entities");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.spawnEntity(this.crates, Crate, crate, "entities");
this.spawnEntity(this.crates, Crate, crate, LAYER_NAMES_GLOBAL.ENTITIES);


if (tileType !== "") {
this.layerMap
.get("background")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.get("background")
.get(LAYER_NAMES_GLOBAL.BACKGROUND)

Comment on lines +9 to +15
export const LAYERS = [ //Layers in order of deepest to shallowest
"background", //Floor tiles and wall tiles
"floor decoys", //Things on the floor such as vents or buttons
"entities", //Players, enemies and things above floor decoys like lasers
"wall decoys", //Upper parts of walls and doord
"effects", //Extra effects rendered on top like speech bubbles
] as const;
Copy link
Copy Markdown
Member

@bnszky bnszky Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const LAYERS = [ //Layers in order of deepest to shallowest
"background", //Floor tiles and wall tiles
"floor decoys", //Things on the floor such as vents or buttons
"entities", //Players, enemies and things above floor decoys like lasers
"wall decoys", //Upper parts of walls and doord
"effects", //Extra effects rendered on top like speech bubbles
] as const;
export const LAYER_NAMES_GLOBAL = {
BACKGROUND: "background",
FLOOR_DECOYS: "floor decoys",
ENTITIES: "entities",
WALL_DECOYS: "wall decoys",
EFFECTS: "effects",
}
as const;
export const LAYERS = [
//Layers in order of deepest to shallowest
LAYER_NAMES_GLOBAL.BACKGROUND, //Floor tiles and wall tiles
LAYER_NAMES_GLOBAL.FLOOR_DECOYS, //Things on the floor such as vents or buttons
LAYER_NAMES_GLOBAL.ENTITIES, //Players, enemies and things above floor decoys like lasers
LAYER_NAMES_GLOBAL.WALL_DECOYS, //Upper parts of walls and doord
LAYER_NAMES_GLOBAL.EFFECTS, //Extra effects rendered on top like speech bubbles
] as const;

Comment on lines +75 to +80
layer:
| "background"
| "floor decoys"
| "entities"
| "wall decoys"
| "effects",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
layer:
| "background"
| "floor decoys"
| "entities"
| "wall decoys"
| "effects",
layer: LayerNames

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dodać layery by wyświetlać mapę

2 participants