Skip to content

Commit

Permalink
deploy: af891b6
Browse files Browse the repository at this point in the history
  • Loading branch information
meronbrouwer committed Feb 23, 2024
1 parent 3f1dad4 commit 84c9741
Show file tree
Hide file tree
Showing 17 changed files with 345 additions and 343 deletions.
20 changes: 10 additions & 10 deletions dynamic-entities.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,26 +178,26 @@ <h1 class="menu-title">Yaeger Tutorial - Creating Waterworld</h1>
<main>
<h1 id="adding-dynamic-entities"><a class="header" href="#adding-dynamic-entities">Adding Dynamic Entities</a></h1>
<p>Before adding Hanny, lets start by adding her enemy, the evil swordfish. Since
this fish will be based on the image <code>sprites/swordfish.png</code> and he will
this fish will be based on the image <code>sprites/swordfish.png</code> and he will
swim around, we will be using a <code>DynamicSpriteEntity</code>.</p>
<h2 id="add-the-swordfish"><a class="header" href="#add-the-swordfish">Add the <code>Swordfish</code></a></h2>
<p><img src="images/edit.png" alt="Edit" /> Create a new class called <code>Swordfish</code> that
extends <code>DynamicSpriteEntity</code> in package
extends <code>DynamicSpriteEntity</code> in package
<code>com.github.hanyaeger.tutorial.entities</code>. Since the image of the
swordfish is already of the correct size, we don't need to set its size through
the constructor, which can now look like:</p>
<pre><code class="language-java">public Swordfish(Coordinate2D location){
super(&quot;sprites/swordfish.png&quot;, location);
super("sprites/swordfish.png", location);
}
</code></pre>
<p>Notice how we call <code>super(String, Coordinate2D)</code> and pass the <em>url</em> and<br />
<em>location</em> to the constructor of the super class.</p>
<h2 id="animate-the-swordfish"><a class="header" href="#animate-the-swordfish">Animate the <code>Swordfish</code></a></h2>
<p>Since the swordfish is a <code>DynamicSpriteEntity</code>, we can let it move around the
scene. To do this, we will need to set both the <em>direction</em> and <em>speed</em>. The
scene. To do this, we will need to set both the <em>direction</em> and <em>speed</em>. The
<em>direction</em> will be an angle in degrees, where 0 denotes upwards. For
convenience, Yaeger supplies a method to set both values at once. For the
trivial directions (up, left, right and down) Yaeger provides an Enumeration
trivial directions (up, left, right and down) Yaeger provides an Enumeration
called <code>Direction</code>, which can also be passed to the method.</p>
<p><img src="images/edit.png" alt="Edit" /> Add the following method-call to the constructor
of <code>Swordfish</code>, just after the call to <code>super</code>:</p>
Expand All @@ -212,7 +212,7 @@ <h2 id="make-the-swordfish-swim-in-circles"><a class="header" href="#make-the-sw
the scene. That way we can place him to the right of the scene, and make him
reappear and continue his path.</p>
<p>As seen before, adding behaviour is being done by implementing the correct
interface. For this case, Yaeger supplies the interface
interface. For this case, Yaeger supplies the interface
<code>SceneBorderCrossingWatcher</code>.</p>
<p><img src="images/edit.png" alt="Edit" /> Let <code>Swordfish</code> implement the
interface <code>SceneBorderCrossingWatcher</code> and implement the event handler in the
Expand All @@ -224,21 +224,21 @@ <h2 id="make-the-swordfish-swim-in-circles"><a class="header" href="#make-the-sw
</code></pre>
<p><img src="images/play.png" alt="Run" /> Run the game again and see what happens. To also change
the y-coordinate at which the swordfish reappears, you can add the following
method-call:
method-call:
<code>setAnchorLocationY(new Random().nextInt((int) getSceneHeight()- 81));</code>
to the handler.</p>
<h2 id="use-the-build-in-debugger-to-see-what-is-happening"><a class="header" href="#use-the-build-in-debugger-to-see-what-is-happening">Use the build-in debugger to see what is happening</a></h2>
<p>Yaeger contains a simple debugger that displays how much memory is used by the
game and how many Entities are currently part of the game. When a game doesn't
work as expected, you can use this debugger to get some inside information.</p>
<p><img src="images/play.png" alt="Run" /> Run the game with the commandline argument
<code>--showDebug</code>. Setting these options can usually be done from the Run
<p><img src="images/play.png" alt="Run" /> Run the game with the commandline argument
<code>--showDebug</code>. Setting these options can usually be done from the Run
Configuration within your IDE, as explained below.</p>
<p>See if you can relate the stated numbers to what you expect from your game. To
disable the Debugger window, just remove the commandline argument from the Run
Configuration.</p>
<h3 id="setting-commandline-arguments-from-intellij"><a class="header" href="#setting-commandline-arguments-from-intellij">Setting commandline arguments from IntelliJ</a></h3>
<p>When using <a href="https://www.jetbrains.com/idea/">JetBrains IntelliJ</a>, first
<p>When using <a href="https://www.jetbrains.com/idea/">JetBrains IntelliJ</a>, first
select <em>Edit Configurations...</em>:</p>
<p><img src="images/setup/intellij-run-config-edit.png" alt="IntelliJ Run Configuration" /></p>
<p>Add the commandline argument to the correct Run Configuration:</p>
Expand Down
34 changes: 17 additions & 17 deletions first-scene.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ <h1 class="menu-title">Yaeger Tutorial - Creating Waterworld</h1>
<h1 id="creating-the-first-scene"><a class="header" href="#creating-the-first-scene">Creating the first scene</a></h1>
<p>We're going to add the first scene to the game. Yaeger supports two different
types of scenes. A <code>StaticScene</code> and a <code>DynamicScene</code>. A <code>StaticScene</code> will have
no Game World Update (GWU) and should be used for scenes in which nothing
no Game World Update (GWU) and should be used for scenes in which nothing
should move or be animated. A <code>DynamicScene</code> does receive a GWU and should be
used for Game Levels, or scenes that contain animated elements. Since nothing
will have to be animated for the Title scene, it can be a <code>StaticScene</code>.</p>
Expand All @@ -189,25 +189,25 @@ <h2 id="add-the-title-scene"><a class="header" href="#add-the-title-scene">Add t
Implement the required methods, but leave them empty.</p>
<h2 id="set-the-background-image-and-audio"><a class="header" href="#set-the-background-image-and-audio">Set the background image and audio</a></h2>
<p>The method <code>setupScene()</code> should be used for setting the background image and
audio of a scene. For this you can use the methods
audio of a scene. For this you can use the methods
<code>setBackgroundImage(String)</code> and <code>setBackgroundAudio(String)</code>.
Both the image and the audio are provided in the <code>resources/</code> folder. This
folder should be the only place to store your assets. The url is relative to
folder should be the only location to store your assets. The url is relative to
this folder, so the file <code>background1.jpg</code> from the folder <code>backgrounds/</code> should
be accessed through the url <code>backgrounds/background1.jpg</code>. For the background
audio, we will use <code>ocean.mp3</code>.</p>
<p><img src="images/edit.png" alt="Edit" /> Add the following body to the <code>setupScene()</code>.</p>
<pre><code class="language-java">@Override
public void setupScene(){
setBackgroundAudio(&quot;audio/ocean.mp3&quot;);
setBackgroundImage(&quot;backgrounds/background1.jpg&quot;);
setBackgroundAudio("audio/ocean.mp3");
setBackgroundImage("backgrounds/background1.jpg");
}
</code></pre>
<p>At this point you should have a look at the file <code>module-info.java</code>, which is
called the <a href="https://www.oracle.com/nl/corporate/features/understanding-java-9-modules.html">Module Descriptor</a>.
This is a special file that defines (amongst other things) which directories
should be opened up. The <code>resources</code> folder itself is open by default, but
any subdirectory should be added for the resources in those directories to
called the <a href="https://www.oracle.com/nl/corporate/features/understanding-java-9-modules.html">Module Descriptor</a>.
This is a special file that defines (amongst other things) which directories
should be opened up. The <code>resources</code> folder itself is open by default, but
any subdirectory should be added for the resources in those directories to
be available. As you will notice this has already been done:</p>
<pre><code class="language-java">opens audio;
opens backgrounds;
Expand All @@ -217,9 +217,9 @@ <h2 id="set-the-background-image-and-audio"><a class="header" href="#set-the-bac
the game is trying to access a resource that is in a directory that has not been
opened up.</p>
<h2 id="add-the-titlescene-to-the-yaeger-game"><a class="header" href="#add-the-titlescene-to-the-yaeger-game">Add the <code>TitleScene</code> to the Yaeger game</a></h2>
<p>Now that we have created the <code>TitleScene</code>, we should add it to the Game. For
this, we will use the method <code>addScene(int, YaegerScene)</code> from <code>Waterworld. java</code>. This method should be called from <code>setupScenes()</code> and takes two
parameters. The first one identifies the scene, which you can
<p>Now that we have created the <code>TitleScene</code>, we should add it to the Game. For
this, we will use the method <code>addScene(int, YaegerScene)</code> from <code>Waterworld. java</code>. This method should be called from <code>setupScenes()</code> and takes two
parameters. The first one identifies the scene, which you can
use to set the active scene. The second parameter is an instance of the scene.</p>
<p><img src="images/edit.png" alt="Edit" /> So add the following body to the <code>setupScenes()</code>
method:</p>
Expand All @@ -233,8 +233,8 @@ <h2 id="add-the-titlescene-to-the-yaeger-game"><a class="header" href="#add-the-
<h2 id="add-some-text-to-the-titlescene"><a class="header" href="#add-some-text-to-the-titlescene">Add some text to the <code>TitleScene</code></a></h2>
<p>Let's add the title of the game to the <code>TitleScene</code>. All objects you can add to
a scene are called <em>Entities</em>. Of these there are various different types. There
are <em>TextEntities</em> that should be used for displaying text, <em>SpriteEntities</em>
for displaying a Sprite and shape-based Entities, such as a
are <em>TextEntities</em> that should be used for displaying text, <em>SpriteEntities</em>
for displaying a Sprite and shape-based Entities, such as a
<em>RectangleEntity</em>. For all these types there are the Static and
Dynamic version.</p>
<p>A title is typically the static version of a <code>TextEntity</code>. We will use the
Expand All @@ -244,11 +244,11 @@ <h2 id="add-some-text-to-the-titlescene"><a class="header" href="#add-some-text-
public void setupEntities(){
var waterworldText = new TextEntity(
new Coordinate2D(getWidth() / 2, getHeight() / 2),
&quot;Waterworld&quot;
"Waterworld"
);
waterworldText.setAnchorPoint(AnchorPoint.CENTER_CENTER);
waterworldText.setFill(Color.DARKBLUE);
waterworldText.setFont(Font.font(&quot;Roboto&quot;, FontWeight.SEMI_BOLD, 80));
waterworldText.setFont(Font.font("Roboto", FontWeight.SEMI_BOLD, 80));
addEntity(waterworldText);
}
</code></pre>
Expand All @@ -259,7 +259,7 @@ <h2 id="add-some-text-to-the-titlescene"><a class="header" href="#add-some-text-
is the text to be shown. To actually place the center of the <code>TextEntity</code> at the
center of the scene, we use the method <code>setAnchorPoint()</code>. To set the color,
we use <code>setFill()</code>. We set the font to Roboto, through the
method <code>setFont()</code> and lastly we add the <code>TextEntity</code> to the scene, by
method <code>setFont()</code> and lastly we add the <code>TextEntity</code> to the scene, by
calling the method <code>addEntity()</code>.</p>
<p><img src="images/play.png" alt="Run" /> Run the game again. The <code>TitleScene</code> should now contain
the title.</p>
Expand Down
10 changes: 5 additions & 5 deletions further-challenges.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,16 @@ <h1 id="further-challenges"><a class="header" href="#further-challenges">Further
<p>Although this game is playable, still many features are missing.</p>
<h2 id="prevent-hanny-from-crossing-a-piece-of-coral"><a class="header" href="#prevent-hanny-from-crossing-a-piece-of-coral">Prevent Hanny from crossing a piece of coral</a></h2>
<p>Right now, whenever Hanny collides with a piece of coral, her speed is set to 0.
This does slow her down, but doen not prevent her from crossing the piece of
This does slow her down, but doen not prevent her from crossing the piece of
coral.</p>
<p>To make that work, you should not only set the speed to 0, but also reset
Hannies location to exactly next to the piece of coral. Since Hanny can only
<p>To make that work, you should not only set the speed to 0, but also reset
Hannies location to exactly next to the piece of coral. Since Hanny can only
travel horizontally or vertically, you should first figure out her direction and
then set het x- or y-coordinate to the right value.</p>
<h2 id="prevent-hanny-from-respawning-in-the-coral-field"><a class="header" href="#prevent-hanny-from-respawning-in-the-coral-field">Prevent Hanny from respawning in the coral field</a></h2>
<p>Because Hanny will respawn at a random location, she could also respawn on a
<p>Because Hanny will respawn at a random location, she could also respawn 'within' a
piece of coral. Because her speed is always set to 0, whenever she collides with
coral, leaving such a location is cumbersome. Resolve this by limiting the
coral, leaving such a location is cumbersome for the player. Resolve this by limiting the
locations at which Hanny can respawn.</p>

</main>
Expand Down
14 changes: 7 additions & 7 deletions import.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ <h2 id="clone-the-starter-project"><a class="header" href="#clone-the-starter-pr
<a href="https://github.com/han-yaeger/yaeger-tutorial">https://github.com/han-yaeger/yaeger-tutorial</a></p>
<p><img src="images/setup/browser-clone.png" alt="Clone Project" /></p>
<p>The project is a <a href="https://maven.apache.org/">Maven</a> project, which will be
recognized by all modern IDE's. Knowledge of <a href="https://maven.apache.org/">Maven</a>
is therefore not required, but just to paint the full picture: you'll find a
<code>pom.xml</code> file at the root of the project. This file contains the full project
recognized by all modern IDE's. Knowledge of <a href="https://maven.apache.org/">Maven</a>
is therefore not required, but just to paint the full picture: you'll find a
<code>pom.xml</code> file at the root of the project. This file contains the full project
setup, and you will notice the dependency it has on<code>Yaeger</code>.</p>
<h2 id="importing-the-maven-project-into-your-favourite-ide"><a class="header" href="#importing-the-maven-project-into-your-favourite-ide">Importing the Maven project into your favourite IDE</a></h2>
<p>Since all modern IDE's can import a <a href="https://maven.apache.org/">Maven</a> project,
it does not matter which you use. In this tutorial we focus on the two most
popular amongst Java developers:
popular amongst Java developers:
<a href="https://www.jetbrains.com/idea/">JetBrains IntelliJ</a> and
<a href="https://www.eclipse.org/">Eclipse</a>.</p>
<h3 id="importing-the-project-in-intellij"><a class="header" href="#importing-the-project-in-intellij">Importing the project in IntelliJ</a></h3>
Expand All @@ -207,7 +207,7 @@ <h3 id="importing-the-project-in-intellij"><a class="header" href="#importing-th
</li>
<li>
<p>In the <strong>import window</strong>, navigate to the project directory. Notice that this
directory contains a <code>pom.xml</code> file. Select this <code>pom.xml</code> file and press
directory contains a <code>pom.xml</code> file. Select this <code>pom.xml</code> file and press
<em>Open</em>.</p>
</li>
<li>
Expand All @@ -234,8 +234,8 @@ <h3 id="importing-the-project-in-eclipse"><a class="header" href="#importing-the
</li>
</ol>
<h2 id="switch-branch-to-look-at-the-solution"><a class="header" href="#switch-branch-to-look-at-the-solution">Switch branch to look at the solution</a></h2>
<p>Whenever your stuck, you can switch to Branch <em>implementation</em>, to see the full
implementation. For switching branches some knowledge of
<p>Whenever you're stuck, you can switch to the Branch <em>implementation</em>, to see the full
implementation. For switching branches some knowledge of
<a href="https://git-scm.com/">Git</a> is required, so read the <a href="https://git-scm.com/">Git</a>
documentation to figure out how to switch branches.</p>

Expand Down
16 changes: 8 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,22 @@ <h1 class="menu-title">Yaeger Tutorial - Creating Waterworld</h1>
<main>
<h1 id="introduction"><a class="header" href="#introduction">Introduction</a></h1>
<p>In this tutorial you will create a simple game called Waterworld. We will start
with an empty project. Only the assets and the project settings are provided.
Step-by-step you will be guided in the creation of simple game, and in doing
with an empty project. Only the assets and the project settings are provided.
You will be guided Step-by-step in the creation of a simple game, and in doing
so, become familiar with many of the features of Yaeger.</p>
<h2 id="what-we-will-be-building"><a class="header" href="#what-we-will-be-building">What we will be building</a></h2>
<p>When this tutorial is completed, we will have a game in which a fish (called
<p>When this tutorial is completed, we will have a game in which a fish (called
Hanny) has to navigate through the ocean and pop air bubbles. While doing so,
she has to prevent being bitten by enemies that also prowl the ocean</p>
she has to prevent being bitten by enemies that also prowl the ocean.</p>
<p><img src="images/game/game.png" alt="Waterworld" /></p>
<h2 id="prerequisite"><a class="header" href="#prerequisite">Prerequisite</a></h2>
<p>Yaeger requires Java JDK21 or above to work. Although it can be used with any
<p>Yaeger requires Java JDK21 or above to work. Although it can be used with any
modern IDE that supports Java, this tutorial will only include examples for
<a href="https://www.jetbrains.com/idea/">JetBrains IntelliJ</a> and
<a href="https://www.jetbrains.com/idea/">JetBrains IntelliJ</a> and
<a href="https://www.eclipse.org/">Eclipse</a>.</p>
<p>This tutorial expects a basic understanding of the Java Programming language.
From Java, we will only be using the basic constructs, such as Packages,
classes, interfaces and methods. More &quot;modern&quot; parts of the language, such
From Java, we will only be using the basic constructs, such as packages,
classes, interfaces and methods. More "modern" parts of the language, such
as lambda's or generics are not required, nor used.</p>

</main>
Expand Down
Loading

0 comments on commit 84c9741

Please sign in to comment.