<commit_before>package slimpleslickgame;

import java.util.ArrayList;
import java.util.Map.Entry;
import java.nio.ByteBuffer;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Input;
import org.newdawn.slick.geom.Shape;
import org.newdawn.slick.geom.Vector2f;

import util.EventProtocol;
import client.ByteMonitor;
import client.MessageWrapper;

public class LocalPlayer extends Player {

	private GameContainer gc;
	private ByteMonitor bm;
	private int time;
	private int creepID;
	private ArrayList<Integer> deadCreeps;

	public LocalPlayer(GameContainer gc, ByteMonitor bm, byte id) {
		this.gc = gc;
		this.bm = bm;
		time = 0;
		creepID = 1;
		super.id = id;
		deadCreeps = new ArrayList<>();
	}

	@Override
	public void init(Vector2f pos) {
		super.init(pos);
		byte[] msg = { EventProtocol.OPPONENT_PLAYER_INIT };
		bm.putArrayToServer(msg, super.id);
	}

	public void update(int delta, Shape containerShape) {
		time++;
		if (processInput(gc.getInput())) {
			if (bm != null) {
				byte[] bytes = MessageWrapper.appendByteArray(
								MessageWrapper.getPlayerPositionBytes(super.position),
								MessageWrapper.getPlayerDirectionBytes(super.direction));
				bm.putArrayToServer(bytes, id);
			}
			super.updatePosition(containerShape);
		}

		if (time % 60 == 0) {
			Vector2f initPos = new Vector2f(super.position.x, 20);
			super.creeps.put(creepID, new Creep(initPos));

			byte[] bytes = MessageWrapper.appendByteArray(
					MessageWrapper.appendByteArray(new byte[]{EventProtocol.CREEP_INIT, EventProtocol.CREEP_ID}, ByteBuffer.allocate(4).putInt(creepID).array()), 
					MessageWrapper.appendByteArray(new byte[]{EventProtocol.CREEP_POS}, MessageWrapper.getVector2fBytes(initPos)));
			
			bm.putArrayToServer(bytes, super.id);
			creepID++;
		}


		for (Creep c : creeps.values()) {
			c.update(delta);
		}
		
		gun.update(delta);
		
		deadCreeps.clear();
		for(Entry<Integer, Creep> c : creeps.entrySet()){
			if(gun.bulletIntersectsCreep(c.getValue().getShape())){
				deadCreeps.add(c.getKey());
			} else if(containerShape.intersects(c.getValue().getShape())){
				deadCreeps.add(c.getKey());
			}
		}
		for(int i : deadCreeps){
			this.delete(i);
			byte[] bytes = MessageWrapper.appendByteArray(new byte[]{EventProtocol.CREEP_DIED, EventProtocol.CREEP_ID}, ByteBuffer.allocate(4).putInt(creepID).array());
			bm.putArrayToServer(bytes, super.id);
		}
	}
	<commit_msg>added explosion sprites<commit_after>package slimpleslickgame;

import java.util.ArrayList;
import java.util.Map.Entry;
import java.nio.ByteBuffer;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Input;
import org.newdawn.slick.geom.Shape;
import org.newdawn.slick.geom.Vector2f;

import util.EventProtocol;
import client.ByteMonitor;
import client.MessageWrapper;

public class LocalPlayer extends Player {

	private GameContainer gc;
	private ByteMonitor bm;
	private int time;
	private int creepID;
	private ArrayList<Integer> deadCreeps;

	public LocalPlayer(GameContainer gc, ByteMonitor bm, byte id) {
		this.gc = gc;
		this.bm = bm;
		time = 0;
		creepID = 1;
		super.id = id;
		deadCreeps = new ArrayList<>();
	}

	@Override
	public void init(Vector2f pos) {
		super.init(pos);
		byte[] msg = { EventProtocol.OPPONENT_PLAYER_INIT };
		bm.putArrayToServer(msg, super.id);
	}

	public void update(int delta, Shape containerShape) {
		time++;
		if (processInput(gc.getInput())) {
			if (bm != null) {
				byte[] bytes = MessageWrapper.appendByteArray(
								MessageWrapper.getPlayerPositionBytes(super.position),
								MessageWrapper.getPlayerDirectionBytes(super.direction));
				bm.putArrayToServer(bytes, id);
			}
			super.updatePosition(containerShape);
		}

		if (time % 60 == 0) {
			Vector2f initPos = new Vector2f(super.position.x, 20);
			super.creeps.put(creepID, new Creep(initPos));

			byte[] bytes = MessageWrapper.appendByteArray(
					MessageWrapper.appendByteArray(new byte[]{EventProtocol.CREEP_INIT, EventProtocol.CREEP_ID}, ByteBuffer.allocate(4).putInt(creepID).array()), 
					MessageWrapper.appendByteArray(new byte[]{EventProtocol.CREEP_POS}, MessageWrapper.getVector2fBytes(initPos)));
			
			bm.putArrayToServer(bytes, super.id);
			creepID++;
		}

		for (Creep c : creeps.values()) {
			c.update(delta);
		}
		
		gun.update(delta);
		
		deadCreeps.clear();
		for(Entry<Integer, Creep> c : creeps.entrySet()){
			if(gun.bulletIntersectsCreep(c.getValue().getShape())){
				deadCreeps.add(c.getKey());
			} else if(containerShape.intersects(c.getValue().getShape())){
				deadCreeps.add(c.getKey());
			}
		}
		for(int i : deadCreeps){
			this.delete(i);
			byte[] bytes = MessageWrapper.appendByteArray(new byte[]{EventProtocol.CREEP_DIED, EventProtocol.CREEP_ID}, ByteBuffer.allocate(4).putInt(creepID).array());
			bm.putArrayToServer(bytes, super.id);
		}
	}
	
{'fraction_non_alphanumeric': 0.13347150259067359, 'fraction_numerical': 0.005803108808290156, 'mean_word_length': 4.598607888631091, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2760267', 'n_tokens_mistral': 1876, 'n_tokens_neox': 1623, 'n_words': 294}