aia-file

Submariner

by
published on

This is a small tutorial about a game i made. It is called Submariner. Object of the game is to move the sprite around the screen without touching the edges of your screen. You move the sprite bij tilting the phone. 

This is how the end result looks. 

I used the tools extension from Taifun. https://puravidaapps.com/tools.php

The image is from https://pixabay.com/vectors/dive-scuba-ocean-sea-water-fish-4219524/

The sonar effect is from http://www.orangefreesounds.com/sonar-sound-effect/

In the aia-file the images and sound effects are all present. 

In this block i made it so that the screen will always be on. During the game you don't touch the screen and it would blackout after some time. The sonar sound is played, the submarine is centered on the screen and the hi-score is loaded from the TinyDB.

This is the routine that centers the sprite on the screen. 

This routine lets the submarine move. It uses the pitch and roll property of the orientationssensor. Looking at the value of pitch and roll the heading of the submarine is changed. 

When you touch the edge of the screen with your submarine the clock that is counting the seconds is stopped. The speed of the submarine is set to 0 so it stops. The sound of the sonar stops. A dialog is opened. The message displayed is depended on the value of your score. If the value of the score is higher then the hi-score it is saved in the TinyDB. You get the choice to play again or to quit. 

If you choose quit the block dontkeepscreenon is executed and the screen is closed. If you choose again the sound is started, the sprite is centered on the screen, the score is set to zero, the clock that counts the second is reset to 0. The image sprite is set to 2 and the value of the tag hiscore in the TinyDB is put in label6. 

This block adds 1 to the speed of the submarine every minute. 

This block adds 1 to the score every second. 

Here you can downloade the aia-file.

Link to the app on Google Play.