diff --git a/src/Q3.java b/src/Q3.java new file mode 100644 index 0000000000000000000000000000000000000000..9db0cbde33fa6354dd816f9c14491d5706e66fda --- /dev/null +++ b/src/Q3.java @@ -0,0 +1,34 @@ +import bagel.*; +import bagel.util.Point; + +/** + * Xulin Yang, 904904 + * + * @create 2021-03-31 22:48 + * description: + **/ + +public class Q3 extends AbstractGame { + // (a) When the game starts, the player should be rendered to the screen at the position: (200, 350), + //and the ball should be rendered at position: (650, 180). You can use the Point class to define + //the position. + // - The player image is located at res/player.png, and the ball image is located at res/ball.png. + + private static final String PLAYER_IMAGE = "res/player.png"; + private static final String BALL_IMAGE = "res/ball.png"; + private static final Point PLAYER_POSITION = new Point(200, 350); + private static final Point BALL_POSITION = new Point(650, 180); + + private final Image playerImage = new Image(PLAYER_IMAGE); + private final Image ballImage = new Image(BALL_IMAGE); + + public static void main(String[] args) { + new Q3().run(); + } + + @Override + protected void update(Input input) { + playerImage.draw(PLAYER_POSITION.x, PLAYER_POSITION.y); + ballImage.draw(BALL_POSITION.x, BALL_POSITION.y); + } +}