Skip to content

Commit 8152134

Browse files
committed
update to FastJ 1.7.0-SNAPSHOT-1
- change to jlink plugin, use module-info - improve jpackage speed by disabling installer generation - bump gradle version to 7.5.1 - bump slf4j to 2.0.0-alpha7 - improve example game - format readme - update license
1 parent f25c45b commit 8152134

File tree

6 files changed

+79
-56
lines changed

6 files changed

+79
-56
lines changed

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Andrew Dey
3+
Copyright (c) 2022 Andrew Dey
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+23-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# FastJ Kotlin Template Program
22

33
## Requirements
4-
- [Java 11 JDK or Higher][jdk-link]
5-
- Basic understanding of Kotlin
64

5+
- [Java 18 JDK or Higher][jdk-link]
6+
- Basic understanding of Java (and Kotlin)
77

88
## Initial Setup
99

1010
### Download the Template
11+
1112
You have a few options for getting the template:
1213

13-
#### Create from Template
14-
1. Click the "Use This Template" button at the top of this project. Leave everything on the project creation screen as is, and hit "Create repository from template".
14+
#### Create from Template - Recommended for Beginners
15+
16+
1. Click the "Use This Template" button at the top of this project. Leave everything on the project creation screen as
17+
is, and hit "Create repository from template".
1518
![image](https://user-images.githubusercontent.com/64715411/125542737-6eb23326-d07a-4a28-89af-dcacb4f01cac.png)
1619
![image](https://user-images.githubusercontent.com/64715411/125543010-b960404a-ad40-431c-ab31-c097f52574bb.png)
1720

@@ -21,13 +24,15 @@ You have a few options for getting the template:
2124
![image](https://user-images.githubusercontent.com/64715411/125545310-c62610da-1eb5-4e80-86b3-352b1ea16612.png)
2225

2326
#### Clone the template directly
24-
1. Clone the repository via terminal: `git clone https://github.com/lucasstarsz/fastj-kotlin-template`
27+
28+
1. Clone the repository via terminal: `git clone https://github.com/lucasstarsz/fastj-java-template`
2529

2630
#### Downloading the latest release
27-
Download the archive (.zip file, or tar.gz file) from https://github.com/lucasstarsz/fastj-kotlin-template/releases/latest
2831

32+
Download the archive (.zip file, or tar.gz file) from https://github.com/lucasstarsz/fastj-java-template/releases/latest
2933

3034
### Running the Program
35+
3136
1. Build the program:
3237
```bash
3338
./gradlew build
@@ -37,10 +42,10 @@ Download the archive (.zip file, or tar.gz file) from https://github.com/lucasst
3742
./gradlew run
3843
```
3944

40-
4145
## General Usage
4246

4347
### Generating Installer/Executable
48+
4449
1. Build the program:
4550
```bash
4651
./gradlew build
@@ -53,18 +58,23 @@ Download the archive (.zip file, or tar.gz file) from https://github.com/lucasst
5358

5459
_Having trouble using `gradlew`? Read [this][Terminals Are Different]._
5560

56-
5761
## Learning FastJ
62+
5863
Check out the following links to learn how to use FastJ:
64+
5965
- [Example Programs][example-programs-readme-link]
6066
- [FastJ Documentation][documentation-link]
6167

62-
6368
## Configuring the Project Variables
64-
Please view the [build.gradle](build.gradle.kts) file -- it contains general instructions for modifying the base example.
69+
70+
Please view the [build.gradle](build.gradle.kts) file -- it contains general instructions for modifying the base
71+
example.
6572

6673

67-
[jdk-link]: https://adoptium.net/?variant=openjdk17 "Java JDK Download"
74+
[jdk-link]: https://adoptium.net/temurin/releases?version=18 "Java JDK Download"
75+
6876
[Terminals Are Different]: https://gist.github.com/lucasstarsz/9bbc306f8655b916367d557043e498ad "Terminals Access Files Differently"
69-
[example-programs-readme-link]: http://fastj.me/tree/main/src/example "FastJ Examples"
70-
[documentation-link]: https://javadoc.io/doc/io.github.lucasstarsz.fastj/fastj-library "FastJ API Documentation"
77+
78+
[example-programs-readme-link]: https://github.com/fastjengine/FastJ/tree/1.7.0-SNAPSHOT-1/examples "FastJ Examples"
79+
80+
[documentation-link]: https://javadoc.io/doc/io.github.lucasstarsz.fastj/fastj-library/1.7.0-SNAPSHOT-1 "FastJ API Documentation"

build.gradle.kts

+42-35
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@
66

77
plugins {
88
/* To begin with, Gradle needs the "kotlin" plugin so that it knows this is a Kotlin project. */
9-
kotlin("jvm") version "1.6.21"
9+
kotlin("jvm") version "1.7.10"
1010
/* This template is for an application -- we"ll need this plugin to make sure Gradle knows
1111
* this, too. */
1212
application
13-
/* To create distributable files for your game, we use this runtime plugin. */
14-
id("org.beryx.runtime") version "1.12.7"
13+
/* To create distributable files for your game, we use this jlink plugin. */
14+
id("org.beryx.jlink") version "2.25.0"
1515
}
1616

17+
val compileKotlin: org.jetbrains.kotlin.gradle.tasks.KotlinCompile by tasks
18+
val compileJava: JavaCompile by tasks
19+
compileJava.destinationDirectory.set(compileKotlin.destinationDirectory.get())
20+
1721
/* Your project's group name goes here.
1822
* This should be a domain name you own.
1923
* If you don't own a domain, don"t worry! You can always set this to "io.github.yourgithubusername". */
@@ -31,6 +35,7 @@ description = "A Kotlin Template for FastJ."
3135

3236
/* Here, we specify where the main entrypoint of the project.
3337
* Feel free to change this as needed. */
38+
application.mainModule.set("fastj.templategame")
3439
application.mainClass.set("tech.fastj.template.GameKt")
3540

3641

@@ -43,9 +48,9 @@ repositories.maven {
4348
repositories.mavenCentral()
4449

4550
/* The dependency for FastJ, the game engine this template depends on. */
46-
dependencies.implementation("com.github.fastjengine:FastJ:1.6.0")
51+
dependencies.implementation("io.github.lucasstarsz.fastj:fastj-library:1.7.0-SNAPSHOT-1")
4752
/* We'll stick with the simplest logging option for now -- you can change it however you need. */
48-
dependencies.implementation("org.slf4j:slf4j-simple:2.0.0-alpha5")
53+
dependencies.implementation("org.slf4j:slf4j-simple:2.0.0-alpha7")
4954

5055
/* To make Kotlin compile and run properly with Gradle, this adds your Kotlin code to the Java
5156
* source sets. */
@@ -56,7 +61,7 @@ sourceSets.main {
5661

5762
/* The Runtime plugin is used to configure the executables and other distributions for your
5863
* project. */
59-
runtime {
64+
jlink {
6065

6166
options.addAll(
6267
"--strip-debug",
@@ -66,47 +71,49 @@ runtime {
6671
)
6772

6873
launcher {
74+
name = project.name
6975
noConsole = true
7076
}
7177

7278
jpackage {
79+
7380
/* Use this to define the path of the icons for your project. */
7481
val iconPath = "project-resources/fastj_icon"
7582
val currentOs = org.gradle.internal.os.OperatingSystem.current()
7683

77-
7884
when {
79-
currentOs.isWindows -> {
80-
installerType = "msi"
81-
imageOptions = listOf("--icon", "${iconPath}.ico")
82-
installerOptions = listOf(
83-
"--description", project.description as String,
84-
"--vendor", project.group as String,
85-
"--app-version", project.version as String,
86-
"--win-per-user-install",
87-
"--win-dir-chooser",
88-
"--win-shortcut",
89-
)
90-
}
91-
currentOs.isLinux -> {
92-
installerType = "deb"
93-
imageOptions = listOf("--icon", "${iconPath}.png")
94-
installerOptions = listOf(
95-
"--description", project.description as String,
96-
"--vendor", project.group as String,
97-
"--app-version", project.version as String,
98-
"--linux-shortcut",
99-
)
100-
}
101-
currentOs.isMacOsX -> {
102-
installerType = "pkg"
103-
imageOptions = listOf("--icon", "${iconPath}.icns")
104-
installerOptions = listOf(
85+
currentOs.isWindows -> imageOptions = listOf("--icon", "${iconPath}.ico")
86+
currentOs.isLinux -> imageOptions = listOf("--icon", "${iconPath}.png")
87+
currentOs.isMacOsX -> imageOptions = listOf("--icon", "${iconPath}.icns")
88+
}
89+
90+
/* Comment the line below to create an installer for your application */
91+
skipInstaller = true
92+
93+
if (!skipInstaller) {
94+
installerOptions.addAll(
95+
listOf(
10596
"--description", project.description as String,
10697
"--vendor", project.group as String,
107-
"--app-version", project.version as String,
108-
"--mac-package-name", project.name
98+
"--app-version", project.version as String
10999
)
100+
)
101+
102+
when {
103+
currentOs.isWindows -> {
104+
installerType = "msi"
105+
installerOptions.addAll(listOf("--win-per-user-install", "--win-dir-chooser", "--win-shortcut"))
106+
}
107+
108+
currentOs.isLinux -> {
109+
installerType = "deb"
110+
installerOptions.addAll(listOf("--linux-shortcut"))
111+
}
112+
113+
currentOs.isMacOsX -> {
114+
installerType = "pkg"
115+
installerOptions.addAll(listOf("--mac-package-name", project.name))
116+
}
110117
}
111118
}
112119
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/module-info.java

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module fastj.templategame {
2+
requires kotlin.stdlib;
3+
requires fastj.library;
4+
5+
exports tech.fastj.template;
6+
}

src/main/kotlin/tech/fastj/template/Game.kt

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ class Game : SimpleManager() {
1616
/* Some crispy anti-aliasing for the road. */
1717
canvas.modifyRenderSettings(RenderSettings.Antialiasing.Enable)
1818

19-
/* A very simple Text2D object, welcoming you to FastJ! */
20-
val helloFastJText = Text2D.fromText("Hello, FastJ 1.6.0!")
21-
helloFastJText.translate(canvas.canvasCenter)
22-
drawableManager.addGameObject(helloFastJText)
23-
}
19+
val helloFastJ: Text2D = Text2D.fromText("Hello, FastJ 1.7.0-SNAPSHOT-1!")
20+
21+
/* Translate our hello text to the center of the screen */
22+
helloFastJ.translation = canvas.canvasCenter.subtract((helloFastJ.width() / 2f), (helloFastJ.height() / 2f))
2423

25-
override fun update(canvas: FastJCanvas?) {
24+
/* Render hello fastj text */
25+
drawableManager().addGameObject(helloFastJ)
2626
}
2727
}
2828

0 commit comments

Comments
 (0)