Update 'README.md'
This commit is contained in:
parent
deb74fd20c
commit
c664129459
57
README.md
57
README.md
@ -1,3 +1,58 @@
|
||||
# JavaECS-Docs
|
||||
|
||||
Documentation for the Java Entity-Component-System
|
||||
## *Documentation for the Java Entity-Component-System*
|
||||
|
||||
Traditional game-engine designs typically follow the standard functional or object-oriented design paradigms.
|
||||
|
||||
Functional-paradigm games focus 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
|
||||
|
||||
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user