2021-06-05 20:07:44 +12:00
2021-06-05 15:57:25 +12:00
2021-06-05 16:18:52 +12:00
2021-06-03 17:47:54 +12:00
2021-06-05 02:44:29 +12:00
..
2021-06-05 20:07:44 +12:00

| JavaECS

JavaECS Docs

View the Documentation

About Entity-Component-Systems

Traditional game-engine designs typically follow the standard functional or object-oriented design paradigms. This choice of paradigm is as important as it is in typical applications.

A functional-paradigm game usually focuses on a 'this-then-that' model, e.g.:

Simple Driving Game

turn = GetTurn()
TurnCar(turn)
if IsCollided():  # and other checks
    GameOver()
else:
    DrawNextFrame()
    turn = GetTurn()

Such a system works well for some game-designs; it is simplistic and follows a deterministic sequence of steps. But it lacks scalability and extensibility.

An Object-Oriented approach could be used instead:

# Create a base-class that is a vehicle, with basic properties:
class Vehicle:
    position = [x,y]
    IsCrashed = False
    def CalcTurn():
        pass
    def IsCollided():
        pass

# Create the PlayerVehicle class which extends Vehicle to include the player input method
class PlayerVehicle(Vehicle):
    def GetPlayerInput():
        pass

def GameLoop():
    vehicles[] = GetAllVehichles()
    allCollided = False
    while not allCollided:
        for v in vehicles:
            turnAmount
            if v is PlayerVehicle:
                turnAmount = v.GetPlayerInput()
            else:
                turnAmount = v.CalcTurn()
            v.TurnVehicle()
            if v.IsCollided():
                v.IsCrashed = True
        anyNotCollided = False
        for v in vehicles:
            if v.IsCrashed = False:
                anyNotCollided = True
                break

Which allows the instancing of objects. Each action also results in an objective state, which can be simply compared to determine the result.

ECS are typically built on object-oriented ideas, but make specfic attempts to reduce overheads that come from object-oriented ideas. The primary reduction made in ECS is to eliminate or otherwise minimise inhertance cycles to reduce the amount of virtual calls required.

Description
Documentation for the Java Entity-Component-System
Readme 135 KiB
Languages
HTML 95.6%
JavaScript 4.4%