interfaces impl - wxyz-abcd/node-haxball GitHub Wiki
Implementation of Haxball's inner classes. Some important classes are exported through this object.
The explanations will be cut short, vague and sometimes partially ambiguous here; and only some of the properties of classes will be explored due to the potentially harmful nature of explaining these in detail.
The classes are put into 3 categories for now:
Some important core classes used inside Haxball.
The Point class that is used internally inside the game's physics engine.
-
x: number
: The x coordinate of the point. -
y: number
: The y coordinate of the point.
The class that defines the colors of a team.
-
angle: number
: The angle of stripes rendered inside a player. -
text: int
: The numeric color of the avatar text rendered inside a player. -
inner: int[]
: The numeric colors of each stripe rendered inside a player.
The class that defines the properties of a team.
-
spec: Team
: The static spectators team. -
red: Team
: The static red team. -
blue: Team
: The static blue team. -
byId: Team[]
: A static array to get all teams using their ids. Its definition isTeam.byId = [Team.spec, Team.red, Team.blue]
.
-
id: int
: The id of current Team object. -
color: int
: The numeric color value of current Team object.
These classes are used to read/write data from/to replay files and/or network/WebRTC stream.
StreamReader class
StreamWriter class
All Stadium-related classes.
A class that defines a vertex.
-
id: int
: The id(index) of this Vertex. -
cGroup: int
: The collision group of this Vertex. -
cMask: int
: The collision mask of this Vertex. -
bCoef: number
: The bouncing coefficient of this Vertex. -
pos: Point
: The position of this Vertex.
A class that defines a segment.
-
v0: Vertex
: The first Vertex of this Segment. -
v1: Vertex
: The second Vertex of this Segment. -
curveF: number
: The curving angle of this Segment. (in radians) -
color: int
: The color of this Segment. Range: -1 <=color
< 16777216.- This value can be converted into a rgba string via API's
Utils.numberToColor
function. - The special value
-1
meanstransparent
color.
- This value can be converted into a rgba string via API's
-
vis: boolean
: Whether this Segment is visible or not. -
bias: number
: Bias of this Segment. -
bCoef: number
: The bouncing coefficient of this Segment. -
cGroup: int
: The collision group of this Segment. -
cMask: int
: The collision mask of this Segment. -
normal: Point
: The calculated normal vector of this Segment. Only applies to non-curved Segments. -
v0Normal: Point
: The calculated normal direction of the object's tangent line atv0
. Only applies to curved Segments. -
v1Normal: Point
: The calculated normal direction of the object's tangent line atv1
. Only applies to curved Segments. -
arcRadius: Point
: The calculated radius of this Segment. Only applies to curved Segments. -
arcCenter: Point
: The calculated center point of this Segment. Only applies to curved Segments.
A class that defines a plane.
-
normal: Point
: The normal vector of this Plane. -
dist: number
: The distance of this Plane to the origin point(0, 0). -
bCoef: number
: The bouncing coefficient of this Plane. -
cGroup: int
: The collision group of this Plane. -
cMask: int
: The collision mask of this Plane.
A class that defines a goal.
-
p0: Point
: The first point of this Goal. -
p1: Point
: The second point of this Goal. -
team: Team
: The team that this Goal belongs to.
-
check(p1: Point, p2: Point): boolean
Checks whether the line segment that passes through p1 and p2 intersects with the goal line.
Parameters:
-
p1: Point
: The first point of the line segment to check. -
p2: Point
: The second point of the line segment to check.
Return value: True if intersection occurs, false otherwise.
-
A class that defines a disc.
-
pos: Point
: The position of this Disc. -
radius: number
: The radius of this Disc. -
speed: Point
: The speed of this Disc. -
gravity: Point
: The gravity of this Disc. -
damping: number
: The damping value of this Disc. -
invMass: number
: The 1/mass value of this Disc. -
bCoef: number
: The bouncing coefficient of this Disc. -
color: int
: The color of this Disc. Range: -1 <=color
< 16777216.- This value can be converted into a rgba string via API's
Utils.numberToColor
function. - The special value
-1
meanstransparent
color.
- This value can be converted into a rgba string via API's
-
cGroup: int
: The collision group of this Disc. -
cMask: int
: The collision mask of this Disc.
A class that defines a joint.
-
d0: int
: Index of the first Disc of this Joint. -
d1: int
: Index of the second Disc of this Joint. -
minLength: number
: The minimum length of this Joint. -
maxLength: number
: The maximum length of this Joint. -
strength: number
: The strength of this Joint. (Infinity
means rigid.) -
color: int
: The color of this Joint. Range: -1 <=color
< 16777216.- This value can be converted into a rgba string via API's
Utils.numberToColor
function. - The special value
-1
meanstransparent
color.
- This value can be converted into a rgba string via API's
A class that defines a stadium.
-
vertices: Vertex[]
: All vertices of this Stadium. -
segments: Segment[]
: All segments of this Stadium. -
planes: Plane[]
: All planes of this Stadium. -
goals: Goal[]
: All goals of this Stadium. -
discs: Disc[]
: All discs of this Stadium. -
joints: Joint[]
: All joints of this Stadium. -
redSpawnPoints: Point[]
: All spawn points of this Stadium for the red team. -
blueSpawnPoints: Point[]
: All spawn points of this Stadium for the blue team. -
playerPhysics: PlayerPhysics
: The physics properties of all players for this Stadium. -
defaultStadiumId: int
: The id(index) of this Stadium in the default stadiums array. This value will be 255 in custom Stadiums. -
maxViewWidth: number
: The maximum view width for this Stadium. Used in Renderers. -
cameraFollow: CameraFollow
: Whether the camera will follow the player or not. Used in Renderers. -
canBeStored: boolean
: Whether this Stadium can be stored or not. -
fullKickOffReset: boolean
: Whether the disc positions other than the ball are reset or not after a goal is scored. -
name: string
: The name of this Stadium. -
width: number
: The width of this Stadium. -
height: number
: The height of this Stadium. -
bgType: BackgroundType
: The background type of this Stadium. -
bgColor: int
: The background color of this Stadium. Range: -1 <=bgColor
< 16777216.- This value can be converted into a rgba string via API's
Utils.numberToColor
function. - The special value
-1
meanstransparent
color.
- This value can be converted into a rgba string via API's
-
bgWidth: number
: The width for the background of this Stadium. -
bgHeight: number
: The height for the background of this Stadium. -
bgKickOffRadius: number
: The kick-off circle's radius for the background of this Stadium. -
bgCornerRadius: number
: The radius of the corners for the background of this Stadium. -
spawnDistance: number
: The spawn distance of players for this Stadium. -
bgGoalLine: number
: The goal line's horizontal distance from the default goal positions for the background of this Stadium. -
isCustom: boolean
: Whether this is a custom Stadium or a default Stadium. (readonly)
-
copy(): Stadium
Creates a copy of this Stadium object.
Parameters: None.
Return value: A new clone of this Stadium object.
-
calculateChecksum(): string|null
Returns the checksum for this Stadium object.
Parameters: None.
Return value: The checksum string of this Stadium object, or
null
for default stadiums. -
calculateHash(): int
Returns the hash value for this Stadium object.
Parameters: None.
Return value: The hash value for this Stadium object.