<commit_before>import Canvas from "./canvas"
import Sprite from "./sprite"

class Enemy extends Sprite {
    public static readonly points = 1

    public w = 40
    public h = 40

    protected readonly fill = "#a44"
    protected readonly speed = 3

    // put this somewhere directly outside the Canvas
    public constructor() {
        // first, put it directly outside the canvas
        super(0, 0)
        this.x -= this.w
        this.y -= this.h

        // then, decide from which side...
        const r1 = Math.random()
        // ...and where on the chosen side it will come
        const r2 = Math.random()

        const total = 2 * (Canvas.w + Canvas.h)
        const a = Canvas.h / total
        const b = a + Canvas.w / total
        const c = a + b
        if (r1 < a) {
            // left
            this.y += r2 * Canvas.h
        } else if (r1 < b) {
            // top
            this.x += r2 * Canvas.w
        } else if (r1 < c) {
            // right
            this.x = Canvas.w
            this.y = r2 * Canvas.h
        } else {
            // bottom
            this.x = r2 * Canvas.w
            this.y = Canvas.h
        }
    }

    // move this in the direction towards s
    public moveTowards(s: Sprite): void {
        this.i = s.x - this.x + (s.w - this.w) / 2
        this.j = s.y - this.y + (s.h - this.h) / 2
        this.move()
    }
}

export default Enemy<commit_msg>change some variable names<commit_after>import Canvas from "./canvas"
import Sprite from "./sprite"

class Enemy extends Sprite {
    public static readonly points = 1

    public w = 40
    public h = 40

    protected readonly fill = "#a44"
    protected readonly speed = 3

    // put this somewhere directly outside the Canvas
    public constructor() {
        // first, put it directly outside the canvas
        super(0, 0)
        this.x -= this.w
        this.y -= this.h

        // then, decide from which side...
        const r1 = Math.random()
        // ...and where on the chosen side it will come
        const r2 = Math.random()

        const total = 2 * (Canvas.w + Canvas.h)
        const lt = Canvas.h / total
        const up = lt + Canvas.w / total
        const rt = lt + up
        if (r1 < lt) {
            this.y += r2 * Canvas.h
        } else if (r1 < up) {
            this.x += r2 * Canvas.w
        } else if (r1 < rt) {
            this.x = Canvas.w
            this.y = r2 * Canvas.h
        } else {
            this.x = r2 * Canvas.w
            this.y = Canvas.h
        }
    }

    // move this in the direction towards s
    public moveTowards(s: Sprite): void {
        this.i = s.x - this.x + (s.w - this.w) / 2
        this.j = s.y - this.y + (s.h - this.h) / 2
        this.move()
    }
}

export default Enemy
{'fraction_non_alphanumeric': 0.11255411255411256, 'fraction_numerical': 0.015873015873015872, 'mean_word_length': 1.3620102214650767, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5157312', 'n_tokens_mistral': 908, 'n_tokens_neox': 869, 'n_words': 298}