Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/gear-foundation/dapps
Browse files Browse the repository at this point in the history
  • Loading branch information
faizov committed Mar 22, 2024
2 parents 9604e80 + 0450ad4 commit 7b3db19
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
13 changes: 7 additions & 6 deletions frontend/apps/vara-man/src/feature/game/models/Character.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ export class Character {
}

getBounds() {
const padding = 4; // Величина, на которую уменьшается хитбокс
return {
x: this.position.x - this.torsoWidth / 2,
y: this.position.y - this.torsoHeight * 2,
width: this.torsoWidth,
height: this.torsoHeight + this.legHeight,
x: this.position.x - (this.torsoWidth / 2) + padding,
y: this.position.y - (this.torsoHeight * 2) + padding,
width: this.torsoWidth - (padding * 2),
height: (this.torsoHeight + this.legHeight) - (padding * 2),
}
}

Expand Down Expand Up @@ -126,11 +127,11 @@ export class Character {
isShift: boolean
): void {
if (isLeft) {
this.rotation -= Math.PI * 0.03
this.rotation -= Math.PI * 0.015
}

if (isRight) {
this.rotation += Math.PI * 0.03
this.rotation += Math.PI * 0.015
}

if (isUp || isDown) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ export class CharacterRenderer {

const radius = 5

// Hands
arms.forEach((arm: { limb: string; height: number }) => {
context.strokeStyle = '#00E3AE'
context.fillStyle = '#00E3AE'
context.beginPath()
context.roundRect(
arm.limb === 'left' ? -torsoWidth / 2 : torsoWidth / 2 - armWidth,
-torsoHeight / 4,
armWidth,
arm.height,
5
)
context.stroke()
context.fill()
})

// Torso
context.beginPath()
context.fillStyle = '#00FFC4'
Expand Down Expand Up @@ -73,22 +89,6 @@ export class CharacterRenderer {
context.closePath()
context.fill()

// Hands
arms.forEach((arm: { limb: string; height: number }) => {
context.strokeStyle = '#00E3AE'
context.fillStyle = '#00E3AE'
context.beginPath()
context.roundRect(
arm.limb === 'left' ? -torsoWidth / 2 : torsoWidth / 2 - armWidth,
-torsoHeight / 4,
armWidth,
arm.height,
5
)
context.stroke()
context.fill()
})

// Head
context.beginPath()
context.fillStyle = '#000000'
Expand All @@ -104,7 +104,7 @@ export class CharacterRenderer {
context.restore()

// Drawing a border for debug
// const bounds = enemy.getBounds()
// const bounds = character.getBounds()
// context.strokeStyle = 'rgba(255, 0, 0, 0.5)'
// context.strokeRect(bounds.x, bounds.y, bounds.width, bounds.height)
}
Expand Down

0 comments on commit 7b3db19

Please sign in to comment.