This site requires JavaScript, please enable it in your browser!
Greenfoot back
myheartwillgoon
myheartwillgoon wrote ...

2012/11/25

HI

myheartwillgoon myheartwillgoon

2012/11/25

#
ALL FRIENDS WHAT'S UP?
danpost danpost

2012/11/25

#
Hey friend, you might want to delete all the older version of your scenario (all but the latest one). You really do not need 5 different version up, all at different stages of development. Just log on, open the scenarios you want to delete and click on 'delete scenario'.
myheartwillgoon myheartwillgoon

2012/11/25

#
And of course I am gonna do that!
myheartwillgoon myheartwillgoon

2012/11/25

#
Hi danpost I have a little discussion again. In my previous scenerio, I had some obstacles in the world and those worked as same as wall ( or world edge) so that the snake can die by hiting the obstacles. But, in my later scenerios ( in the latest version I uploaded), I removed the obstacles in order to make my game simple and easy to handle. Okay, before I ask my question, see the coad of the "eat" method of my "Snake" class: private void eat() { Actor food=getOneObjectAtOffset(0,0,Food.class); if (food!=null){ SnakeEarth snakeEarth=(SnakeEarth)getWorld(); //snakeEarth.addArray(); snakeEarth.removeObject(food); if(length<11) { snakeEarth.addArray(); snakeEarth.snake = new Snake(); snakeEarth.addObject(snakeEarth.snake, getX(), getY()); length++; } Well, now, I am confused about the line . The reason of being confused about the line is that the snake will look for the food at offset because the food can't be placed inside the obstacles. So, according to my previous scenerio, the food could be placed any random location in the world except at the locations where the obstacles exist (or located). So,(1). should I change the "addOneObjectAtOffset" method and use some other codes instead of that? (2). Or, there is no problem with running the code? (3) I am wondering if it's any logical error. (4) May be I am not clear with the getOneObjectAtOffset" term still now.
danpost danpost

2012/11/25

#
Being 'getOneObjectAtOffset' returns one object (if any) whose image intersects the point in question, your actor could end up partially overlapping the food and not detect it. Better would be to use the 'getOneIntersectingObject' method (unless, of course, you want to make it much more difficult to 'eat' the food -- cutting the 'hit-zone' in half). At any rate, when food is being placed, you should use the 'getOneIntersectingObject' method; otherwise it may be very difficult (or impossible) for the actor to find the food without hitting the obstacle.
You need to login to post a reply.