diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..f419dc7baab4bcced83228343644b0f97730afad --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.idea +/target diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..72f9ebac53f844cf4f986552389699468c08cbd5 --- /dev/null +++ b/pom.xml @@ -0,0 +1,36 @@ +<?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> + <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.2</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/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..a053d58568b86447004209c32fd918e898beee9c --- /dev/null +++ b/src/BagelTest.java @@ -0,0 +1,55 @@ +import bagel.*; + +/** + * An example Bagel game. + * + * @author Eleanor McMurtry + */ +public class BagelTest extends AbstractGame { + private Image smiley; + private Image bagel; + private float x = 100; + private float 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) { + float speed = 0.5f; + 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, Window.getHeight() / 2); + smiley.draw(x, y); + } +}