Skip to content
Snippets Groups Projects
Commit 9f188d28 authored by yangxvlin's avatar yangxvlin
Browse files

initial commit

parent c2bf0f87
No related branches found
No related tags found
No related merge requests found
/target
/.idea
*.iml
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>
<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>
res/bagel.png

659 KiB

res/ball.png

2.07 KiB

File added
res/house.png

8.49 KiB

res/player.png

2.61 KiB

res/smiley.png

5.95 KiB

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