Contents
xSGE is a collection of extensions for the SGE licensed under the GNU General Public License. They are designed to give additional features to free/libre software games which aren’t necessary, but are nice to have.
xSGE extensions are not dependent on any particular SGE implementation. They should work with any implementation that follows the specification.
This extension provides an easy-to-use framework for collision physics. This is especially useful for platformers, though it can also be useful for other types of games.
Note
This collision system supports plain rectangle-based collision detection ONLY. Attempting to use precise or ellipse collision detection will not work as you expect, and may often not even work at all. This is because implementing support for such mask-based collision detection would be guaranteed to be slow, unreliable, and needlessly complicated; it’s not worth it.
If you must use precise collision detection, consider doing so with a separate object that follows the appropriate Collider object.
Class for objects which have physics interactions.
Note
This class depends on use of Collider.move_x() and Collider.move_y() to handle physics interactions. event_update_position() uses these methods, so speed attributes will work properly, but changing x and y manually will not cause any physics to occur.
These attributes are used by certain wall classes to exclude the object from “sticking” to the wall. See the documentation for the wall classes for more information.
Default value: False
Move the object horizontally, handling physics.
Arguments:
Move the object vertically, handling physics.
Arguments:
Return a list of SolidRight objects whose right sides are touching the left side of this object.
Return a list of SolidLeft objects whose left sides are touching the right side of this object.
Return a list of SolidTop objects whose top sides are touching the bottom side of this object.
Return a list of SolidBottom objects whose bottom sides are touching the top side of this object.
Return a list of SlopeTopRight and SlopeBottomRight objects whose right sides are touching the left side of this object.
Return a list of SlopeTopLeft and SlopeBottomLeft objects whose left sides are touching the right side of this object.
Return a list of SlopeBottomLeft and SlopeBottomRight objects whose bottom sides are touching the top side of this object.
Return a list of SlopeTopLeft and SlopeTopRight objects whose top sides are touching the bottom side of this object.
Called when the left side of the collider collides with a wall or slope in the sense of the physics system, rather than in the sense of SGE collision detection.
Arguments:
See the documentation for sge.dsp.Object.event_collision() for more information.
Called when the right side of the collider collides with a wall or slope in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for xsge_physics.Collider.event_physics_collision_left() for more information.
Called when the top side of the collider collides with a wall or slope in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for xsge_physics.Collider.event_physics_collision_left() for more information.
Called when the bottom side of the collider collides with a wall or slope in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for xsge_physics.Collider.event_physics_collision_left() for more information.
Class for walls which stop movement of Collider objects from the top.
Class for walls which stop movement of Collider objects from the right.
Called when the right side of the wall collides with a collider in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for sge.dsp.Object.event_collision() for more information.
Class for walls which stop movement of Collider objects from the top.
Class for walls which stop movement of Collider objects from the bottom.
Called when the bottom side of the wall collides with a collider in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for sge.dsp.Object.event_collision() for more information.
Inherits SolidLeft, SolidRight, SolidTop, and SolidBottom. Meant to be a convenient parent class for walls that should stop movement in all directions.
Called when the left side of the wall collides with a collider in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for sge.dsp.Object.event_collision() for more information.
Called when the right side of the wall collides with a collider in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for sge.dsp.Object.event_collision() for more information.
Called when the top side of the wall collides with a collider in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for sge.dsp.Object.event_collision() for more information.
Called when the bottom side of the wall collides with a collider in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for sge.dsp.Object.event_collision() for more information.
A parent class for slopes which point in some direction upwards and to the left.
Slopes of this type go from the bottom-left corner to the top-right corner of the bounding box.
If set to True, a collider that moves to the left while touching the top side of the slope will attempt to keep touching the top side of the slope by moving downward, unless the collider’s nonstick_bottom value is True.
Default value: False
If set to True, a collider that moves upward while touching the left side of the slope will attempt to keep touching the left side of the slope by moving to the right, unless the collider’s nonstick_right value is True.
Default value: False
Called when the left side of the slope collides with a collider in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for sge.dsp.Object.event_collision() for more information.
Called when the top side of the slope collides with a collider in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for sge.dsp.Object.event_collision() for more information.
A parent class for slopes which point in some direction upwards and to the right.
Slopes of this type go from the top-left corner to the bottom-right corner of the bounding box.
If set to True, a collider that moves to the right while touching the top side of the slope will attempt to keep touching the top side of the slope by moving downward, unless the collider’s nonstick_bottom value is True.
Default value: False
If set to True, a collider that moves upward while touching the right side of the slope will attempt to keep touching the right side of the slope by moving to the left, unless the collider’s nonstick_left value is True.
Default value: False
Called when the right side of the slope collides with a collider in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for sge.dsp.Object.event_collision() for more information.
Called when the top side of the slope collides with a collider in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for sge.dsp.Object.event_collision() for more information.
A parent class for slopes which point in some direction upwards and to the left.
Slopes of this type go from the top-left corner to the bottom-right corner of the bounding box.
If set to True, a collider that moves to the left while touching the bottom side of the slope will attempt to keep touching the bottom side of the slope by moving upward, unless the collider’s nonstick_top value is True.
Default value: False
If set to True, a collider that moves downward while touching the left side of the slope will attempt to keep touching the left side of the slope by moving to the right, unless the collider’s nonstick_right value is True.
Default value: False
Called when the left side of the slope collides with a collider in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for sge.dsp.Object.event_collision() for more information.
Called when the bottom side of the slope collides with a collider in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for sge.dsp.Object.event_collision() for more information.
A parent class for slopes which point in some direction upwards and to the right.
Slopes of this type go from the bottom-left corner to the top-right corner of the bounding box.
If set to True, a collider that moves to the right while touching the bottom side of the slope will attempt to keep touching the bottom side of the slope by moving upward, unless the collider’s nonstick_top value is True.
Default value: False
If set to True, a collider that moves downward while touching the right side of the slope will attempt to keep touching the right side of the slope by moving to the right, unless the collider’s nonstick_left value is True.
Default value: False
Called when the right side of the slope collides with a collider in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for sge.dsp.Object.event_collision() for more information.
Called when the bottom side of the slope collides with a collider in the sense of the physics system, rather than in the sense of SGE collision detection. See the documentation for sge.dsp.Object.event_collision() for more information.
A parent class for walls and slopes that can move. When an object of this class moves, it “pushes” any appropriate colliders, as a real wall might be expected to do.
Note
For classes derived from this class to be useful, they also need to inherit one or more of the other wall classes. Objects of this class that are not also objects of other classes will naturally not collide.
Note
This class depends on use of MobileWall.move_x() and MobileWall.move_y() to handle physics interactions. event_update_position() uses these methods, so speed attributes will work properly, but changing x and y manually will not cause any physics to occur.
If set to True, the wall will push any colliders collided with as a result of the wall’s movement to the left. Otherwise, the wall will pass through such colliders.
Default value: True
If set to True, the wall will push any colliders collided with as a result of the wall’s movement to the right. Otherwise, the wall will pass through such colliders.
Default value: True
If set to True, the wall will push any colliders collided with as a result of the wall’s movement upwards. Otherwise, the wall will pass through such colliders.
Default value: True
If set to True, the wall will push any colliders collided with as a result of the wall’s movement downwards. Otherwise, the wall will pass through such colliders.
Default value: True
If set to True, any colliders touching the left side of the wall will move along with it, regardless of the direction of movement, with the exception of colliders whose nonstick_right values are True.
Default value: False
If set to True, any colliders touching the right side of the wall will move along with it, regardless of the direction of movement, with the exception of colliders whose nonstick_left values are True.
Default value: False
If set to True, any colliders touching the top side of the wall will move along with it, regardless of the direction of movement, with the exception of colliders whose nonstick_bottom values are True.
Default value: False
If set to True, any colliders touching the bottom side of the wall will move along with it, regardless of the direction of movement, with the exception of colliders whose nonstick_top values are True.
Default value: False
Return a list of Collider objects which are “stuck” to this wall (i.e. will move along with the wall regardless of direction).
A parent class for mobile walls that are also colliders. See the documentation for xsge_physics.Collider and xsge_physics.MobileWall for more information.
Note
Due to the way movement is implemented in this class, it is not safe to move this object during its collision events. Doing so may cause colliders that should be stuck to this object to become un-stuck, or cause this object to pass through colliders it should be pushing.