Skip to content

Commit 406ab54

Browse files
committed
Update up to chapter 14
1 parent 040ec27 commit 406ab54

File tree

143 files changed

+3953
-584
lines changed

Some content is hidden

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

143 files changed

+3953
-584
lines changed

bookcontents/chapter-01/chapter-01.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class Main implements IGameLogic {
6767

6868
As you can see, in the `main` method, we just start our render/game engine, modeled by the `Engine` class.
6969
This class requires, in its constructor, the name of the application and a reference to the class which will implement the application logic.
70-
This is controlled by an interface `IAppLogic` which defines four methods:
70+
This is controlled by an interface `IGameLogic` which defines four methods:
7171

7272
- `cleanup`: Which is invoked when the application finished to properly release the acquired resources.
7373
- `init`: Invoked upon application startup to create the required resources (meshes, textures, etc.).
@@ -121,9 +121,9 @@ public class Engine {
121121
}
122122

123123
public void run() {
124-
EngCfg engineProperties = EngCfg.getInstance();
124+
var engCfg = EngCfg.getInstance();
125125
long initialTime = System.currentTimeMillis();
126-
float timeU = 1000.0f / engineProperties.getUps();
126+
float timeU = 1000.0f / engCfg.getUps();
127127
double deltaUpdate = 0;
128128

129129
long updateTime = initialTime;
@@ -137,8 +137,8 @@ public class Engine {
137137
window.resetInput();
138138

139139
if (deltaUpdate >= 1) {
140-
long diffTimeMilis = now - updateTime;
141-
gameLogic.update(engCtx, diffTimeMilis);
140+
long diffTimeMillis = now - updateTime;
141+
gameLogic.update(engCtx, diffTimeMillis);
142142
updateTime = now;
143143
deltaUpdate--;
144144
}
@@ -180,8 +180,8 @@ This class also provides a handy `stop` method to get out of said loop and a `cl
180180

181181
Let's go back to the core method of the `Engine` class, the `run` method.
182182
We basically control the elapsed time since the last loop block to check if enough seconds have passed to update the state. If so,
183-
we've calculated the elapsed time since the last update and invoke the `update` method from the `IAppLogic` instance.
184-
We invoke the `input` from the `IAppLogic` instance and the `render` method in each turn of the loop.
183+
we've calculated the elapsed time since the last update and invoke the `update` method from the `IGameLogic` instance.
184+
We invoke the `input` from the `IGameLogic` instance and the `render` method in each turn of the loop.
185185
Later on, we will be able to limit the frame rate using vsync, or leave it uncapped.
186186

187187
You may have noticed that we use a class named `EngCfg`, which in this case establishes the updates per second.

bookcontents/chapter-06/chapter-06.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ We are now ready to put all the pieces together and render something to the scre
11211121
```java
11221122
package org.vulkanb;
11231123
...
1124-
public class Main implements IAppLogic {
1124+
public class Main implements IGameLogic {
11251125
...
11261126
@Override
11271127
public InitData init(EngCtx engCtx) {
@@ -1158,7 +1158,7 @@ public record InitData(List<ModelData> models) {
11581158
}
11591159
```
11601160

1161-
Therefore, we need to update the `IAppLogic` interface to reflect that change:
1161+
Therefore, we need to update the `IGameLogic` interface to reflect that change:
11621162

11631163
```java
11641164
public interface IGameLogic {

bookcontents/chapter-07/chapter-07.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ public class ScnRender {
11431143
The next step missing now is to modify the `init` method in or `Main` class:
11441144

11451145
```java
1146-
public class Main implements IAppLogic {
1146+
public class Main implements IGameLogic {
11471147
...
11481148
private final Vector3f rotatingAngle = new Vector3f(1, 1, 1);
11491149
private float angle = 0;
@@ -1206,7 +1206,7 @@ public class Main implements IAppLogic {
12061206
We are defining the coordinates of a cube, and setting some random texture coordinates to see some changes in the color. After that, we need to create also a new `Entity` instance in order to render the cube. We want the cube to spin, so we use the `update` method, that will be invoked periodically to update that angle:
12071207

12081208
```java
1209-
public class Main implements IAppLogic {
1209+
public class Main implements IGameLogic {
12101210
...
12111211
@Override
12121212
public void update(EngCtx engCtx, long diffTimeMillis) {

bookcontents/chapter-08/chapter-08.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2329,7 +2329,7 @@ We need to change we load the models in the `Main` class. Instead of defining th
23292329
`loadModel` and `loadMaterials` methods to load the data:
23302330

23312331
```java
2332-
public class Main implements IAppLogic {
2332+
public class Main implements IGameLogic {
23332333
...
23342334
@Override
23352335
public InitData init(EngCtx engCtx) {

bookcontents/chapter-09/chapter-09.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ public class Render {
763763
The last step is to change the `Main` class to use the camera and a new model. In this case we will be using the famous Sponza model (we are using the models from [GitHub - KhronosGroup/glTF-Sample-Models: glTF Sample Models](https://github.com/KhronosGroup/glTF-Sample-Models)). We have modified the `input` to update the camera position with the mouse movement when pressing the right button:
764764

765765
```java
766-
public class Main implements IAppLogic {
766+
public class Main implements IGameLogic {
767767
...
768768
private static final float MOUSE_SENSITIVITY = 0.1f;
769769
private static final float MOVEMENT_SPEED = 0.01f;
@@ -806,7 +806,7 @@ public class Main implements IAppLogic {
806806
The `init` method has also been modified to load the new model. The `update` method is empty now:
807807

808808
```java
809-
public class Main implements IAppLogic {
809+
public class Main implements IGameLogic {
810810
...
811811
@Override
812812
public InitData init(EngCtx engCtx) {

bookcontents/chapter-10/chapter-10.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,4 +423,4 @@ public class Attachment {
423423
}
424424
```
425425

426-
[Next chapter](../chapter-13/chapter-13.md)
426+
[Next chapter](../chapter-11/chapter-11.md)

0 commit comments

Comments
 (0)