Slick Forums

Discuss the Slick 2D Library
It is currently Sun May 19, 2013 7:42 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Strange collision issue
PostPosted: Wed Jun 20, 2012 4:54 pm 
Offline

Joined: Wed Jun 20, 2012 4:42 pm
Posts: 6
Ive recently started learning java and have been playing with slick and have been enjoying it quite a bit. Its so simple! lol. I followed a tutorial for and Entity and Component based game. I had created a component called RadialCollision that moves a Entity somewhere else when the object gets in range of another to test if the collision was working. And it works... once. I cannot explain why this is. Ive been working on it for days and I simply cannot understand why it only works once! The logic looks pretty solid and Ive gone over the other components to see if maybe they where interfering but have had no luck at all. Its driving me bonkers >_< lol. Can any of the gurus lurking around here maybe peek at my source and help me figure out where I went wrong? Any help for this budding developer would be greatly appreciated:).

The tutorial I initially followed: http://slick.cokeandcode.com/wiki/doku.php?id=entity_tutorial

My full source: https://dl.dropbox.com/u/9159394/test_game.zip


Top
 Profile  
 
PostPosted: Wed Jun 20, 2012 5:50 pm 
Offline
Regular
User avatar

Joined: Thu May 05, 2011 8:35 pm
Posts: 231
Location: Somewhere between the bits and bytes
In the RadialCollision class you replace the owner's Vector2f with another instance of Vector2f upon collision.
That works fine at first because effect_location has the desired values [0,0], but whenever you collide after that, your are assigning effect_location as the owner's location Vector2f object again.

Replace
Code:
   owner.setPosition(effect_location);

with this
Code:
   owner.getPosition().set(effect_location);

Doing that will set the values in the owners location Vector2f to the values in effect_location, rather than replacing it.

_________________
For every new problem, a new source of solutions has come to exist.


Top
 Profile  
 
PostPosted: Wed Jun 20, 2012 5:57 pm 
Offline

Joined: Wed Jun 20, 2012 4:42 pm
Posts: 6
Thanks allot! Lesson learned:). I would have never cought that.


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 3 guests


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