Skip to content
Snippets Groups Projects
Commit 31c3d3ec authored by Eleanor McMurtry's avatar Eleanor McMurtry
Browse files

bagel test

parent df4f6ef1
No related branches found
No related tags found
No related merge requests found
/.idea
/target
pom.xml 0 → 100644
<?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>
res/bagel.png

659 KiB

res/smiley.png

5.95 KiB

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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment