Blueprint
Blueprint is a foundation package for the Bappa Framework, providing common components, interfaces, and utilities for game development.
Overview
Blueprint serves as the base layer of the Bappa Framework, defining standard component types and interfaces that other packages in the framework build upon. It establishes shared patterns and data structures used throughout the ecosystem.
Features
- Core Interfaces: Defines essential interfaces like
Scene
and CoreSystem
- Common Components: Provides standardized component definitions across multiple domains
- Vector Mathematics: Complete 2D vector implementation with comprehensive operations
- Predefined Queries: Ready-to-use queries for common component combinations
- Background Utilities: Tools for creating static and parallax backgrounds
- Shape Factory: Various shape creation functions for collision geometry
Installation
go get github.com/TheBitDrifter/blueprint
Component Subpackages
Blueprint organizes components by domain:
-
blueprint/client: Visual and audio components
SpriteBundle
: Sprites with animation support
SoundBundle
: Audio resources
ParallaxBackground
: Multi-layered scrolling backgrounds
-
blueprint/input: User interaction components
InputBuffer
: Collection and management of user inputs
StampedInput
: Inputs with timing and position information
-
blueprint/motion: Physics components
Dynamics
: Physical properties for movement and forces
-
blueprint/spatial: Positioning and geometry components
Position
, Rotation
, Scale
: Basic spatial properties
Shape
: Collision geometry with various factory methods
Direction
: Directional orientation
-
blueprint/vector: 2D vector mathematics
Two
: Vector with extensive operations (add, subtract, rotate, etc.)
- Vector interfaces for flexible implementation
Quick Start
Using Predefined Queries
cursor := scene.NewCursor(blueprint.Queries.Position)
for range cursor.Next() {
pos := blueprintspatial.Components.Position.GetFromCursor(cursor)
}
Creating Backgrounds
builder := blueprint.NewParallaxBackgroundBuilder(storage)
builder.AddLayer("backgrounds/mountains.png", 0.2, 0.0)
builder.AddLayer("backgrounds/clouds.png", 0.5, 0.1)
builder.WithOffset(vector.Two{X: 0, Y: 20})
builder.Build()
blueprint.CreateStillBackground(storage, "backgrounds/scene.png")
Creating and Using Shapes
rect := blueprintspatial.NewRectangle(50, 30)
ramp := blueprintspatial.NewSingleRamp(100, 40, true)
platform := blueprintspatial.NewTrapezoidPlatform(80, 20, 0.7)
License
MIT License - see the LICENSE file for details.