zgameeditor (ZGE)

repository·master·Indexed 41 days ago

https://github.com/villekrumlinde/zgameeditor

A FOSS game engine written in Delphi/Freepascal for creating ultra-small games (under 64kb) using OpenGL and real-time audio synthesis. It features a Windows-only authoring tool and a runtime engine supporting Windows, Mac OS X, Linux x86, and Android. Key components include AnimatorGroup and AnimatorSimple for animations, AppState for application mode management, and a real-time AudioMixer.

Tokens
66.9K
Snippets
135
Records
410
Agent score
100%

What's inside zgameeditor

  1. Overview of zgameeditor

    master

    zgameeditor (ZGE) is a game engine designed to create extremely small games with a redistributable size of 64kb or less. It utilizes OpenGL for graphics rendering and a real-time synthesizer for audio generation.

    ZGE is Free Open Source Software (FOSS) written in Delphi/Freepascal. It provides a dedicated authoring tool for Windows and a runtime engine that supports multiple platforms.

  2. Overview of ZGameEditor sample projects

    master

    ZGameEditor includes various sample projects that demonstrate specific technical capabilities of the engine:

    • ZBlast: Arena-style shooting with abstract graphics.
    • FpsDemo: Demonstrates 3D game capabilities (First Person Shooter style).
    • ShaderDemo: Demonstrates GLSL vertex and fragment shaders.
    • CleanseCube: Demonstrates imported bitmap graphics and warped 3D cubes.
    • ZPong: Demonstrates stereo sound and simple game logic.
    • Particles: Demonstrates particle effects (can be used as a screensaver).
    • TripleE: A shoot-em-up demonstrating scoring, levels, stages, and on-the-fly model generation.
    • Steering: Demonstrates steering behaviors.
    • About: The source for the ZGameEditor 'About' box animation.
    • Implicit: A test project for the experimental implicit surface polygonizer.
    • FileDemo: Demonstrates using the File component to load and save data from text files.
    • YakYakReader: Demonstrates web browser integration via YakYak active topics.
    • RenderTexture: Demonstrates RenderTarget and SetRenderTarget components by rendering a dynamic scene to a texture used on a rotating cube.
    • RenderPass: Demonstrates ZApplication.RenderPasses by using two render passes to render a spiral to a RenderTarget and then using that target as a texture for sprites.
    • ModPlay: Demonstrates playing music files using the external BASS.dll library and visualizing volume levels.
  3. Syntax and Structure of the ZGameEditor Scripting Language

    master

    The ZGameEditor scripting language is based on C language dialects. It is used to compute values for component properties and control application behavior.

    Statements

    A statement is a declaration of a variable/function or the execution of a command. Statements must be terminated with a semicolon (;).

    Blocks

    Statements can be grouped into a block using curly brackets ({ and }). Blocks do not require a terminating semicolon and are typically used for control flow or function definitions.

    Comments

    • Single-line: Start with // and continue to the end of the line.
    • Multi-line: Start with /* and end with */.
    // Single line comment
    /* Multi-line 
       comment */
    
    {
        int x = 10;
        x = x + 5;
    }
  4. Develop applications with ZGameEditor

    master

    ZGameEditor is a tool for rapid development of games and multimedia applications (like retro games, screensavers, or animations). It consists of an IDE for development and a multi-platform OpenGL-based runtime engine.

    Workflow

    1. Create/Load Project: Projects are stored as XML-based .zgeproj files.
    2. Develop: Use the IDE to add components and configure properties.
    3. Test/Debug: Execute the application within an integrated view in the IDE. You can modify code during runtime, and changes are reflected immediately.
    4. Export: Once free of syntax or compilation errors, export the project to a standalone executable for the selected platform. The exported file includes both the engine and your compiled application code.
  5. Use the WebOpen component to access web pages

    master

    The WebOpen component allows you to interact with web pages, which can be used for displaying online high scores or implementing turn-based multiplayer functionality.

    It supports two modes of operation:

    1. In-Browser Mode: When InBrowser is set to true, the web page opens in a separate browser window.
    2. Data Retrieval Mode: When InBrowser is set to false, the component fetches the page content and stores it in the ResultString property. In this mode, you should use the OnResult event to process the fetched data.
  6. Navigate the ZGameEditor IDE structure

    master

    The ZGameEditor IDE is organized into several functional panels that allow you to manage components, edit properties, and preview your application:

    1. Project Tree: Displays the hierarchy of components. The root is always the ZApplication component (referred to as App in expressions).
    2. Property Editor: Shows the editable properties of the currently selected component.
    3. Preview Window: Displays visual or auditory feedback (3D models, bitmaps, audio, or the running application).
    4. Custom Property Editor: Provides specialized input tools (sliders, code editors, shader editors) based on the selected property type.
    5. Log Window: Displays internal engine messages and error logs.
    6. Toolbar and Menu: Provides access to standard editor actions.
  7. Use BitmapDistort to distort bitmaps

    master

    The BitmapDistort component allows you to distort a primary bitmap using the pixel data from a second bitmap. The distortion works by shifting pixels of the first bitmap based on the color values of the second bitmap at the same position:

    • Vertical shift: Determined by the G (Green) pixel value of the 2nd bitmap.
    • Horizontal shift: Determined by the B (Blue) pixel value of the 2nd bitmap.

    Constraint: This component can only be used within the Bitmap.Producers property of a Bitmap object.

    // Conceptual usage within Bitmap.Producers
    Bitmap.Producers = BitmapDistort(primaryBitmap, distortionMapBitmap, amount);
  8. Use Component-based Types

    master

    ZGameEditor allows you to create variables of types that correspond to specific components. You can instantiate these components and set their properties directly in scripts.

    Supported Component Types:

    • model: An instance of the Model component
    • Material, Sound, Shader, Bitmap, Mesh, Camera, Font, Sample, Component

    Note: Except for model, component-based variables must be defined as local expression variables or global variables defined in the ZLibrary component.

    // Instantiating models in a loop
    model m;
    for(int i = 0; i < 100; i++) {
      m = createModel(AsteroidModel);
      m.Position.X = random(0, 50);
      m.AsteroidWeight = random(30, 10);
    }
    
    // Using Sound component
    Sound snd = @Sound();
    @PlaySound(Sound : snd, NoteNr : 65);
  9. Use FileMoveData to transfer data between files and variables

    master

    The FileMoveData component is used to transfer data between a file and a variable. It is a specialized component that can only be utilized within the File.OnRead or File.OnWrite list properties of a File object.

    To use it, you must specify a target property that will receive the value from the file (during a read operation) or provide the value to be written to the file (during a write operation).

  10. Use the Shader component for OpenGL shaders

    master

    The Shader component allows you to implement custom rendering logic using OpenGL Shading Language (GLSL). You can provide source code for vertex, geometry, and fragment shaders.

    Depending on your ZApplication.GLBase configuration, the available GLSL version and built-in variables will change:

    • Compatible mode: Supports GLSL 1.1.
    • ES2/GL3 mode: Supports modern GLSL with specific built-in uniform and attribute variables provided by ZGameEditor.
  11. Understand the ZApplication component

    master
    The ZApplication component is the top-most component of your application. It is automatically created when you start a new project and serves as the central hub for application-level settings, global properties, and lifecycle events. It manages high-level concerns such as windowing, rendering modes, camera settings, input, and Android-specific configurations.