# Collision detection with entities/AI

I'm making my first game in Java, a top down 2D RPG. I've handled basic collision detection, rendering and have added an NPC, but I'm stuck on how to handle interaction between the player and the NPC.

Currently I'm drawing out my level and then drawing characters, NPCs and animated tiles on top of this. The problem is keeping track of the NPCs so that my Character class can interact with methods in the NPC classes on collision.

I'm not sure my method of drawing the level and drawing everything else on top is a good one - can anyone shed any light on this topic?

• That's typically how drawing is done - in layers. Jun 29 '13 at 16:37
• Okay thanks, I'm new to game development and although it might seem obvious to an experienced game dev some things just puzzle me! Jun 29 '13 at 16:50

for(Enemy enemy : enemiesArray) {