-2

コードのどこでキャラクターを右側にバウンドさせ、カウントさせないのか、よくわかりません。

    public void exercise1e() {
    PaintWindow pw = new PaintWindow();
    Random rand = new Random();
    ImageIcon image = new ImageIcon("C:/Users/char.jpg");
    int width = pw.getBackgroundWidth();
    int height = pw.getBackgroundHeight();
    int dx = -2;
    int dy = 0;
    int x = 250;
    int y = rand.nextInt(height-100);

    while(true) {
        pw.showImage(image, x, y);
        PaintWindow.pause(20);
        x += dx;
        y += dy;
        if(x<0) {
            dx = -dx;
            if (x>0) {
        }
    }
}
}
4

1 に答える 1