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

2014/4/18

can't find mover class (support classes)

greenprogrammer greenprogrammer

2014/4/18

#
Hello, I have seen in one of the tutorials use of mover class and I want to use it but I can't find it in greenfoot website. Can you please help me how I can find it. However, what is the difference between greenfoot API and support classes. I think it's same. API = classes with methods. support classes = same as API but a particular class, isn't it?
danpost danpost

2014/4/18

#
There is a single line of text at the bottom of the Documentation page. You will find the link there.
greenprogrammer greenprogrammer

2014/4/19

#
hi, thank you for taking your time and replying to my question, it was helpful. However, I am trying to make a ice hockey game. The goal keeper moves up when the player moves up, and the goal keeper moves down when the player moves down, without leaving the goal post. The player should slide from fast to slow as well, when I take off my hands from control. Will you please tell me step by step how I can do this? thanks
greenprogrammer greenprogrammer

2014/4/20

#
Hello, can anyone please give me a solution, how I make an object slide from fast to slow?
danpost danpost

2014/4/20

#
You will have to a bit more specific as to what you want. 'slide' could be interpreted in many ways. 'fast to slow' is not specific enough. You need to include what makes it go fast to begin with, when or what triggers it to slow down, and whether it will slow down to a stop or not -- anything that will be needed to come upon a solution that will fit your needs.
greenprogrammer greenprogrammer

2014/4/21

#
On the ice hockey arena I control a player through keyboard. When I take off my fingers from control player starts to loose speed and eventually stop, like in real life when you are on the ice hockey arena.atworldedge it doesn't get stuck. Same thing I need to do with puck, it gets hit by player. Kindly tell how I implement these.
greenprogrammer greenprogrammer

2014/4/21

#
About puck what I meant is, when it gets hit by player and no one hit it again it starts to loose speed and stop. Atworldedge it doesn't get stuck also.thanks
danpost danpost

2014/4/21

#
You will probably have to either use 'double' type values for the speed (like the 'SmoothMover' class implements) or use larger values for the speed (like 10 or 100 times) and only move by its value divided by the factor 10 or 100. With the second way, you can just subtract 1 from its value each act cycle (if it is not already zero) for slowing down. Adjusting the factor adjusts the rate of deceleration (the higher the factor, the slower the deceleration).
greenprogrammer greenprogrammer

2014/4/22

#
Hello, thank you very much. Furthermore, left and right is working but how do I do the same with up and down? Will you please write down in codes for up and down. public class player extends Actor { private int speed = 0; public final int topWall = 134; public final int bottomWall = 407; public final int leftWall = 109; public final int rightWall = 717; public void act() { move(speed/100); //We divide by 100 because the numbers are too big (otherwise we would lose speed to quickly because the move method only accepts integers) loseSpeed(); checkKeys(); } private void checkKeys(){ if (Greenfoot.isKeyDown("right")){ speed=speed+10; } if (Greenfoot.isKeyDown("left")) { speed=speed-15; } if (Greenfoot.isKeyDown("up")){ setLocation(getX(), getY()-1); } if (Greenfoot.isKeyDown("down")) { setLocation(getX(), getY()+1); } } private void touchingWall(){ if(getY()<topWall){ //setRotation(-getRotation()); } if(getY()>bottomWall){ //setRotation(-getRotation()); } if(getX()<leftWall){ } if(getX()>rightWall){ } } private void loseSpeed() { if(speed>0) speed=speed-2; if(speed<0) speed=speed+2; } }
danpost danpost

2014/4/22

#
The main problem is that you have a 'speed' value which you are using for left and right; but, you do not have any value for the speed up and down. You should change the name of 'speed' to 'xSpeed' and add a 'ySpeed' for the y direction of movement.
greenprogrammer greenprogrammer

2014/4/23

#
Thank you for your reply, very kind of you. I'll try this.
greenprogrammer greenprogrammer

2014/4/25

#
why there is no video tutorials on Vector and SmoothMover, when this is an important topic. Everyone talking about easy stuff. I am not being rude just frustrated.
You need to login to post a reply.