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

2012/10/15

Problem

1
2
3
BradH BradH

2012/10/17

#
any luck?
danpost danpost

2012/10/18

#
The main problem is that your world has a cell size greater than 1. The Mover class was created for a pixel-cell-sized world. Adjusting the constants to compensate for your cell size in the 'atWorldEdge' method in the Mover class (and maybe also the comparison operators) should do the trick.
BradH BradH

2012/10/18

#
I will give it a try, thanks
BradH BradH

2012/10/18

#
/** * Test if we are close to one of the edges of the world. Return true is we are. */ public boolean atWorldEdge() { if(getX() < 20|| getX() > getWorld().getWidth() - 20) return true; if(getY() < 20|| getY() > getWorld().getHeight() - 20) return true; else return false; } } if this is the atWorldMove method in my Mover class would i change the 20's to a larger #?
BradH BradH

2012/10/18

#
I think you are right because I have a few more at world methods for some alien ships and they are supposed to turn when they reach the world's edge but the just turn right away even if they are in the middle of the world they just turn
danpost danpost

2012/10/18

#
Now, now! Think about it (use some logic). Do you want the action to occur 20 grid-cells from the edge? more than 20? how about 1?!?
public boolean atWorldEdge()
{
    if (getX() == 1 || getX() == getWorld().getWidth() - 1) return true;
    if (getY() == 1 || getY() == getWorld().getHeight() - 1) return true;
    return false;
}
As a side note: the reason 20 was being used in the Mover class originally was to compensate for a portion of the size of the object that was approaching the edge (in pixel-cell-sized worlds, up to half the image could be hidden outside the edge of the screen before the center of the object reaches the edge of the world). This effect is being compensated for by the size of your grid-cells.
Game/maniac Game/maniac

2012/10/18

#
you got to it before me I had the same idea and was just about to post it
danpost danpost

2012/10/18

#
Well, that change did not stop what the GumLoader shoots from not reaching the edge of the world.
BradH wrote...
the projectile is going about 4x farther than it did before it leaves the gun but it disappears in the middle of the world
The problem here is that the projectile is not a LongShot projectile, but a Gum projectile which has a life-span shorter than what it takes to reach the edge of the world.
Y0ger Y0ger

2014/7/16

#
Yes it helped :D
You need to login to post a reply.
1
2
3