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

2021/5/31

VARIOUS

1
2
3
danpost danpost

2021/6/9

#
Change 50 in line 35 to 100.
ronald ronald

2021/6/9

#
line 15 you mean I forget to add mousemoved to move rocket but it does not move it remains blocked The distance is always equal to zero I have a problem of x1.getx (), x2.getx () ...
ronald ronald

2021/6/9

#
ok i erased mouseclicked because it blocks with mouseMoved it's always equal to zero but I'm looking for
ronald ronald

2021/6/9

#
I have a question The distance is calculated with respect to the point X = 0, y = 0? I just realize I thought to calculate between two points in clicking anywhere by moving the mouse, I'm wrong, Is this feasible?
danpost danpost

2021/6/9

#
ronald wrote...
The distance is calculated with respect to the point X = 0, y = 0?
Then all you need is:
double distance = Math.hypot(x1, y1);
ronald ronald

2021/6/10

#
hi I am looking for the mathematical formula of a projectile or rocket moving shot in vertical There are so many on Google that I do not know how to choose Thank you for your help
danpost danpost

2021/6/10

#
If moving in a straight line, no mathematical formula is needed.
ronald ronald

2021/6/11

#
yes I'm stupid I found a code on a cannon of Ubay Dillah but the missile flies straight in vertical What interests me, it is to see the missile fly vertically and not right in vertically I do not know if you understand me
danpost danpost

2021/6/11

#
In a straight line, but angled? like Missile Command?
ronald ronald

2021/6/11

#
you tilt Rocket and pull a missile that points its nose following the trajectory vertically and not standing With a round shot, you do not see but a missile starting in vertical, you see it, the missile follows the standing trajectory
danpost danpost

2021/6/11

#
So, like:
Actor missile = new Missile();
getWorld().addObject(missile, getX(), getY());
missile.setRotation(getRotation());
ronald ronald

2021/6/11

#
ok it's this code that I had seen at the forum thank you it works I put your code next to Ubay and removes the missile rotation and The missiles point their noses well by following the trajectory thanks again
ronald ronald

2021/6/19

#
hi I click on the Run button and the 1st Background Scroll up by following the duration of the music by making way at the 2nd Background how to do ? thank you
danpost danpost

2021/6/22

#
ronald wrote...
I click on the Run button and the 1st Background Scroll up by following the duration of the music by making way at the 2nd Background how to do ?
In Background01 class: (1) Making and retaining a reference to the music will allow you to check its playing state, eliminating the need for system time elapse checking. (2) bgBase is redundant with bgImage and can be removed. (3) With scrollPosition as an int, scrollSpeed might as well be an int. (4) no need for static content here. Try this:
import greenfoot.*;

public class Background01 extends World
{
    private int scrollSpeed = 2;
    private int picHeight;
    private GreenfootImage bgImage;
    private int scrollPosition;
    GreenfootSound bgMusic;
    
    public Background01()
    {    
        super(900, 600, 1);
        bgImage = new GreenfootImage(getBackground());
        picHeight = bgImage.getHeight();
        Greenfoot.start();
        bgMusic = new GreenfootSound("Star Wars.mp3"); 
        bgMusic.play();
    }
    
    public void act()
    {        
        scrollPosition -= scrollSpeed;
        while(scrollSpeed > 0 && scrollPosition < -picHeight) scrollPosition += picHeight;
        while(scrollSpeed < 0 && scrollPosition > 0) scrollPosition -= picHeight;
        paint(scrollPosition);       
        if (!bgMusic.isPlaying()) Greenfoot.setWorld(new Background02());
    }
    
    private void paint(int position)
    {
        GreenfootImage bg = getBackground();
        bg.drawImage(bgImage, 0, position);
        bg.drawImage(bgImage, 0, position + picHeight);
    }
}
ronald ronald

2021/6/22

#
thank you
You need to login to post a reply.
1
2
3