Ola
Download
What's New
In the game config we introduce some new properties, render, autoFocus etc. We also look at how to scale the game to fit
I chose this game because it has a resource loading functionality that displays for the user whilst resources are loading and also because I have 4 eyes! So I can always test how good my eyes are at anytime.
Extras...
Loading scripts (requires an internet connection)
PURPOSE OF THE GAME
How good are your eyes? This is a wrap of this Github done by Marcus Sanatan
You are provided with balls of different sized in each level. The task is to expand the balls on the bottom to be equal in size with the balls on the top. You can also add extra needed balls if there is more.
The code for the game is kinda cumbersome so we will touch on the parts that I think are rather useful in our game development lessons. These are
1. Showing progress when resources are being loaded.
2. Using webfonts to textualize our game
3. Scaling the game to fit the specified viewport
The rest you can learn on the code.
SHOWING PROGRESS
This is to indicate the status of the game load. We will need to do this on the preLoad sub.
Now for the onProgress and onComplete methods. These update the graphic to show percentage and loading and after completion starts the game.
Download
What's New
In the game config we introduce some new properties, render, autoFocus etc. We also look at how to scale the game to fit
I chose this game because it has a resource loading functionality that displays for the user whilst resources are loading and also because I have 4 eyes! So I can always test how good my eyes are at anytime.
Extras...
Loading scripts (requires an internet connection)
PURPOSE OF THE GAME
How good are your eyes? This is a wrap of this Github done by Marcus Sanatan
You are provided with balls of different sized in each level. The task is to expand the balls on the bottom to be equal in size with the balls on the top. You can also add extra needed balls if there is more.
The code for the game is kinda cumbersome so we will touch on the parts that I think are rather useful in our game development lessons. These are
1. Showing progress when resources are being loaded.
2. Using webfonts to textualize our game
3. Scaling the game to fit the specified viewport
The rest you can learn on the code.
SHOWING PROGRESS
This is to indicate the status of the game load. We will need to do this on the preLoad sub.
B4X:
Sub onPreload
progressBar = Scene.add.graphics
progressBox = Scene.add.graphics
progressBox.fillStyle("0x222222", 0.8)
progressBox.fillRect(240, 270, 320, 50)
Dim width As Int = Scene.cameras.mainc.width
Dim height As Int = Scene.cameras.mainc.height
loadingText = Scene.make.text(width / 2, height / 2 - 50, "Loading...", "20px monospace", "#ffffff")
loadingText.setOrigin(0.5, 0.5)
percentText = Scene.make.text(width / 2, height / 2 - 5, "0%", "18px monospace", "#ffffff")
percentText.setOrigin(0.5, 0.5)
'
Dim value As Double
Dim onloadCB As BANanoObject = BANano.CallBack(Me, "onProgress", Array(value))
Scene.load.on("progress", onloadCB)
'
Dim onCompleteCB As BANanoObject = BANano.CallBack(Me, "onComplete", Null)
Scene.load.on("complete", onCompleteCB)
'load resources
Scene.load.image("separator", "./assets/separator.png")
Scene.load.image("playerBall", "./assets/playerBall.png")
Scene.load.image("guessBall", "./assets/guessBall.png")
Scene.load.image("growButton", "./assets/growButton.png")
Scene.load.image("checkButton", "./assets/checkButton.png")
Scene.load.image("nextButton", "./assets/nextButton.png")
Scene.load.image("retryButton", "./assets/retryButton.png")
Scene.load.image("addButton", "./assets/addButton.png")
Scene.load.image("disabledGrowButton", "./assets/disabledGrowButton.png")
Scene.load.image("disabledAddButton", "./assets/disabledAddButton.png")
'load google font script
Scene.load.script("webfont", "https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js")
End Sub
Now for the onProgress and onComplete methods. These update the graphic to show percentage and loading and after completion starts the game.
B4X:
Sub onProgress(value As Double)
Dim perc As String = Scene.Percentage(value)
Dim strVal As String = Scene.Cstr(perc) & "%"
percentText.setText(strVal)
progressBar.clear
progressBar.fillStyle("0xffffff", 1)
progressBar.fillRect(250, 280, 300 * value, 30)
End Sub
Sub onComplete
progressBar.destroy
progressBox.destroy
loadingText.destroy
percentText.destroy
Scene.Start(gameScene.Scene.name)
End Sub
Last edited: