From 50a93be7da94def0e5be8af496e8e735a78f05ee Mon Sep 17 00:00:00 2001
From: Chaowen Zeng <chaowenz@student.unimelb.edu.au>
Date: Fri, 23 Apr 2021 14:29:44 +1000
Subject: [PATCH] Add new file

---
 code for project-1 | 116 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 116 insertions(+)
 create mode 100644 code for project-1

diff --git a/code for project-1 b/code for project-1
new file mode 100644
index 0000000..15d887e
--- /dev/null
+++ b/code for project-1	
@@ -0,0 +1,116 @@
+import bagel.*;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.text.DecimalFormat;
+
+
+/**
+ * An example Bagel game.
+ */
+public class ShadowTreasure extends AbstractGame {
+
+    // for rounding double number; use this to print the location of the player
+    private static DecimalFormat df = new DecimalFormat("0.00");
+
+    public static void printInfo(double x, double y, int e) {
+        System.out.println(df.format(x) + "," + df.format(y) + "," + e);
+    }
+    
+    public ShadowTreasure() throws IOException {
+        this.loadEnvironment("res/IO/environment.csv");
+        // Add code to initialize other attributes as needed
+        private final Image PlayerImage = new Image("res/images/player.png");
+        private final Image BackgroundImage = new Image("res/images/background.png");
+        private final Image ZoombieImage = new Image("res/images/Zombie.png");
+        private final Image SandwichImage = new Image("res/images/Sandwich.png");
+        private final Font font = new Font("DejaVuSans-Bold.ttf", 20);
+
+
+        private static final double STEP_SIZE = 10;
+        private static final double Meet_DISTANCE = 50;
+        private static final Point Zoombie_POINT = new Point(300, 200);
+        private static final Point Sandwich_POINT = new Point(500, 400);
+        private static final double SCORE_DISTANCE = 20;
+        private double playerX = 650;
+        private double playerY = 100;
+        private double player_Energy = 2;
+
+    }
+
+    /**
+     * Load from input file
+     */
+    private void loadEnvironment(String filename){
+        // Code here to read from the file and set up the environment
+        try (BufferedReader br =
+                     new BufferedReader(new FileReader("res/environment.csv.\n"))) {
+
+            
+
+            while ((text = br.readLine()) != null) {
+                <block of code to execute >
+            }
+        }
+    }
+
+    /**
+     * Performs a state update.
+     */
+    @Override
+    public void update(Input input) {
+        // Logic to update the game, as per specification must go here
+        if (input.isDown(Keys.LEFT)) {
+            playerX -= STEP_SIZE;
+        }
+        if (input.isDown(Keys.RIGHT)) {
+            playerX += STEP_SIZE;
+        }
+        if (input.isDown(Keys.UP)) {
+            playerY -= STEP_SIZE;
+        }
+        if (input.isDown(Keys.DOWN)) {
+            playerY += STEP_SIZE;
+        }
+
+        if (new Point(playerX, playerY).distanceTo(Zoombie_POINT) <= Meet_DISTANCE) {
+            player_Energy -= 3;
+            font.drawString(playerX, playerY, player_Energy);
+            break;
+        }
+        if (new Point(playerX, playerY).distanceTo(Sandwich_POINT) <= Meet_DISTANCE) {
+            player_Energy += 5;
+            font.drawString(playerX, playerY, player_Energy);
+            break;
+        }
+        if (play_Energy >= 3){
+            int X = Math.pow(Zoombie_POINT.x - playerX, 2);
+            int Y = Math.pow(Zoombie_POINT.y - playerY, 2);
+            X += STEP_SIZE;
+            Y += STEP_SIZE;
+
+        }
+        if (play_Energy < 3){
+            int X = Math.pow(Sandwich_POINT.x - playerX, 2);
+            int Y = Math.pow(Sandwich_POINT.y - playerY, 2);
+            X += STEP_SIZE;
+            Y += STEP_SIZE;
+
+        }
+
+
+        ZoombieImage.draw(Zoombie_POINT.x, Zoombie_POINT.y);
+        PlayerImage.draw(playerX, playerY);
+        SandwichImage.draw(Sandwich_POINT.x, Sandwich_POINT.y);
+
+
+
+    /**
+     * The entry point for the program.
+     */
+    public static void main(String[] args) throws IOException {
+        ShadowTreasure game = new ShadowTreasure();
+        game.run();
+    }
+}
\ No newline at end of file
-- 
GitLab