generated from projects/testosmaximus
fix: update version to 1.3.7 in package.json and package-lock.json; enhance drawing functions in RickGamePanel for improved gameplay visuals
This commit is contained in:
parent
e85af99cd7
commit
a3cfc4dbb3
4
source/package-lock.json
generated
4
source/package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@funky-flask-test/funky-flask-test",
|
"name": "@funky-flask-test/funky-flask-test",
|
||||||
"version": "1.3.6",
|
"version": "1.3.7",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@funky-flask-test/funky-flask-test",
|
"name": "@funky-flask-test/funky-flask-test",
|
||||||
"version": "1.3.6",
|
"version": "1.3.7",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^24.0.15",
|
"@types/node": "^24.0.15",
|
||||||
"typescript": "^5.8.3",
|
"typescript": "^5.8.3",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@funky-flask-test/funky-flask-test",
|
"name": "@funky-flask-test/funky-flask-test",
|
||||||
"version": "1.3.6",
|
"version": "1.3.7",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist/index.jsx",
|
"main": "./dist/index.jsx",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@ -146,26 +146,85 @@ export class RickGamePanel {
|
|||||||
private draw() {
|
private draw() {
|
||||||
const ctx = this.ctx;
|
const ctx = this.ctx;
|
||||||
ctx.clearRect(0, 0, 300, 200);
|
ctx.clearRect(0, 0, 300, 200);
|
||||||
ctx.fillStyle = '#222'; ctx.fillRect(0, 0, 300, 200);
|
ctx.fillStyle = '#222';
|
||||||
ctx.fillStyle = '#444'; ctx.fillRect(0, 190, 300, 10);
|
ctx.fillRect(0, 0, 300, 200); // background
|
||||||
|
ctx.fillStyle = '#444';
|
||||||
|
ctx.fillRect(0, 190, 300, 10); // ground
|
||||||
|
|
||||||
|
// draw enemies
|
||||||
this.enemies.forEach(e => {
|
this.enemies.forEach(e => {
|
||||||
const img = this.assetImgs.dogWalk;
|
if (e.variant === 'fly') {
|
||||||
ctx.drawImage(img, e.x, e.y, e.size, e.size);
|
this.drawDogFly(e.x, e.y);
|
||||||
|
} else {
|
||||||
|
this.drawDogWalk(e.x, e.y);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.powerups.forEach(p => {
|
|
||||||
const img = this.assetImgs.nut;
|
// draw powerups
|
||||||
ctx.drawImage(img, p.x, p.y, p.size, p.size);
|
this.powerups.forEach(p => this.drawNut(p.x, p.y));
|
||||||
});
|
|
||||||
const pl = this.assetImgs.squirrel;
|
// draw player
|
||||||
ctx.drawImage(pl, this.player.x, this.player.y, this.player.width, this.player.height);
|
this.drawSquirrel(this.player.x, this.player.y);
|
||||||
ctx.fillStyle = '#fff'; ctx.font = '12px monospace';
|
|
||||||
|
// score
|
||||||
|
ctx.fillStyle = '#fff';
|
||||||
|
ctx.font = '12px monospace';
|
||||||
ctx.fillText(`Score: ${this.score}`, 200, 20);
|
ctx.fillText(`Score: ${this.score}`, 200, 20);
|
||||||
|
|
||||||
|
// game over
|
||||||
if (this.isGameOver) {
|
if (this.isGameOver) {
|
||||||
ctx.font = 'bold 16px monospace';
|
ctx.font = 'bold 16px monospace';
|
||||||
ctx.fillText('Game Over! Click to restart', 50, 100);
|
ctx.fillText('Game Over! Click to restart', 50, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private drawSquirrel(x: number, y: number) {
|
||||||
|
const ctx = this.ctx;
|
||||||
|
ctx.fillStyle = '#33f';
|
||||||
|
ctx.fillRect(x, y, 10, 10); // body
|
||||||
|
ctx.fillStyle = '#66f';
|
||||||
|
ctx.fillRect(x - 4, y + 2, 6, 6); // tail
|
||||||
|
}
|
||||||
|
|
||||||
|
private drawDogWalk(x: number, y: number) {
|
||||||
|
const ctx = this.ctx;
|
||||||
|
ctx.fillStyle = '#f33';
|
||||||
|
ctx.fillRect(x, y, 10, 10); // body
|
||||||
|
ctx.fillStyle = '#000';
|
||||||
|
ctx.fillRect(x + 2, y - 2, 2, 2); // ear left
|
||||||
|
ctx.fillRect(x + 6, y - 2, 2, 2); // ear right
|
||||||
|
}
|
||||||
|
|
||||||
|
private drawDogFly(x: number, y: number) {
|
||||||
|
const ctx = this.ctx;
|
||||||
|
ctx.fillStyle = '#ff3';
|
||||||
|
ctx.fillRect(x, y, 10, 10); // body
|
||||||
|
|
||||||
|
ctx.fillStyle = '#ccc';
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(x, y);
|
||||||
|
ctx.lineTo(x - 5, y + 5);
|
||||||
|
ctx.lineTo(x, y + 10);
|
||||||
|
ctx.fill(); // wing left
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(x + 10, y);
|
||||||
|
ctx.lineTo(x + 15, y + 5);
|
||||||
|
ctx.lineTo(x + 10, y + 10);
|
||||||
|
ctx.fill(); // wing right
|
||||||
|
}
|
||||||
|
|
||||||
|
private drawNut(x: number, y: number) {
|
||||||
|
const ctx = this.ctx;
|
||||||
|
ctx.fillStyle = '#a52a2a';
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(x + 5, y + 5, 5, 0, Math.PI * 2);
|
||||||
|
ctx.fill();
|
||||||
|
|
||||||
|
ctx.fillStyle = '#228B22';
|
||||||
|
ctx.fillRect(x + 3, y - 2, 4, 2); // little leaf on top
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function insertRickPanel(target: HTMLElement | string = document.body): void {
|
export function insertRickPanel(target: HTMLElement | string = document.body): void {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user