*| JavaECS* # JavaECS Docs ### [View the Documentation](./docs/overview.md) ## *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*** ``` py 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: ``` py # 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.