This is a "bare" arkanoid game:
The code is made of 4 modules:
Main - main activity. Also holds the main timer that is running the game.
Ball - code module. Responsible for moving the ball and checking for hits.
Slider - code module. Responsible for moving the slider. It also draws a red marker to mark the slider target.
Bricks - code module. Responsible for drawing and managing the bricks.
Two layers are used for the drawing. This is done by adding two panels over the activity. One layer is used for the ball and the second layer for the bricks and slider.
By separating the drawing to two layers we overcome issues where the ball might erase a part of the slider or a brick.
SoundPool is used to play the three sounds.
Sounds were downloaded from here: Crash Sounds | Free Sound Effects | Crash Sound Clips | Sound Bites
If you want to use those sounds for commercial use you should check their license.
Drawings are related to the screen size and should look properly on all devices.
I've checked this program on several devices and the game speed looks fine. If you run it on the emulator you will need to change the timer interval (and it will not run smoothly). Make sure to disable the debugger if you are encountering performance issues.
The game progress is managed by MainTimer which calls the other modules:
I hope that you this code will be helpful. Please feel free to ask any question about it...
The compiled APK can be downloaded here: http://www.b4x.com/android/files/Arkanoid.apk
The code is made of 4 modules:
Main - main activity. Also holds the main timer that is running the game.
Ball - code module. Responsible for moving the ball and checking for hits.
Slider - code module. Responsible for moving the slider. It also draws a red marker to mark the slider target.
Bricks - code module. Responsible for drawing and managing the bricks.
Two layers are used for the drawing. This is done by adding two panels over the activity. One layer is used for the ball and the second layer for the bricks and slider.
By separating the drawing to two layers we overcome issues where the ball might erase a part of the slider or a brick.
SoundPool is used to play the three sounds.
Sounds were downloaded from here: Crash Sounds | Free Sound Effects | Crash Sound Clips | Sound Bites
If you want to use those sounds for commercial use you should check their license.
Drawings are related to the screen size and should look properly on all devices.
I've checked this program on several devices and the game speed looks fine. If you run it on the emulator you will need to change the timer interval (and it will not run smoothly). Make sure to disable the debugger if you are encountering performance issues.
The game progress is managed by MainTimer which calls the other modules:
B4X:
Sub MainTimer_Tick
Ball.Tick(drawers) 'move and handle the ball
Slider.Tick(drawers) 'move and handle the slider
End Sub
The compiled APK can be downloaded here: http://www.b4x.com/android/files/Arkanoid.apk