Developing Games

From Arduboy Wiki
Revision as of 11:49, 13 August 2024 by Filmote (talk | contribs) (→‎ArduboyG)
Jump to navigation Jump to search

Developing games for the Arduboy is an exciting endeavor that blends creativity with technical skills. The Arduboy is a compact, credit card-sized gaming platform based on the Arduino microcontroller, making it accessible for both beginners and experienced developers. Its simplicity and portability offer a unique challenge due to its limited resources, such as a monochrome 128x64 pixel display and minimal memory. However, these constraints inspire innovation and efficient coding practices.

Standard libraries for sound and graphics play a significant role in the development process. The Arduboy2 library provides essential functions for managing the display, handling input, and maintaining game states. It facilitates tasks such as drawing shapes, rendering text, and controlling frame rates, allowing developers to concentrate on game mechanics. For audio, the ArduboyTones library enables the addition of sound effects and music, enhancing the game's atmosphere. Using these libraries, developers can create functional and engaging games that work well within the Arduboy's hardware limitations.

Prerequisites for Developing Games

Arduino Development IDEs

Arduino development environments provide a range of tools for creating, testing, and deploying projects to the Arduboy. The primary environment is the Arduino Integrated Development Environment (IDE), known for its user-friendly interface that simplifies writing, compiling, and uploading code. It supports various Arduino models and includes a library manager for easy access to numerous libraries. Additionally, Visual Studio Code (VSCode) can be used for Arduino development, offering advanced features like integrated debugging and a customizable interface. These environments cater to both beginners and advanced users, offering tools that range from straightforward to professional-grade.

Visual Studio Code

The Arduino plugin for Visual Studio Code is an easy way to develop and build Arduboy games with a full-featured IDE.

1. Download and install Visual Studio Code.

2. Install the "Arduino" extension developed by Microsoft.

3. Configure the extension to use the bundled version of Arduino CLI.

4. Add the following URL to the "Additional Urls" setting for the Arduino extension:

https://raw.githubusercontent.com/MrBlinky/Arduboy-homemade-package/master/package_arduboy_homemade_index.json

5. Open the Arduino Board Manager and click "Refresh Package Indexes". Install the Arduboy homemade package by Mr.Blinky.

6. Add a file ".vscode/arduino.json" to your project to define how to build your project. For example, to build a game for the Arduboy FX, you might have:

{
    "configuration": "core=arduboy-core,boot=cathy3k",
    "board": "arduboy-homemade:avr:arduboy-fx",
    "sketch": "my_game.ino",
    "output": "build/"
}

7. You can now build your project with the "Arduino: Verify" command. The command will create a "build" directory inside your project directory, and generate .hex and .elf files there.

Common Libraries

An Arduboy library is a collection of pre-written code designed to simplify and standardize the development of games and applications for the Arduboy platform. These libraries provide a range of functionalities, such as handling graphics, sound, input, and other core features of the device. For example, the Arduboy2 library includes functions for drawing shapes, rendering text, managing game states, and handling user input, while the ArduboyTones library offers tools for generating sound effects and music. By utilizing these libraries, developers can streamline their coding process, focus on the creative aspects of game design, and ensure their applications run efficiently on the limited hardware of the Arduboy.

Base Libraries

Arduboy2

The basic Arduboy library, often referred to as Arduboy2, is an essential toolkit for developing games on the Arduboy platform. This library provides a comprehensive set of functions that manage the device's core features, making it easier for developers to create games and applications. It includes capabilities for drawing graphics on the 128x64 pixel monochrome display, such as drawing lines, circles, and rectangles, as well as rendering text. The library also handles input from the device's buttons, allowing developers to implement game controls efficiently. Additionally, Arduboy2 offers functions for managing frame rates and game states, ensuring smooth game play experiences. By using the Arduboy2 library, developers can focus more on the creative aspects of game development while leveraging standardized, efficient code for fundamental tasks.

Graphic Libraries

Sprites / SpritesB

Shipped as part of the Arduboy2 library, the Sprites library provides functions for rendering both masked and unmasked bitmaps and tilesheets. When working with masked bitmaps, the library supports various formats including standalone masks (allowing them to be used with multiple bitmaps) or interlaced within the bitmap image themselves (for best performance). The library can only render images from PROGMEM and provides no FX chip support.

The SpritesB library is functionally identical to the standard Sprites library but the code has been optimised for size at the expense of speed.

ArduboyG

The ArduboyG library extends the basic Arduboy2 library with advanced functions for handling sprites, animations, and complex graphical operations, including support for 3 and 4 color greyscale. The library allows images to be rendered from PROGMEM or directly from the FX chip. Images can include transparent sections and must be a multiple of 8 bits high. These are converted using a python script provided with the library.

ArdBitmap

The ArdBitmap library works with compressed and uncompressed bitmaps and provides horizontal and vertical mirroring and real-time image resizing (downscaling). It can only render images from PROGMEM and provides no FX chip support.