I got the basic, by editing the mover class (but i use
movingThing :D )
public void pmove(double distance)
{
double angle = Math.toRadians( getRotation() );
int x = (int) Math.round(getX() + Math.cos(angle) * distance);
int y = (int) Math.round(getY() + Math.sin(angle) * distance);
List p = getWorld().getObjectsAt(x, y, Wall.class);
Iterator i = p.iterator();
while(i.hasNext())
{
while(i.hasNext()) <<< i want to loop by decreasing the
speed, but no work :(
{
angle = Math.toRadians( getRotation() );
x = (int) Math.round(getX() + Math.cos(angle) *
(distance - w) );
y = (int) Math.round(getY() + Math.sin(angle) *
(distance - w) );
w++;
break;
}
}
if(!i.hasNext())
{
w=0;
setLocation(x, y);
}
}
That code will check if there is a wall.class at the target position,
if there, i want to decrease the speed, so it will be smoother but it
did not work.
I want to create more smooth movement, like if the object is at world
edge.
help me pleasee ^_^
Creating one while loop inside another isn't the way to go about
decreasing the speed smoothly - if it did decrease it noticeably at
all, then all it'd do was make the game run more jerkily!
Personally, I wouldn't edit the mover class at all to do this, I'd
create a subclass and put all your code there. If I've understood you
correctly, then you just want something to slow down before it hits
something else? Just because it's christmas (almost), here's a demo
with source. Have a look at it and you should be able to work out what
it's doing :)
On Wed, Dec 24, 2008 at 7:02 PM, mjrb4 <berry...@gmail.com> wrote:
> Creating one while loop inside another isn't the way to go about
> decreasing the speed smoothly - if it did decrease it noticeably at
> all, then all it'd do was make the game run more jerkily!
> Personally, I wouldn't edit the mover class at all to do this, I'd
> create a subclass and put all your code there. If I've understood you
> correctly, then you just want something to slow down before it hits
> something else? Just because it's christmas (almost), here's a demo
> with source. Have a look at it and you should be able to work out what
> it's doing :)
Sorry, I'm still not entirely sure what you mean - do you want the car
to turn gradually when it comes close to a wall then head off in
another direction?
On Thu, Dec 25, 2008 at 7:21 PM, mjrb4 <berry...@gmail.com> wrote:
> Sorry, I'm still not entirely sure what you mean - do you want the car
> to turn gradually when it comes close to a wall then head off in
> another direction?
On Thu, Dec 25, 2008 at 9:36 PM, Keenan Mandela <dus...@gmail.com> wrote:
> no problem !!! :-)
> hmm, nope, i want the car stop ! :D, stop like at the world edge.
> stop, for i while, i handle if car, get collision with other object,
> turn(-180); so its move back.
> but i want to.. like at the world edge ^_^
> On Thu, Dec 25, 2008 at 7:21 PM, mjrb4 <berry...@gmail.com> wrote:
>> Sorry, I'm still not entirely sure what you mean - do you want the car
>> to turn gradually when it comes close to a wall then head off in
>> another direction?
On Thu, Dec 25, 2008 at 8:39 AM, Keenan Mandela <dus...@gmail.com> wrote:
> i think i will put all the source
> ...
> i think again i will upload it to the gallery ^_^"
> On Thu, Dec 25, 2008 at 9:36 PM, Keenan Mandela <dus...@gmail.com> wrote:
>> no problem !!! :-)
>> hmm, nope, i want the car stop ! :D, stop like at the world edge.
>> stop, for i while, i handle if car, get collision with other object,
>> turn(-180); so its move back.
>> but i want to.. like at the world edge ^_^
>> On Thu, Dec 25, 2008 at 7:21 PM, mjrb4 <berry...@gmail.com> wrote:
>>> Sorry, I'm still not entirely sure what you mean - do you want the car
>>> to turn gradually when it comes close to a wall then head off in
>>> another direction?
On Thu, Dec 25, 2008 at 11:02 PM, Mike H. <motormichae...@gmail.com> wrote:
> make it check if its intersecting the wall object and if it is then turn it
> On Thu, Dec 25, 2008 at 8:39 AM, Keenan Mandela <dus...@gmail.com> wrote:
>> i think i will put all the source
>> ...
>> i think again i will upload it to the gallery ^_^"
>> On Thu, Dec 25, 2008 at 9:36 PM, Keenan Mandela <dus...@gmail.com> wrote:
>>> no problem !!! :-)
>>> hmm, nope, i want the car stop ! :D, stop like at the world edge.
>>> stop, for i while, i handle if car, get collision with other object,
>>> turn(-180); so its move back.
>>> but i want to.. like at the world edge ^_^
>>> On Thu, Dec 25, 2008 at 7:21 PM, mjrb4 <berry...@gmail.com> wrote:
>>>> Sorry, I'm still not entirely sure what you mean - do you want the car
>>>> to turn gradually when it comes close to a wall then head off in
>>>> another direction?
yes, but if you slowly turn (press up too), then the apple just 'jumping'
compare it with if the apple go to world edge
if you go to world edge, the apple stop. but if you turn slowly, the apple
move slowly.