Register FAQ Search Today's Posts Mark Forums Read
Go Back   JazzJackrabbit Community Forums » Maintenance & Feedback » JJ2+ Issue Tracker

Feature Request a new onDraw variant for jjBEHAVIORINTERFACE

Zah dud4h

JCF Member

Joined: Dec 2014

Posts: 30

Zah dud4h is doing well so far

Apr 26, 2025, 01:31 PM
Zah dud4h is offline
Reply With Quote
a new onDraw variant for jjBEHAVIORINTERFACE

Unsure how the onDraw(jjOBJ@ obj) hook works internally and if it's possible to have a variant that accepts a second parameter of "jjPLAYER@ play" so you can specify how differently it should draw for a specific player, similar to how the PU blaster monitors and the fast fire pickups work

Example:
Quote:
void onDraw(jjOBJ@ obj,jjPLAYER@ play) {
if (play.currChar == CHAR::JAZZ) {
//draw the sprite for jazz
} else {
// draw the default sprite
}
}
__________________
.
Seren

JCF Member

Joined: Feb 2010

Posts: 872

Seren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to all

Apr 27, 2025, 03:11 AM
Seren is offline
Reply With Quote
All jjDraw* functions take an optional playerID argument that can be used to specify which player the sprite should be drawn for (the default of -1 denoting all). This already enables patterns such as
Code:
void onDraw(jjOBJ@ obj) {
    for (int i = 0; i < jjLocalPlayerCount; i++) {
        const auto@ player = jjLocalPlayers[i];
        // draw the sprite facing the player's direction instead of the object's
        jjDrawSpriteFromCurFrame(obj.xPos, obj.yPos, obj.curFrame,
                player.direction, playerID: player.playerID);
    }
}
The proposed overload couldn't really do anything more than move this loop outside of the function and into JJ2+ code - which we could do, but this use case comes up rarely enough that it would probably do more harm than good to provide a dedicated shorthand for it.
__________________

I am an official JJ2+ programmer and this has been an official JJ2+ statement.
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -8. The time now is 04:57 PM.