diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..f63bc049776ab3ec747d02ffe7c5fade3059026d --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/target +/.idea +*.iml + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..19edbafc627e4d560897199b353fac6ad0463909 --- /dev/null +++ b/pom.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>au.edu.unimelb.cis</groupId> + <artifactId>bagel</artifactId> + <version>0.1-SNAPSHOT</version> + <packaging>jar</packaging> + + <build> + <sourceDirectory>src/</sourceDirectory> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>11</source> + <target>11</target> + </configuration> + </plugin> + </plugins> + </build> + + <properties> + <maven.compiler.source>11</maven.compiler.source> + <maven.compiler.target>11</maven.compiler.target> + </properties> + + <dependencies> + <dependency> + <groupId>io.github.eleanor-em</groupId> + <artifactId>bagel</artifactId> + <version>1.9.3</version> + </dependency> + </dependencies> +</project> diff --git a/res/bagel.png b/res/bagel.png new file mode 100644 index 0000000000000000000000000000000000000000..13ad6a70d5ca358b77e98680daa5034fff5c3120 Binary files /dev/null and b/res/bagel.png differ diff --git a/res/ball.png b/res/ball.png new file mode 100644 index 0000000000000000000000000000000000000000..3a695bca9a0c3b2243a698236128e8e5961737ea Binary files /dev/null and b/res/ball.png differ diff --git a/res/conformable.otf b/res/conformable.otf new file mode 100644 index 0000000000000000000000000000000000000000..52cf623d896c065914bd1b06c0462919b54f6ff3 Binary files /dev/null and b/res/conformable.otf differ diff --git a/res/house.png b/res/house.png new file mode 100644 index 0000000000000000000000000000000000000000..0bb978132c6d6c4bfed143a72f2011ae014cd293 Binary files /dev/null and b/res/house.png differ diff --git a/res/player.png b/res/player.png new file mode 100644 index 0000000000000000000000000000000000000000..103a2ff1c64ccd5bf18b9ef8b2ca444dbdf204d1 Binary files /dev/null and b/res/player.png differ diff --git a/res/smiley.png b/res/smiley.png new file mode 100644 index 0000000000000000000000000000000000000000..2a0810422a1e894cd405bd2982f9260cc42a9a6f Binary files /dev/null and b/res/smiley.png differ diff --git a/src/BagelTest.java b/src/BagelTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cc306fb7f0c7f871eb7dce2458687920a12e5bc0 --- /dev/null +++ b/src/BagelTest.java @@ -0,0 +1,59 @@ +import bagel.*; + +import java.util.Random; + +/** + * An example Bagel game. + * + * @author Eleanor McMurtry + */ +public class BagelTest extends AbstractGame { + private Image smiley; + private Image bagel; + private double x = 100; + private double y = 100; + + public BagelTest() { + super(800, 600, "Hello World"); + bagel = new Image("res/bagel.png"); + smiley = new Image("res/smiley.png"); + } + + /** + * The entry point for the program. + */ + public static void main(String[] args) { + BagelTest game = new BagelTest(); + game.run(); + } + + /** + * Performs a state update. This simple example shows an image that can be controlled with the arrow keys, and + * allows the game to exit when the escape key is pressed. + */ + @Override + public void update(Input input) { + double speed = 0.5; + + if (input.isDown(Keys.LEFT)) { + x -= speed; + } + if (input.isDown(Keys.RIGHT)) { + x += speed; + } + if (input.isDown(Keys.UP)) { + y -= speed; + } + if (input.isDown(Keys.DOWN)) { + y += speed; + } + + if (input.wasPressed(Keys.ESCAPE)) { + Window.close(); + } + + + bagel.draw(Window.getWidth() / 2.0, Window.getHeight() / 2.0); + smiley.draw(x, y); + } +}