Skip to content

Commit 02a04c3

Browse files
committed
Example Game: Bankrupt Dash
1 parent 1d1d02c commit 02a04c3

71 files changed

Lines changed: 1555 additions & 1 deletion

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.txt
2+
target
3+
dev
4+
game.jar
5+
wip_*/
6+
.settings
7+
.classpath
8+
.project
9+
.vscode

games/bankrupt-dash/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.txt
2+
*.xcf
3+
*.ods
4+
target
5+
dev
6+
game.jar
7+
high.scr
3.76 MB
Binary file not shown.

games/bankrupt-dash/lib/jaylib.jar

2.55 MB
Binary file not shown.

games/bankrupt-dash/package.bat

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
del kodenkel-bankrupt-dash.jar
4+
5+
mvn clean package
6+
7+
copy target/kodenkel-bankrupt-dash.jar kodenkel-bankrupt-dash.jar
8+
java -jar kodenkel-bankrupt-dash.jar

games/bankrupt-dash/package.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
rm -f kodenkel-bankrupt-dash.jar
4+
5+
mvn clean package
6+
7+
cp target/kodenkel-bankrupt-dash.jar kodenkel-bankrupt-dash.jar
8+
chmod +x kodenkel-bankrupt-dash.jar
9+
java -jar kodenkel-bankrupt-dash.jar

games/bankrupt-dash/pom.xml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<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">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.kodenkel.game</groupId>
4+
<artifactId>bankrupt-dash</artifactId>
5+
<version>1</version>
6+
<packaging>jar</packaging>
7+
<name>kodenkel bankrupt dash</name>
8+
9+
<properties>
10+
<maven.compiler.source>1.8</maven.compiler.source>
11+
<maven.compiler.target>1.8</maven.compiler.target>
12+
</properties>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>com.raylib</groupId>
17+
<artifactId>Jaylib</artifactId>
18+
<version>1.0.0</version>
19+
<scope>system</scope>
20+
<systemPath>${project.basedir}/lib/jaylib.jar</systemPath>
21+
</dependency>
22+
23+
<dependency>
24+
<groupId>com.raylib</groupId>
25+
<artifactId>Raylib</artifactId>
26+
<version>1.0.0</version>
27+
<scope>system</scope>
28+
<systemPath>${project.basedir}/lib/jaylib.jar</systemPath>
29+
</dependency>
30+
</dependencies>
31+
32+
<build>
33+
<finalName>kodenkel-bankrupt-dash</finalName>
34+
<resources>
35+
<resource>
36+
<directory>${project.basedir}</directory>
37+
<includes>
38+
<include>lib/*.jar</include>
39+
<include>src/main/resources/*.png</include>
40+
<include>src/main/resources/*.wav</include>
41+
</includes>
42+
</resource>
43+
</resources>
44+
45+
<plugins>
46+
<plugin>
47+
<groupId>org.apache.maven.plugins</groupId>
48+
<artifactId>maven-shade-plugin</artifactId>
49+
<version>3.2.4</version>
50+
51+
<configuration>
52+
<createDependencyReducedPom>false</createDependencyReducedPom>
53+
</configuration>
54+
55+
<executions>
56+
<execution>
57+
<phase>package</phase>
58+
<goals>
59+
<goal>shade</goal>
60+
</goals>
61+
<configuration>
62+
<artifactSet>
63+
<excludes>
64+
<exclude>junit:junit</exclude>
65+
</excludes>
66+
</artifactSet>
67+
<transformers>
68+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
69+
<manifestEntries>
70+
<Main-Class>com.kodenkel.game.Application</Main-Class>
71+
<Class-Path>. ./lib/jaylib.jar</Class-Path>
72+
</manifestEntries>
73+
</transformer>
74+
</transformers>
75+
</configuration>
76+
</execution>
77+
</executions>
78+
79+
</plugin>
80+
</plugins>
81+
</build>
82+
</project>

games/bankrupt-dash/readme.jpg

152 KB
Loading

games/bankrupt-dash/readme.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Example Game: Bankrupt Dash
2+
3+
This is a Boulder Dash like game.
4+
5+
You are a green alien on the verge of bankruptcy, so you began mining for diamonds throughout the galaxy.
6+
7+
Explore what lies deep inside the crust of 5 different planets. Beware of the red alien beasts.
8+
9+
Press F2 in-game to see the detailed rules.
10+
11+
![Preview](readme.jpg)
12+
13+
## Pre-requisites
14+
15+
- Java 1.8
16+
- Maven 3.6
17+
18+
or newer
19+
20+
Help on my blog: <a href="https://www.kodenkel.com/how-to/java-jdk-maven-installation-windows" target="_blank">How To Install the Java JDK and Maven on Windows</a>
21+
22+
Debian/Ubuntu
23+
24+
````
25+
sudo apt-get install default-jdk maven
26+
````
27+
28+
## Package and Test
29+
30+
On Linux simply run the "package.sh" script.
31+
32+
On Windows simply run the "package.bat" script (untested).
33+
34+
The resulting jar will be executable and include all dependencies (so called "fat-jar").
35+
36+
To run the built jar manually:
37+
38+
````
39+
java -jar kodenkel-scorched.jar
40+
````
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.kodenkel.game;
2+
3+
import com.raylib.Raylib;
4+
import static com.raylib.Jaylib.*;
5+
6+
import java.util.ArrayList;
7+
8+
import com.kodenkel.game.screen.*;
9+
10+
public class Application {
11+
private static final int WINDOW_WIDTH = 640;
12+
private static final int WINDOW_HEIGHT = 480;
13+
private static final int LOCKED_FPS = 60;
14+
private static final String JAR_PATH = System.getProperty("user.dir") + "/src/main/resources/";
15+
public static final ResourceLoader RESOURCE_LOADER = new ResourceLoader(JAR_PATH);
16+
17+
private static GameState STATE;
18+
private static GameData DATA;
19+
private static ArrayList<BaseScreen> SCREENS;
20+
21+
public static void main(String args[]) throws Exception {
22+
InitWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Bankrupt Dash - kodenkel.com");
23+
SetTargetFPS(LOCKED_FPS);
24+
25+
STATE = GameState.BOOT;
26+
DATA = new GameData();
27+
SCREENS = new ArrayList<BaseScreen>();
28+
SCREENS.add(new TitleScreen(RESOURCE_LOADER));
29+
SCREENS.add(new RulesScreen(RESOURCE_LOADER));
30+
SCREENS.add(new MissionScreen(RESOURCE_LOADER));
31+
SCREENS.add(new MapScreen(RESOURCE_LOADER));
32+
SCREENS.add(new ScoreScreen(RESOURCE_LOADER));
33+
34+
while (!WindowShouldClose()) {
35+
BeginDrawing();
36+
37+
for (BaseScreen manager : SCREENS) {
38+
if (manager.respondsTo(STATE, DATA)) manager.tick(STATE, DATA);
39+
}
40+
SCREENS.get(0).tickCommon(STATE, DATA);
41+
42+
EndDrawing();
43+
}
44+
45+
RESOURCE_LOADER.free();
46+
Raylib.CloseWindow();
47+
}
48+
49+
public static void changeState(GameState newGameState) {
50+
for (BaseScreen manager : SCREENS) {
51+
if (manager.respondsTo(STATE, DATA) && !manager.respondsTo(newGameState, DATA)) {
52+
manager.onLeave(DATA);
53+
}
54+
if (!manager.respondsTo(STATE, DATA) && manager.respondsTo(newGameState, DATA)) {
55+
manager.onEnter(DATA);
56+
}
57+
}
58+
STATE = newGameState;
59+
}
60+
61+
public static boolean isGameState(GameState state) {
62+
return STATE.equals(state);
63+
}
64+
}

0 commit comments

Comments
 (0)