Added warped and scaled objects - #369
Open
turkballbredissus wants to merge 2 commits into
Open
Conversation
Levels built in 2.2 use per-axis scale and warp everywhere, and neither survived the trip into Web Dashers: 128/129 and 131/132 were not parsed at all, so a scaled or warped object loaded at its default size and rotation. Key 32 was parsed but only ever reached the sprite, never the hitbox. Parsing 128/129 are the two scale axes. 2.2 writes them instead of key 32, and writes them independently, so each falls back to 32 and 32 falls back to 1. 131/132 are the object's cocos2d rotationX and rotationY - what the editor calls warp. Equal values are an ordinary rotation, and 2.2 writes the pair INSTEAD of key 6, so the pair wins over key 6 rather than the reverse. They are stored as one rotation plus the spread between the axes, which keeps a warped object's warp when something later rotates it. Rendering Phaser builds a sprite matrix from rotation + scaleX + scaleY, three numbers that can only describe a rectangle. A warped object is a parallelogram, so a warped sprite holds an identity transform of its own and its render call is wrapped to pass the renderer a parent matrix with the real transform folded in. Tint, flip, blend mode, depth and origin are untouched, and the formula reduces to Phaser's own applyITRS when the two axis angles are equal. Hitboxes Solids, hazards, slopes, portals, pads, orbs, coins and speed portals all size from the object's scale now. Warp is deliberately not applied: in GD the hitbox stays a rectangle however far the sprite is sheared. Enter effects updateEnterEffects, updateAudioScale and the orb pulse animate a scale factor and used to write it straight onto the sprite, which assumed every object sits at scale 1 - so a scaled object snapped to full size the moment it entered the screen. This is why key 32 never visibly worked either. They multiply by the object's own scale now. Editor _serializeObject writes 128/129 and 131/132 back, and keeps old levels on key 32 and key 6 so they round-trip unchanged. Verified against level 22, which has 11,897 scaled and 487 warped objects, and against a purpose-built level covering each key alone and combined: a 45 degree turn written as key 6 and as 131/132 renders and collides identically, and every case survives a save/reload.
An object built from several sprites positions each part from a localDx/localDy in the object's own space. That offset was rotated with the object but not scaled or warped, so a scaled composite kept its parts at unscaled distances - the pieces sat too close together while each piece drew at the right size. 2576 of the 4082 objects are composites, so this covers most of the object set: portals, orbs, pads and every decorated block. The offset now goes through the same transform as the object. It reduces to the rotation that was there before at scale 1 with no warp, so unscaled objects are untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
this took me a "bit" but i got it working yay wohooo...
the fact that here wasnt any scaling in wd annoyed me so i did it myself ig
-TurkBall (me)