samengine 1.6.4 → 1.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -58,11 +58,11 @@ startEngine(init, gameLoop);
58
58
  ### Using Bun (local development)
59
59
 
60
60
  ```sh
61
- npx samengine-build # Start Dev Server
62
- npx samengine-build --release # Production build
63
- npx samengine-build --new # Create a new project with a
64
- # simple Snake Clone as Template
65
- npx samengine-build --new-empty # Create a new empty project
61
+ npx samengine-build # Start Dev Server
62
+ npx samengine-build --release # Production build
63
+ npx samengine-build --new (newproject) # Create a new project with a
64
+ # simple Snake Clone as Template
65
+ npx samengine-build --new-empty (new) # Create a new empty project
66
66
  ```
67
67
 
68
68
  ### Configuration
@@ -130,11 +130,13 @@ MIT
130
130
 
131
131
  *(I dont now why i added this)*
132
132
 
133
- ## More Tools for samengine
133
+ ## More Tools for samengine and Game Making by me lol
134
134
 
135
135
  - [samengine-build](https://www.npmjs.com/package/samengine-build)
136
136
  - [samengine-cli](https://www.npmjs.com/package/samengine-cli)
137
137
  - [old deprecated npm package](https://www.npmjs.com/package/@shadowdara/webgameengine)
138
+ - [linksaver](https://github.com/shadowdara/linksaver)
139
+
138
140
  <!--
139
141
 
140
142
  IDEAS
@@ -1,4 +1,4 @@
1
1
  // Function to get the Version
2
2
  export function version() {
3
- return "1.6.4";
3
+ return "1.6.5";
4
4
  }
@@ -0,0 +1,8 @@
1
+ import { Rect } from "./rectangle.js";
2
+ export type Button = {
3
+ form: Rect;
4
+ text: string;
5
+ };
6
+ export declare function makeButton(form: Rect, text: string): Button;
7
+ export declare function clickedButton(btn: Button): boolean;
8
+ export declare function drawButton(btn: Button, ctx: CanvasRenderingContext2D, color?: string, textColor?: string, font?: string): void;
@@ -0,0 +1,27 @@
1
+ // Button
2
+ import { getMouse } from "../input.js";
3
+ import { isRectClicked } from "./rectangle.js";
4
+ import { drawRect } from "../renderer.js";
5
+ import { renderText } from "../renderer.js";
6
+ // Function to create a new Button Type
7
+ export function makeButton(form, text) {
8
+ return {
9
+ form: form,
10
+ text: text
11
+ };
12
+ }
13
+ // Prüft, ob der Button geklickt wurde
14
+ export function clickedButton(btn) {
15
+ const mouse = getMouse();
16
+ return isRectClicked(mouse, btn.form);
17
+ }
18
+ // Zeichnet den Button (Rechteck + Text)
19
+ export function drawButton(btn, ctx, color = "#444", textColor = "white", font = "20px Arial") {
20
+ drawRect(ctx, btn.form, color);
21
+ // Text mittig im Button platzieren
22
+ const textX = btn.form.x + btn.form.width / 2;
23
+ const textY = btn.form.y + btn.form.height / 2;
24
+ ctx.textAlign = "center";
25
+ ctx.textBaseline = "middle";
26
+ renderText(ctx, btn.text, textX, textY, textColor, font);
27
+ }
@@ -4,3 +4,4 @@ export { type Color, makeColor, invertcolor, invertHexColor } from "./color.js";
4
4
  export { type Rect, makeRect, centerRectX, centerRectY, centerRect, isPointInRect, isMouseInRect, isRectClicked } from "./rectangle.js";
5
5
  export { type Circle, makeCircle, centerCircle, isPointInCircle, isMouseInCircle, isCircleClicked, isCircleColliding, getCircleDistance } from "./circle.js";
6
6
  export { type Triangle, makeTriangle, centerTriangle, isPointInTriangle, isMouseInTriangle, isTriangleClicked, getTrianglePerimeter, } from "./triangle.js";
7
+ export { type Button, makeButton, clickedButton, drawButton } from "./button.js";
@@ -11,3 +11,5 @@ export { makeRect, centerRectX, centerRectY, centerRect, isPointInRect, isMouseI
11
11
  export { makeCircle, centerCircle, isPointInCircle, isMouseInCircle, isCircleClicked, isCircleColliding, getCircleDistance } from "./circle.js";
12
12
  // Triangle Type
13
13
  export { makeTriangle, centerTriangle, isPointInTriangle, isMouseInTriangle, isTriangleClicked, getTrianglePerimeter, } from "./triangle.js";
14
+ // Button Type
15
+ export { makeButton, clickedButton, drawButton } from "./button.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "samengine",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
4
4
  "description": "A TypeScript game library to make HTML Games",
5
5
  "sideEffects": false,
6
6
  "files": [