jjOBJ class
A level object (actor) controllable from scripts.
Reference-counted script view of an in-level object (enemy, pickup, projectile, etc.), mirroring the original JJ2+ jjOBJ. Exposes position, speed, acceleration, animation, energy, lighting and the handling flags that govern collisions with players, bullets and blasts, plus its jjBEHAVIOR. Static helpers spawn, delete and kill objects; live ones are reached through jjObjects[id].
Public static functions
-
static auto jjAddObject(std::
uint8_t eventID, float xPixel, float yPixel, std:: uint16_t creatorID, std:: uint32_t creatorType, std:: uint32_t behavior) -> std:: int32_t - Spawns a new object with a built-in behavior and returns its object id.
-
static auto jjAddObjectEx(std::
uint8_t eventID, float xPixel, float yPixel, std:: uint16_t creatorID, std:: uint32_t creatorType, jjVOIDFUNCOBJ behavior) -> std:: int32_t - Spawns a new object with a custom behavior function and returns its object id.
-
static void jjDeleteObject(std::
int32_t objectID) - Deletes the object with the given id.
-
static void jjKillObject(std::
int32_t objectID) - Kills the object with the given id.
Constructors, destructors, conversion operators
Public functions
- void AddRef()
- Increments the reference count.
- void Release()
- Decrements the reference count.
- auto get_isActive() const -> bool
- Returns whether the object is currently active.
-
auto get_lightType() const -> std::
uint32_t - Returns the light type emitted by the object.
-
auto set_lightType(std::
uint32_t value) const -> std:: uint32_t - Sets the light type emitted by the object.
-
auto objectHit(jjOBJ* target,
std::
uint32_t playerHandling) -> jjOBJ* - Handles a collision against the target object and returns the object that was hit.
-
void blast(std::
int32_t maxDistance, bool blastObjects) - Destroys nearby objects (and optionally tiles) within the given distance.
-
void behave1(std::
uint32_t behavior, bool draw) - Runs the given built-in behavior id once, optionally drawing the object.
- void behave2(jjBEHAVIOR behavior, bool draw)
- Runs the given behavior once, optionally drawing the object.
- void behave3(jjVOIDFUNCOBJ behavior, bool draw)
- Runs the given behavior function once, optionally drawing the object.
-
auto determineCurFrame(bool change) -> std::
uint32_t - Advances and returns the current animation frame, optionally changing it.
-
auto get_creatorID() const -> std::
uint16_t - Returns the id of the object that created this one.
-
auto set_creatorID(std::
uint16_t value) const -> std:: uint16_t - Sets the id of the object that created this one.
-
auto get_creatorType() const -> std::
uint32_t - Returns the type of the creator.
-
auto set_creatorType(std::
uint32_t value) const -> std:: uint32_t - Sets the type of the creator.
-
auto determineCurAnim(std::
uint8_t setID, std:: uint8_t animation, bool change) -> int16_t - Selects and returns the current animation, optionally changing it.
-
auto get_bulletHandling() -> std::
uint32_t - Returns how the object responds to bullets.
-
auto set_bulletHandling(std::
uint32_t value) -> std:: uint32_t - Sets how the object responds to bullets.
- auto get_ricochet() -> bool
- Returns whether bullets ricochet off the object.
- auto set_ricochet(bool value) -> bool
- Sets whether bullets ricochet off the object.
- auto get_freezable() -> bool
- Returns whether the object can be frozen.
- auto set_freezable(bool value) -> bool
- Sets whether the object can be frozen.
- auto get_blastable() -> bool
- Returns whether the object can be destroyed by a blast.
- auto set_blastable(bool value) -> bool
- Sets whether the object can be destroyed by a blast.
-
auto get_playerHandling() -> std::
uint32_t - Returns how the object responds to player contact.
-
auto set_playerHandling(std::
uint32_t value) -> std:: uint32_t - Sets how the object responds to player contact.
- auto get_isTarget() -> bool
- Returns whether the object can be targeted.
- auto set_isTarget(bool value) -> bool
- Sets whether the object can be targeted.
- auto get_triggersTNT() -> bool
- Returns whether the object triggers nearby TNT.
- auto set_triggersTNT(bool value) -> bool
- Sets whether the object triggers nearby TNT.
- auto get_deactivates() -> bool
- Returns whether the object deactivates when off screen.
- auto set_deactivates(bool value) -> bool
- Sets whether the object deactivates when off screen.
- auto get_scriptedCollisions() -> bool
- Returns whether collisions are handled by the script.
- auto set_scriptedCollisions(bool value) -> bool
- Sets whether collisions are handled by the script.
-
auto get_var(std::
uint8_t x) -> std:: int32_t - Returns the value of a custom per-object variable.
-
auto set_var(std::
uint8_t x, std:: int32_t value) -> std:: int32_t - Sets the value of a custom per-object variable.
-
auto draw() -> std::
int32_t - Draws the object this frame.
-
auto beSolid(bool shouldCheckForStompingLocalPlayers) -> std::
int32_t - Makes the object behave as a solid obstacle.
-
void bePlatform(float xOld,
float yOld,
std::
int32_t width, std:: int32_t height) - Makes the object behave as a moving platform.
- void clearPlatform()
- Stops the object from acting as a platform.
- void putOnGround(bool precise)
- Snaps the object onto the ground below it.
- auto ricochet() -> bool
- Bounces the object as a ricocheting bullet.
-
auto unfreeze(std::
int32_t style) -> std:: int32_t - Unfreezes the object with the given shatter style.
- void deleteObject()
- Removes the object from the level.
- void deactivate()
- Deactivates the object.
- void pathMovement()
- Advances the object along its predefined path.
-
auto fireBullet(std::
uint8_t eventID) -> std:: int32_t - Fires a bullet from the object and returns the new bullet's id.
-
void particlePixelExplosion(std::
int32_t style) - Spawns a pixel-explosion particle effect for the object.
-
void grantPickup(jjPLAYER* player,
std::
int32_t frequency) - Grants the object as a pickup to the given player.
-
auto findNearestPlayer(std::
int32_t maxDistance) const -> std:: int32_t - Returns the id of the nearest player within the given distance.
-
auto findNearestPlayerEx(std::
int32_t maxDistance, std:: int32_t& foundDistance) const -> std:: int32_t - Returns the id of the nearest player within the given distance and outputs the distance.
- auto doesCollide(const jjOBJ* object, bool always) const -> bool
- Returns whether this object collides with another object.
- auto doesCollidePlayer(const jjPLAYER* object, bool always) const -> bool
- Returns whether this object collides with the given player.
Public variables
- jjBEHAVIOR behavior
- The behavior driving this object each frame.
- float xOrg
- Original (spawn) horizontal position in pixels.
- float yOrg
- Original (spawn) vertical position in pixels.
- float xPos
- Current horizontal position in pixels.
- float yPos
- Current vertical position in pixels.
- float xSpeed
- Horizontal speed in pixels per frame.
- float ySpeed
- Vertical speed in pixels per frame.
- float xAcc
- Horizontal acceleration in pixels per frame.
- float yAcc
- Vertical acceleration in pixels per frame.
-
std::
int32_t counter - General-purpose counter used by behaviors.
-
std::
uint32_t curFrame - Current sprite frame index.
-
std::
int32_t age - Number of frames the object has existed.
-
std::
int32_t creator - Object id of the creator.
- int16_t curAnim
- Current animation index.
-
std::
uint16_t killAnim - Animation played when the object is killed.
-
std::
uint8_t freeze - Number of frames the object remains frozen.
-
std::
uint8_t lightType - Light type emitted by the object.
-
std::
int8_t frameID - Current frame id within the animation.
-
std::
int8_t noHit - Number of frames during which the object cannot be hit.
-
std::
int8_t energy - Remaining health of the object.
-
std::
int8_t light - Brightness of the light emitted by the object.
-
std::
uint8_t objType - Object category/type.
-
std::
int8_t state - Current behavior state.
-
std::
uint16_t points - Score points awarded when the object is destroyed.
-
std::
uint8_t eventID - Event id the object was spawned from.
-
std::
int8_t direction - Facing direction of the object.
-
std::
uint8_t justHit - Number of frames since the object was last hit.
-
std::
int8_t oldState - Previous behavior state.
-
std::
int32_t animSpeed - Animation playback speed.
-
std::
int32_t special - General-purpose value used by behaviors.
-
std::
uint8_t doesHurt - Amount of damage the object deals on contact.
-
std::
uint8_t counterEnd - Counter value at which the object's counter is considered complete.
-
std::
int16_t objectID - Unique id of the object.