Hold only one object at a time
You want to limit the number of items the player can have on him? Add these few lines in the pick function of the item class, in the item.js script. The player will then systematically drop the object he already has on the ground to be able to pick up a new one.
this.pick = function(){ // player's interaction with items if (this.type==0) winGame(); else { if(onHand.length>0) { append(items, new item (playerPos[1].x, playerPos[1].y, onHand[0].type)); onHand=[]; } append(onHand, this); fx[1].play(); this.supp(); } }