Ep. 02 – Game Loop | Android studio 2D Game Development

How to write your own Game Loop in Android Studio from scratch using Java.
🎁Support me on Patreon for exclusive content: https://www.patreon.com/alexbukk

Next episode – Player control: https://youtu.be/FdVKV8y_1kU
Previous episode – Setup Android Studio: https://youtu.be/joO-0w0qd7k
Project on GitHub: https://github.com/bukkalexander/AndroidStudio2DGameDevelopment

// ========================================
// Social Media
// ========================================
Facebook: https://www.facebook.com/alexander.bukk
Instagram: https://www.instagram.com/bukkalexander/
LinkedIn: https://linkedin.com/in/alexander-bükk-22926311b/
Website: http://alexanderbukk.com

// ========================================
// Production Equipment
// ========================================
*** Recording device – Røde NT1-A: https://amzn.to/2QBbhXu ***
*** Audio interface – Zoom U-22: https://amzn.to/2EPMdr3 ***

// ========================================
// Educational material
// ========================================
Game loop YouTube tutorial: https://youtu.be/OojQitoAEXs
Game loop blog post: https://www.javacodegeeks.com/2011/07/android-game-development-game-loop.html
2D Animation tutorials: https://youtu.be/pywbPQD9vYU

// ========================================
// Production Softwares
// ========================================
Screen capturing: https://obsproject.com/sv/download
Video editing: https://www.blender.org/download/
Audio recording + editing: https://www.audacityteam.org/
Thumbnail design: https://www.gimp.org/
2D animation – Grease pencil inside Blender: https://www.blender.org/download/

// ========================================
// Intro Music
// ========================================
Source: https://www.youtube.com/audiolibrary/music
Artist: Geographer

// ========================================
// Computer Specification
// ========================================
Operating System
Windows 10 Home 64-bit
Intel Core i5 4440 @ 3.10GHz
Haswell 22nm Technology
8.00GB Dual-Channel DDR3 @ 798MHz (11-11-11-28)
Viseo 220Dx (1920×[email protected])
2047MB NVIDIA GeForce GTX 650 (MSI)
931GB Seagate ST1000DX001-1CM162 (SATA )
Optical Drives
Realtek High Definition Audio

*All affiliate links are marked with three asterisks (***)

29 thoughts on “Ep. 02 – Game Loop | Android studio 2D Game Development”

  1. I get no errors at all , but when I run the app I see a white screen and a little bit of black on top, not showing any of the fps or ups info. what should i do?

  2. I like your tutorial a lot, but sometimes you get a bit to quick with your editing, so it is hard to follow your instructions, even with 0.75xSpeed

  3. Hey man, I'm getting a white screen after 12:56, also nothing is getting drawn/displayed either. No errors, I have modified every colour value in every xml file and none of them change the white screen. Any ideas? Seems to be running perfectly otherwise.

  4. hey bro i followed all the steps up until 12:56 but my ups and fps is still not displaying on my phone. I only added one WindowManager.LayoutParams.FLAG_FULLSCREEN as it only let me add one could that be the issue. If you can help please do thanks

  5. Attempt to invoke virtual method 'void com.example.androidstudio2dgamedevelopment.GameLoop.startLoop()' on a null object reference

    how this sir ? sry… i'm beginner

  6. When u run to fix the canvas locking problem … ive been restarting the project 3 times … and the first time it was doin ok …. but now i get that incompatibility error surfaceHolder cannot be converted to this.surf etc….
    Been trying to fix it myself …. but getting painful now ….

  7. the code works well like in video up until when I add the while loop that skips frames when we increase the target UPS. If I comment those lines out, the avgUPS and avgFPS are equal as they should be, but when I add the loop and run they both change to 0 instead of UPS being larger. After a really long time the values change from 0s to very large UPS (currently around 50000) values and a very low FPS (currently around 0.01) values and they are constantly changing around these values
    Is there a way you can help?

  8. I am not getting the FPS and UPS just black screen then exits to phone home screen. I am unsure what I am doing wrong. I copied all the code you have. is it maybe my Android Manifest. Also noticed that where I have canvas in the code it is underlined. Please help!

  9. Hi, really nice tutorials but i have a question:
    I see that your Game class extends the SurfaceView class and then you implemented the game loop yourself but what if you extend the 'View' class directly and Override its on onDraw(Canvas) method and then use this method for all your update and draw code and then finally call invalidate(); at the end.

    Is this bad practice or not recommended?

  10. You channel is awesome and it is teaching me programming alot! im really grateful however i get message

    error: non-static method addCallback(Callback) cannot be referenced from a static context.

    I searched on google but cant find any answers;/ you know why?

Comments are closed.