Slick Forums

Discuss the Slick 2D Library
It is currently Mon May 20, 2013 5:46 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue May 01, 2012 4:45 pm 
Offline

Joined: Wed Apr 25, 2012 2:26 pm
Posts: 13
Here are 2 ways I can think of for handling each section but I'm not sure what would be the most efficient and easiest to work into my game

Firstly handling collisions

Quote:
Idea 1:
The same way it's done in the tutorial on the wiki, where you have a block class that holds a rectangle then iterate through all those blocks

Idea 2:
Translate the players position into world coords then depending on which key is pressed check the adjacent tile on the collision layer in the .tmx file returning true or false?
(this would require a lot less code and GUESSING would be less intensive as it wouldnt have to iterate through a loop every update call)


Next handling npcs

Quote:
Idea 1:
Draw the (static) npcs in the Tiled map on a new layer and make those tiles non-passable

Idea 2:
Set the npcs on an object layer and iterate through them when checking for collisions


Top
 Profile  
 
PostPosted: Thu May 03, 2012 5:27 pm 
Offline
Oldbie
User avatar

Joined: Thu Jan 13, 2011 4:42 pm
Posts: 349
If you're working with a set of sprites that will, at all times, be bound to a tiled map, then the second method for collision detection is perfectly acceptable, and combined with the first method for npc handling, might be fairly easy to implement. However, the choice is yours: neither of these choices goes against good practice from what I can tell. If you are a glutton for overkill, you could use Box2D, and it would still get the job done correctly.

_________________
"Artificial intelligence will never be a match for human stupidity" - "Jamos Kennedynos"


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group