The Daily Click ::. Forums ::. Klik Coding Help ::. Help with a rogue-like, if that interests you.
 

Post Reply  Post Oekaki 
 

Posted By Message

Nate Baker



Registered
  19/07/2010
Points
  12
24th March, 2014 at 24/03/2014 16:42:23 -

Hi all, I was hoping someone would take a look at this and tell me what I'm missing. What I am tinkering with is grid based movement using the path finding object for a turn based rogue-like style game, and my problem is the collision detection in the monster's AI code near the bottom. The problem is that I haven't found a reliable way to prevent my monsters (green "monster" squares) from walking in to the player( blue "player" square") and each other. The code below is my latest attempt and for some reason it's not working very well. It will detect collision between the player and monster and sometimes prevent them occupying the same space but if the player walks towards the monsters then they will overlap. The code also never seams to detect collision between other monsters and they always overlap.

My question is two parts then, first is this a decent method for doing what I'm trying to do or does some one else have a suggestion. Second why is collision not being detected between monsters. I need to know this regardless of the method I'm using because I think I'm missing something about how collision detection works.

Thanks for you time.

The file:
https://onedrive.live.com/redir?resid=69EAC52E90EB0BF9%211501

Image
Image
Image

 
n/a

Nate Baker



Registered
  19/07/2010
Points
  12
25th March, 2014 at 25/03/2014 16:16:36 -

Alright I was kind of asking you to do my home work for me so never mind all that. But answer me this; if I move active object A in a frame can active object B detect collision with A in the same frame or do I have to wait until the engine draws the frame before I can detect collision. Because after lots of experimenting that's the way it seams and I just need that confirmed so that I can get on with my life. In short after some trial and error I got the monster to stop stepping on top the player but only after I moved it out of my step group which only runs after I get new input from the player because this is a turn based game. So anyway it works but I just wanted to know if I should be able to do it inside a group of events that only run every few frames.

Thanks for looking

 
n/a

nim



Registered
  17/05/2002
Points
  7234
25th March, 2014 at 25/03/2014 22:25:53 -


Originally Posted by Nate Baker
if I move active object A in a frame can active object B detect collision with A in the same frame or do I have to wait until the engine draws the frame before I can detect collision.



MMF doesn't need to draw the frame to check for collisions. You can move an object, check for collisions then move it back with the whole process being invisible to the player.

 
//

Pan-tosser



Registered
  24/10/2008
Points
  520

Has Donated, Thank You!
26th March, 2014 at 26/03/2014 02:17:09 -

I like what you got going on here. Looks well planned out. I think you are using the loop index the right way.

The only thing i would caution about here is to test and make sure your string for your ai modes is doing what you think it is. I found sometimes with duplicate objects. Just checking a string of a duplicate can get confusing. A common mistake i often happens to me. Is i end up with conditions that trigger if any of my duplicates have an ai mode that equals what i'm testing for. Which is bad if the current object being tested doesn't have a matching ai mode.

Most of the time to fix that. I end up pulling the objects fixed value. Instead of spreading a value in id.




 
https://www.facebook.com/nathon.brown.7
   

Post Reply



 



Advertisement

Worth A Click