API

Jan 9, 2018
API
  • ArcadeBoard API


    Introduction(top)

    The ArcadeBoard API works similar to any other game API out there. If you ever created games you will most likely recognize design patterns you can find in this API.

    Games are individual JAR files placed in the 'games' folder of the plugin. The server version of the plugin will load these games on startup.

    Of course the graphics are very limited, however the API provides a vast majority of tools that can help you extend these graphics with resource packs. The main types of games this API is created for are 'Tile based games'. If you are not familiar with this concept I suggest reading it here: https://en.wikipedia.org/wiki/Tile-based_video_game

    In short: the games you create are drawn on a low resolution raster. However the things you draw on each pixel on that raster can be high detail by the use of resource packs. The use of resource packs is very well integrated in the API and explained later.

    Understanding the main concept(top)

    There are three main concepts you have to understand of the API.

    GamePlayer(top)

    A player that is added to a game is called a 'GamePlayer'. This is basically a player that is playing the game. With multiplayer games you can have multiple players.

    Canvas(top)

    The canvas is the area you draw on. Each player can have his own canvas, however it is possible to set a global canvas so each player sees the same thing.

    Every frame you can choose to draw on the canvas. The canvas is not reset on every update, you have to reset (parts) of it, or do not update it at all (if no change happens).


    Game(top)

    The game is the class you extend when creating a new game. The game has a game loop that is fired every frame. Default the frame rate is set to 20, however you can increase this up to 30FPS.

    In the game loop you do everything you want that results in a canvas to be altered. You can move an object across the canvas or do whatever you want. As a developer you have to calculate when changes have to happen. If you only want a change to happen every second, but you have an FPS of 25 you only need to trigger this every 25 frames.

    Understanding the technical aspects(top)

    There are some technical aspects you have to keep in mind when creating a game.

    Frame delay(top)

    There is a frame delay of three frames. Meaning that when you change something, it will not be shown for 3 frames. Usually this is not a big problem, seeing for an 25 FPS game this is only 120ms - however it is something to keep in mind when using inputs.

    In the future the plugin may delay the triggers of these inputs by 3 frames in order to compensate for this problem - or even remove the frame delay altogether.

    Screen dimensions(top)

    The screen dimensions depend on a few things. You can have a max amount of lines of 15 + 1 title. The width however is variable:

    • For a 1.8-1.12 server the width is about 22 when each pixel has a different color
      • However the width can increase when not all pixels have a different color when using monochrome games or resource pack intensive games.
    • For a 1.13 server the width is unlimited

    Music and Sound(top)

    The API provides the ability to play music and sound. Sound is similar as in Spigot/Bukkit where you just select a sound and define its volume and pitch.

    The music is different, it allows you to play NBS files (Note Block Sounds) you generated from midi files. Also - in combination with resource packs it allows you to play mp3 files.

    Resource packs(top)


    The API provides the ability to import PNG files that are automatically generated in a resource pack and send to the player when they want to play your game. That way you can create sprites and utilize the color of your PNG images to remove any colors and extending your width on 1.8-1.12 servers to 68 characters.

    Understanding the scaleability of the API(top)

    The API is very scalable. It includes classes and tools for drawing on the screen, .. creating music, ... but the possibilities are way greater than that. The API also provides some basic 2D game dynamics to calculate vectors, drawing specific objects or sprites - but you can also use your own game engine.

    The plugin comes with a shaded version of JBox2D, this is a physics engine that allows you to create physics like bouncing things, hitting two things together, ... (physics).

    That way you can choose to only use the API for the actual drawing - and keep the engine on your side.
  • Loading...
  • Loading...