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

2021/1/6

Smooth Movement upwards

GLOBALHUNT GLOBALHUNT

2021/1/6

#
So guys just wanted to ask could we move an object upwards in a smooth way other than just teleporting? This is my code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public void act()
    {
       if (isTouching(MAN.class))
       {
           setImage("lift-closed.png");
           Greenfoot.delay (1);
           setLocation(getX(), getY()-300);
       }
       if (isTouching(TRIGGER4.class))
       {
          setImage("lift-open.png");
          getWorld().addObject(new MAN2(),698,246);
       }   
        if (isTouching(TRIGGER3.class))
       {
           setImage("lift-closed.png");
            
       }
        
    }
GLOBALHUNT GLOBALHUNT

2021/1/6

#

Pls answer fast gotto do a activity and submit very soon

Roshan123 Roshan123

2021/1/6

#
Use move(int) and turn(int)
GLOBALHUNT GLOBALHUNT

2021/1/6

#
Roshan123 wrote...
Use move(int) and turn(int)
Hey u r the one who even chatted with TheFeared_king's programme right
GLOBALHUNT GLOBALHUNT

2021/1/6

#
Roshan123 wrote...
Use move(int) and turn(int)
Thnx btw
GLOBALHUNT GLOBALHUNT

2021/1/6

#
Can u rewrite the code and send
danpost danpost

2021/1/6

#
Add fields to Lift class for maxY, minY and movement direction. Adjust direction field as needed by what it touches. Usage of direction field: 1: moving down 0: stopped -1: moving up Use the following to move:
1
setLocation(getX(), getY()+direction);
BASIC FORMAT: If not moving, check for "triggers". Else move and check for max/min y values, and if then at max/min y, stop lift (set direction to 0). To start lift moving, set direction dependent on which of min or max value the lift is currently at. (do not use delay in your code, here)
Roshan123 Roshan123

2021/1/7

#
GLOBALHUNT wrote...
Hey u r the one who even chatted with TheFeared_king's programme right
I don't remember. Is their anything wrong???
GLOBALHUNT wrote...
Thnx btw
Welcome!!!
Roshan123 Roshan123

2021/1/7

#
GLOBALHUNT wrote...
Can u rewrite the code and send
1
2
move(-3);
turn(90);
But i would like u to recommend to use Danpost's code(its better) and not mine.
You need to login to post a reply.