TGViewer
Moth Moth @namlessmoth · 44 subscribers
Post #95 47
Самое время добавить ворон. Я не буду подробно описывать их работу и поведение просто покажу вам код их компонента. Они просто летят в сторону игрока с небольшой инерцией.
export default function crownComp(obj) {
return {

id: "crownComp",
require: ["pos", "area"],

hasScissors: chance(0.2),
velocity: rand(10, 30),
directionX: 0,
directionY: 0,
horAcceliration: 0,
vertAcceliration: 0,
horSpeed: 0,
vertSpeed: 0,

add() {
if (this.hasScissors) {
let scissors = this.add([
anchor("center"),
pos(0,4),
sprite("crown"),
])

scissors.play("scissors")

scissors.onUpdate(() => {
scissors.flipX = this.flipX
})
}
},
update() {
this.directionX = Math.sign(obj.pos.x - this.pos.x)
this.directionY = Math.sign(obj.pos.y - this.pos.y)

this.horAcceliration += this.directionX * (1/this.velocity) * dt() * 100
this.vertAcceliration += this.directionY * (1/this.velocity) * dt() * 100

this.horAcceliration = clamp(this.horAcceliration, -5, 5)
this.vertAcceliration = clamp(this.vertAcceliration, -5, 5)

this.horSpeed = clamp(1/2 * this.horAcceliration, -5, 5)
this.vertSpeed = clamp(1/2 * this.vertAcceliration, -5, 5)

this.move(vec2(this.horSpeed*100, this.vertSpeed*100))

this.flipX = this.horSpeed < 0
}
}
}
  • ❤ 2
More from @namlessmoth
  1. Mar 7, 2026Как сломать босса одним прокачанным навыком Причём первую заратану я победил точно так же,…
  2. Mar 3, 2026Наиграл уже 150+ часов и даже не прошел половину игры Мне капец как не везёт почти в каждо…
  3. Feb 17, 2026Один месяц подписки на впн Вдруг кому надо https://t.me/gruVPNbot?start=g_UZhunlWNfFC_2127…
  4. Feb 16, 2026оставлю тут, чтобы не потерять вам смотреть нельзя, это только для меня
  5. Feb 13, 2026Вчера сделал всего три задания и все три оказались не правильными 1) Задание: Проведите ре…
  6. Feb 12, 2026Оказалось что всё-таки можно сдавать несколько заданий за один раз. Я вчера сдал 7 заданий…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →