summaryrefslogtreecommitdiff
path: root/2026/games_submissions/just__jane/src/cut.cpp
blob: 67e4c25fde6ed587d62f6840a3d8bd6dd0af7fdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "raylib.h"
#include "raymath.h"
#include <cut.hpp>

Cut::Cut(Vector2 start, Vector2 end) {
  InitAudioDevice();
  this->start_ = start;
  this->end_ = end;
  this->current_step_ = 0.0;
  this->slash_ = LoadSound("assets/slash.wav");
}

void Cut::Draw() {
  if (this->its_joever) {
    return;
  }

  Vector2 head = Vector2Lerp(start_, end_, current_step_);
  DrawLineV(start_, head, {0x0F, 0x0F, 0x0F, 0x40});
}

void Cut::Update() {
  if (this->its_joever) {
    return;
  }

  if (this->current_step_ == 0.0) {
    PlaySound(slash_);
  }

  if (this->current_step_ >= 1.0) {
    this->its_joever = true;
    return;
  }

  this->current_step_ += (1.0 / 60.0);
}