Overview
Explanation
GagsEngine will actually be two Java code libraries, one for desktop applications, the other for Android, however they will each share the same code and API (Application Program Interface, or in layman's terms, a template on everything the code library must have regardless of what system it is running on).
Let's back up a second. What's Java? What's Swing? What's Android?
Java is an object-oriented programming language that is cross-platform (works on Windows, Mac, and Linux). The Java library comes equipped with many features, including GUI libraries. (GUI stands for Graphical User Interface, aka visual elements on the screen).
Java's main graphics library is Swing, and that is what I use for graphics in my desktop programs
Eventually the Android operating system for smartphones was created. Android OS is built on Java.
Does that mean all Java programs will work on Android? Sadly, no. The Android SDK (Software Development Kit) does share part of the basic Java library with the desktop versions of Java. However, since it is using different hardware, the library is different (and also more modern).
Swing is not included in Android at all. This presents a problem to me, since graphics and resources are handled in completely different manners. How can I write a program that works for both?
Luckily Java has interfaces and abstract classes. Each allow you to specify what objects in a program should do, but allow you to not specify how the tasks should be conducted.
In context, my basic API includes only parts of my game engine that uses only basic Java functionality that both desktop and Android flavors of Java can handle. For parts that are platform-specific (for example, graphics and resources) I create interfaces that describe what the game engine should do, and leave the details to be given in each individual library.
For example, I have an Image interface that describes a basic image that stores image data and some other information such as width and height. In my desktop version of my library, I define a SwingImage that stores a BufferedImage, where as the AndroidImage uses a Bitmap for the image data. However, for either version of Image, you can still get the image data for drawing, as well as the width and height.
The desktop version of GagsEngine implements my game engine API, using Swing to handle files, images, and drawing to a desktop application window.
The Android version of GagsEngine will do the same, yet it will use the Android graphics library to handle graphics.
Let's back up a second. What's Java? What's Swing? What's Android?
Java is an object-oriented programming language that is cross-platform (works on Windows, Mac, and Linux). The Java library comes equipped with many features, including GUI libraries. (GUI stands for Graphical User Interface, aka visual elements on the screen).
Java's main graphics library is Swing, and that is what I use for graphics in my desktop programs
Eventually the Android operating system for smartphones was created. Android OS is built on Java.
Does that mean all Java programs will work on Android? Sadly, no. The Android SDK (Software Development Kit) does share part of the basic Java library with the desktop versions of Java. However, since it is using different hardware, the library is different (and also more modern).
Swing is not included in Android at all. This presents a problem to me, since graphics and resources are handled in completely different manners. How can I write a program that works for both?
Luckily Java has interfaces and abstract classes. Each allow you to specify what objects in a program should do, but allow you to not specify how the tasks should be conducted.
In context, my basic API includes only parts of my game engine that uses only basic Java functionality that both desktop and Android flavors of Java can handle. For parts that are platform-specific (for example, graphics and resources) I create interfaces that describe what the game engine should do, and leave the details to be given in each individual library.
For example, I have an Image interface that describes a basic image that stores image data and some other information such as width and height. In my desktop version of my library, I define a SwingImage that stores a BufferedImage, where as the AndroidImage uses a Bitmap for the image data. However, for either version of Image, you can still get the image data for drawing, as well as the width and height.
The desktop version of GagsEngine implements my game engine API, using Swing to handle files, images, and drawing to a desktop application window.
The Android version of GagsEngine will do the same, yet it will use the Android graphics library to handle graphics.