<commit_before>import pyglet
from Entity import *
from pyglet.window import key
WIDTH = 800
HEIGHT = 400
window = pyglet.window.Window(WIDTH, HEIGHT)
#Keys holds a handler that keeps track of keyboard state, part of pyglet
keys = pyglet.window.key.KeyStateHandler()
window.push_handlers(keys)

entities = []

player = Player(Vect2(x=window.width/2, y=window.height/2))
entities.append(player)

test_asteroid = Asteroid()
test_asteroid.vel = Vect2(5,5)
entities.append(test_asteroid)

for e in entities:
    pyglet.clock.schedule(e.update)

@window.event
def on_draw():
    window.clear()
    #map keys to input object
    #On a proper engine the controller would probably be its own class.
    controller = {'acc': keys[key.W], 'left': keys[key.A], 'right':keys[key.D], 'fire':keys[key.SPACE]}
    player.input(controller)
    batch = pyglet.graphics.Batch()
    #TODO: Bullet spawning
    if player.isFiring():
        bullet = Bullet(player.pos.getCopy(), player.angle)
        pyglet.clock.schedule(bullet.update)
        entities.append(bullet)
    #TODO: Score
    #TODO: Asteroids
    for e in entities:
        batch.add(*e.draw())
    #TODO: Lives
    #TODO: Batch graphics
    for e in entities:
        if not e.isAlive():
            entities.remove(e)
            del e
    batch.draw()

pyglet.app.run()<commit_msg>Improved entity removal loop<commit_after>import pyglet
from Entity import *
from pyglet.window import key
WIDTH = 800
HEIGHT = 400
window = pyglet.window.Window(WIDTH, HEIGHT)
#Keys holds a handler that keeps track of keyboard state, part of pyglet
keys = pyglet.window.key.KeyStateHandler()
window.push_handlers(keys)

entities = []

player = Player(Vect2(x=window.width/2, y=window.height/2))
entities.append(player)

test_asteroid = Asteroid()
test_asteroid.vel = Vect2(5,5)
entities.append(test_asteroid)

for e in entities:
    pyglet.clock.schedule(e.update)

@window.event
def on_draw():
    window.clear()
    #map keys to input object
    #On a proper engine the controller would probably be its own class.
    controller = {'acc': keys[key.W], 'left': keys[key.A], 'right':keys[key.D], 'fire':keys[key.SPACE]}
    player.input(controller)
    batch = pyglet.graphics.Batch()
    if player.isFiring():
        bullet = Bullet(player.pos.getCopy(), player.angle)
        pyglet.clock.schedule(bullet.update)
        entities.append(bullet)
    #TODO: Score
    #TODO: Asteroids
    for e in entities:
        batch.add(*e.draw())
    #TODO: Lives
    for e in entities:
        if not e.isAlive():
            pyglet.clock.unschedule(e.update)
    entities[:] = [e for e in entities if e.isAlive()]
    batch.draw()

pyglet.app.run()
{'fraction_non_alphanumeric': 0.12397003745318352, 'fraction_numerical': 0.008988764044943821, 'mean_word_length': 3.4815436241610738, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2304113', 'n_tokens_mistral': 913, 'n_tokens_neox': 903, 'n_words': 230}