@Override
	public void run() {
		while(running){
			float onStart = System.currentTimeMillis();
			if(player.meleeCounter==0){
				player.meleeReady = true;
			}else if(player.meleeCounter > 0){
				player.meleeCounter--;
			}
			
			collisionDetect();
			theEnemies = new CopyOnWriteArrayList<Enemy>(enemylist);
			for(Enemy e : theEnemies){

				e.move();
				if(!e.canAttack){
					e.countToNextAttack--;
				}
				if(e.countToNextAttack ==0){
					e.canAttack=true;
				}
				if(e.energy <= 0){
					e.isDead =true;
					e.speed=0;
					enemylist.remove(e);
					corpses.add(e);
					Item i = new Item(window,e.posX,e.posY, (int)Math.random()*1 + 4);
					window.activeLevel.thisLevelsItems.add(i);
					panel.actionMessages.add(new ActionMessage(panel,"Enemy killed"));
				}
			}
			float onEnd = System.currentTimeMillis()-onStart;
			if(gamespeed > onEnd){
				try {
					Thread.sleep(gamespeed -(int)onEnd);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	}