<commit_before>import constants as CONSTS
from pyglet.graphics import *
import pyglet
import math
import utils
import random
import resources


class Layer(pyglet.graphics.Batch):

    def __init__(self, *args, **kwargs):
        super(Layer, self).__init__(**kwargs)
        self.x = 0
        self.y = 0
        self.z = 0


class Camera(object):

    def __init__(self, win, x=0, y=0, z=0, zoom=1.0):
        self.win = win
        self.zoom = zoom
        self.x, self.y, self.z = x, y, z

        self._offset = [0, 0]
        self._track = type('obj', (object,), {'x': 0, 'y': 0})
        self._radius = 0
        self._shake_dec = 0  # how much the shake dies down every update
        self.a = 0

    def update(self, dt):
        if self._radius > 0:
            self._radius *= self._shake_dec
            self._angle += 180 if random.randint(0, 1) == 0 else 60
            self._offset = [
                math.sin(self._angle) * self._radius, math.cos(self._angle) * self._radius]
            if math.floor(self._radius) == 0.0:
                self._radius = 0

        self.x = (
            self._track.x + self._offset[1]) / float(CONSTS.win_width / 2)
        self.y = (
            self._track.y + self._offset[0]) / float(CONSTS.win_height / 2)

    def track(self, track):
        self._track = track

    def shake(self, r, dec=0.9):
        self._radius = r
        self._shake_dec = dec
        self._angle = random.randint(0, 360)
        self._offset = [
            math.sin(self._angle) * self._radius, math.cos(self._angle) * self._radius]

    def star_projection(self):
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        x = (self._track.x + self._offset[1]) / float(CONSTS.win_width / 3)
        y = (self._track.y + self._offset[0]) / float(CONSTS.win_height / 3)
        glTranslatef(x, y, self.z)
        gluOrtho2D(
            0, self.win.width,
            0, self.win.height)

    def game_projection(self):
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        glTranslatef(self.x, self.y, self.z)
        gluOrtho2D(
            0, self.win.width,
            0, self.win.height)

    def hud_project(self):
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        gluOrtho2D(
            0, self.win.width,
            0, self.win.height)

    def hud_projection(self):
        """
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        # glTranslatef(self.x, self.y, self.z)
        gluOrtho2D(
            0, self.win.width,
            0, self.win.height)
        """

        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        gluPerspective(
            40.0, CONSTS.game_width / float(CONSTS.game_height), 0.1, 2000.0)
        glTranslatef(0, 0, -800)
        ang = min(15, (1 - float(self.ax) / (CONSTS.game_width / 2)) * 30)
        # print ang
        if ang >= 0:
            glRotatef(ang, 0, CONSTS.game_height / 2, 0)
        glTranslatef(-400, -300, 0)
        glMatrixMode(GL_MODELVIEW)


class ParticleSystem():<commit_msg>fixes hud projection aspect ratio<commit_after>import constants as CONSTS
from pyglet.graphics import *
import pyglet
import math
import utils
import random
import resources


class Layer(pyglet.graphics.Batch):

    def __init__(self, *args, **kwargs):
        super(Layer, self).__init__(**kwargs)
        self.x = 0
        self.y = 0
        self.z = 0


class Camera(object):

    def __init__(self, win, x=0, y=0, z=0, zoom=1.0):
        self.win = win
        self.zoom = zoom
        self.x, self.y, self.z = x, y, z

        self._offset = [0, 0]
        self._track = type('obj', (object,), {'x': 0, 'y': 0})
        self._radius = 0
        self._shake_dec = 0  # how much the shake dies down every update
        self.a = 0

    def update(self, dt):
        if self._radius > 0:
            self._radius *= self._shake_dec
            self._angle += 180 if random.randint(0, 1) == 0 else 60
            self._offset = [
                math.sin(self._angle) * self._radius, math.cos(self._angle) * self._radius]
            if math.floor(self._radius) == 0.0:
                self._radius = 0

        self.x = (
            self._track.x + self._offset[1]) / float(CONSTS.win_width / 2)
        self.y = (
            self._track.y + self._offset[0]) / float(CONSTS.win_height / 2)

    def track(self, track):
        self._track = track

    def shake(self, r, dec=0.9):
        self._radius = r
        self._shake_dec = dec
        self._angle = random.randint(0, 360)
        self._offset = [
            math.sin(self._angle) * self._radius, math.cos(self._angle) * self._radius]

    def star_projection(self):
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        x = (self._track.x + self._offset[1]) / float(CONSTS.win_width / 3)
        y = (self._track.y + self._offset[0]) / float(CONSTS.win_height / 3)
        glTranslatef(x, y, self.z)
        gluOrtho2D(
            0, self.win.width,
            0, self.win.height)

    def game_projection(self):
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        glTranslatef(self.x, self.y, self.z)
        gluOrtho2D(
            0, self.win.width,
            0, self.win.height)

    def hud_project(self):
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        gluOrtho2D(
            0, self.win.width,
            0, self.win.height)

    def hud_projection(self):
        """
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        # glTranslatef(self.x, self.y, self.z)
        gluOrtho2D(
            0, self.win.width,
            0, self.win.height)
        """

        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        gluPerspective(
            40.0, CONSTS.win_width / float(CONSTS.win_height), 0.1, 2000.0)
        glTranslatef(0, 0, -800)
        ang = min(15, (1 - float(self.ax) / (CONSTS.win_width / 2)) * 30)
        # print ang
        if ang >= 0:
            glRotatef(ang, 0, CONSTS.win_height / 2, 0)
        glTranslatef(-400, -300, 0)
        glMatrixMode(GL_MODELVIEW)


class ParticleSystem():
{'fraction_non_alphanumeric': 0.12659470068694798, 'fraction_numerical': 0.027805037618580306, 'mean_word_length': 1.8588125292192614, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7509811', 'n_tokens_mistral': 2207, 'n_tokens_neox': 2060, 'n_words': 443}