Add second year

This commit is contained in:
2023-12-07 01:19:12 +00:00
parent 3291e5c79e
commit 3d12031ab8
1168 changed files with 431409 additions and 0 deletions

View File

@ -0,0 +1,31 @@
import java.awt.*;
import javax.swing.*;
public class Alien extends Sprite2D {
private int stepSize = 2;
public Alien(Image image) {
super(image);
}
// method to randomly move the alien
public void move(boolean right) {
// changing the x & y co-ordinates (inherited from superclass) by either plus or minus the stepSize, depending on the direction
if (right) {
x += stepSize;
}
else {
x -= stepSize;
}
}
// method to move aliend down
public void moveDown() {
y += 10;
}
// getter method for the alien's x coordinate
public int getx() {
return x;
}
}