Skip to content

Commit

Permalink
Merge pull request #4 from Deseteral/post-ld54
Browse files Browse the repository at this point in the history
Post Ludum Dare 54
  • Loading branch information
Deseteral authored Oct 12, 2023
2 parents b62af4e + 6a1fa75 commit 2a3eb57
Show file tree
Hide file tree
Showing 21 changed files with 350 additions and 110 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,29 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.0] - 2023-10-12
### Added
- Support for left and right mouse buttons.
- Euclidean search heuristic to pathfinding implementation.
- `String#capitalize` method.
- Sound can be played with specific volume.
- `Screen#clear*` methods for all existing primitives.
### Changed
- Renamed all `Screen#fill*` methods to `Screen#draw*`.
- Renamed all `Screen#draw*` methods to `Screen#draw*Lines*`.
### Fixed
- Fixed ImGui crashing the game in incognito mode.
- Various bug fixes, stability and performance improvements.

## [1.1.0] - 2023-09-28
- Added ImGui

## [1.0.0] - 2023-02-04
- Initial release

[unreleased]: https://github.com/Deseteral/ponczek/compare/v1.1.0...HEAD
[2.0.0]: https://github.com/Deseteral/ponczek/releases/tag/v1.1.2...v2.0.0
[1.1.2]: https://github.com/Deseteral/ponczek/releases/tag/v1.1.1...v1.1.2
[1.1.1]: https://github.com/Deseteral/ponczek/releases/tag/v1.1.0...v1.1.1
[1.1.0]: https://github.com/Deseteral/ponczek/releases/tag/v1.0.0...v1.1.0
[1.0.0]: https://github.com/Deseteral/ponczek/releases/tag/v1.0.0
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ Uses fantastic font [Monogram by datagoblin](https://datagoblin.itch.io/monogram

Works in every major browser.

# 🧰 Development
## 🏗️ Made using ponczek
- [Cargo Trek](https://deseteral.itch.io/cargo-trek) ([source code](https://github.com/Deseteral/cargo-trek))

## 🚧 Development
Install dependencies using `yarn`.

You can start examples project in watch mode using:
Expand All @@ -85,5 +88,8 @@ For type checking in watch mode during development use:
npm run test:type-check:watch
```

## 🪵 Changelog
You can read the project changelog [here](CHANGELOG).

## 📝 License
This project is licensed under the [MIT license](LICENSE).
4 changes: 2 additions & 2 deletions examples/src/scenes/camera-test-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ export class CameraTestScene extends Scene {
this.camera.begin();

scr.color(ENDESGA16PaletteIdx[9]);
scr.fillRectR(this.rect);
scr.drawRectR(this.rect);

scr.color(ENDESGA16PaletteIdx[6]);
scr.fillRect(this.playerPosition.x, this.playerPosition.y, 20, 20);
scr.drawRect(this.playerPosition.x, this.playerPosition.y, 20, 20);

this.camera.end();

Expand Down
8 changes: 4 additions & 4 deletions examples/src/scenes/drawing-test-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export class DrawingTestScene extends Scene {

const n = idx + 8;
const x = ((n * (n + 1)) / 2) - 34;
scr.fillRect(x, 10, idx + 1, idx + 1);
scr.drawRect(x, 25, idx + 1, idx + 1);
scr.drawRect(x, 10, idx + 1, idx + 1);
scr.drawRectLines(x, 25, idx + 1, idx + 1);
}
}

Expand Down Expand Up @@ -73,8 +73,8 @@ export class DrawingTestScene extends Scene {
for (let r = 1; r < 11; r += 1) {
scr.color(ENDESGA16PaletteIdx[r]);

scr.fillCircle((r * 20) - 10, 100, r);
scr.drawCircle((r * 20) - 10, 115, 10 - r);
scr.drawCircle((r * 20) - 10, 100, r);
scr.drawCircleLines((r * 20) - 10, 115, 10 - r);
}
}

Expand Down
8 changes: 4 additions & 4 deletions examples/src/scenes/effects-test-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export class EffectsTestScene extends Scene {
scr.clearScreen(Color.black);

scr.color(Color.green);
scr.fillRect(5, 10, 200, 150);
scr.fillRect(140, 100, 120, 120);
scr.fillRect(10, 180, 50, 50);
scr.fillCircle(250, 40, 25);
scr.drawRect(5, 10, 200, 150);
scr.drawRect(140, 100, 120, 120);
scr.drawRect(10, 180, 50, 50);
scr.drawCircle(250, 40, 25);

this.testEffect.applyToScreen(scr);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/src/scenes/font-rendering-test-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export class FontRenderingTestScene extends Scene {
render(scr: Screen): void {
scr.clearScreen(ENDESGA16PaletteIdx[10]);
scr.drawText(`Current tick ${Ponczek.ticks}!`, 10, 10, ENDESGA16PaletteIdx[13]);
scr.drawText('This text should be in red', 10, 20, ENDESGA16PaletteIdx[5]);
scr.drawText('This text should be red', 10, 20, ENDESGA16PaletteIdx[5]);

scr.color(ENDESGA16PaletteIdx[11]);
scr.fillRectR(this.rect);
scr.drawRectR(this.rect);

scr.drawTextInRectR('Glib jocks quiz nymph to vex dwarf.\n\nSphinx of black quartz, judge my vow.', this.rect, ENDESGA16PaletteIdx[8]);

Expand Down
4 changes: 2 additions & 2 deletions examples/src/scenes/grid-view-test-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class TestGridView extends GridView<Item> {
if (!item) return;

scr.color(ENDESGA16Palette.sap);
scr.fillRect(x, y, this.cellWidth, this.cellHeight);
scr.drawRect(x, y, this.cellWidth, this.cellHeight);

const selectionColor = isSelected ? ENDESGA16Palette.fabric : ENDESGA16Palette.pine;
scr.drawText(item.text, x + 2, y + 6, selectionColor);

scr.color(selectionColor);
scr.drawRect(x, y, this.cellWidth, this.cellHeight);
scr.drawRectLines(x, y, this.cellWidth, this.cellHeight);
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/src/scenes/imgui-test-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ export class ImGuiTestScene extends Scene {
scr.clearScreen(ENDESGA16PaletteIdx[6]);

scr.color(ENDESGA16PaletteIdx[14]);
scr.fillRect(10, 25, 128, 256);
scr.drawRect(10, 25, 128, 256);
}
}
4 changes: 2 additions & 2 deletions examples/src/scenes/main-menu-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ export class MainMenuScene extends Scene {

scr.color(ENDESGA16PaletteIdx[2]);

scr.fillRect(this.gridPosition.x - 2, this.gridPosition.y - 17, 93, 11);
scr.drawRect(this.gridPosition.x - 2, this.gridPosition.y - 17, 93, 11);
scr.drawNineSlice(this.frameTexture, this.gridPosition.x + 4, this.gridPosition.y - 13, 83, 10, 8, 8);
scr.drawText('Test scenes', this.gridPosition.x + 1, this.gridPosition.y - 14, ENDESGA16PaletteIdx[6]);

scr.fillRect(this.gridPosition.x - 3, this.gridPosition.y - 2, this.demoScenesGridView.totalWidth + 9, this.demoScenesGridView.totalHeight + 4);
scr.drawRect(this.gridPosition.x - 3, this.gridPosition.y - 2, this.demoScenesGridView.totalWidth + 9, this.demoScenesGridView.totalHeight + 4);
scr.drawNineSlice(this.frameTexture, this.gridPosition.x, this.gridPosition.y, this.demoScenesGridView.totalWidth, this.demoScenesGridView.totalHeight, 8, 8);
this.demoScenesGridView.drawAt(this.gridPosition, scr);
}
Expand Down
6 changes: 3 additions & 3 deletions examples/src/scenes/scene-stack-test-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ class PauseMenuScene extends Scene {

render(scr: Screen): void {
scr.color(this.backgroundColor);
scr.fillRect(0, 0, scr.width, scr.height);
scr.drawRect(0, 0, scr.width, scr.height);

scr.color(ENDESGA16PaletteIdx[2]);
scr.fillRect(this.gridPosition.x - 5, this.gridPosition.y - 5, this.gridWidth + 10, 48);
scr.drawRect(this.gridPosition.x - 5, this.gridPosition.y - 5, this.gridWidth + 10, 48);
this.grid.drawAt(this.gridPosition, scr);
}
}
Expand Down Expand Up @@ -103,7 +103,7 @@ export class SceneStackTestScene extends Scene {
scr.clearScreen(ENDESGA16PaletteIdx[9]);

scr.color(ENDESGA16PaletteIdx[10]);
scr.fillRectR(this.rect);
scr.drawRectR(this.rect);
scr.drawTextInRectR('Press "back" to open pause menu', this.rect, ENDESGA16PaletteIdx[11]);
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ponczek",
"version": "1.1.2",
"version": "2.0.0",
"description": "Deep-fried game framework with sweet filling",
"author": "Deseteral <github.com/deseteral>",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions src/core/datastore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export abstract class Datastore {
* Checks if the data exists for specified `key`.
* Returns `true` when there is something written for that `key`, `false` otherwise.
*/
public exists(key: string = DEFAULT_KEY): boolean {
public static exists(key: string = DEFAULT_KEY): boolean {
try {
const data = window.localStorage.getItem(key);
return !!data;
Expand All @@ -50,7 +50,7 @@ export abstract class Datastore {
/**
* Deletes data for specified `key`. Does nothing when there is no data for that `key`.
*/
public delete(key: string = DEFAULT_KEY): void {
public static delete(key: string = DEFAULT_KEY): void {
try {
window.localStorage.removeItem(key);
} catch (e) {
Expand Down
12 changes: 12 additions & 0 deletions src/core/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export abstract class Input {
* Pointer position in screen space.
*/
public static readonly pointer: Vector2 = new Vector2();
public static pointerLeftPressed: boolean = false;
public static pointerRightPressed: boolean = false;

private static keyState: Map<string, boolean> = new Map();
private static previousKeyState: Map<string, boolean> = new Map();
Expand Down Expand Up @@ -121,5 +123,15 @@ export abstract class Input {
((y / canvas.clientHeight) * canvas.height) | 0,
);
});

document.addEventListener('mousedown', (e) => {
if (e.button === 0) Input.pointerLeftPressed = true;
if (e.button === 2) Input.pointerRightPressed = true;
});

document.addEventListener('mouseup', (e) => {
if (e.button === 0) Input.pointerLeftPressed = false;
if (e.button === 2) Input.pointerRightPressed = false;
});
}
}
10 changes: 7 additions & 3 deletions src/core/scene-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,19 @@ export abstract class SceneManager {
* Removes all scenes from the stack and makes `nextScene` next active scene.
*/
public static clearStack(nextScene: Scene): void {
// TODO: This generates unnecessary allocation.
this.sceneStack = [nextScene];
while (SceneManager.sceneStack.length > 0) {
SceneManager.popScene();
}
SceneManager.pushScene(nextScene);
}

/**
* Removes all scenes except the oldest one, which will be the next active scene.
*/
public static backToRoot(): void {
this.clearStack(this.sceneStack.at(-1)!);
while (SceneManager.sceneStack.length > 1) {
SceneManager.popScene();
}
}

public static _update(): void {
Expand Down
Loading

0 comments on commit 2a3eb57

Please sign in to comment.