Skip to content

Commit

Permalink
Stage [Shadow] xshear support (missing mugen feature)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazin3ss committed Aug 9, 2022
1 parent f86abaf commit 657d73b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/anim.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ func (a *Animation) Draw(window *[4]int32, x, y, xcs, ycs, xs, xbs, ys,
}
RenderSprite(rp)
}
func (a *Animation) ShadowDraw(window *[4]int32, x, y, xscl, yscl, vscl float32, rot Rotation,
func (a *Animation) ShadowDraw(window *[4]int32, x, y, xscl, yscl, vscl, rxadd float32, rot Rotation,
pfx *PalFX, old bool, color uint32, alpha int32, facing float32, posLocalscl float32, projectionMode int32, fLength float32) {
if a.spr == nil || a.spr.Tex == nil {
return
Expand All @@ -740,7 +740,7 @@ func (a *Animation) ShadowDraw(window *[4]int32, x, y, xscl, yscl, vscl float32,
AbsF(xscl*h) * float32(a.spr.Offset[0]) * sys.widthScale,
AbsF(yscl*v) * float32(a.spr.Offset[1]) * sys.heightScale, a.tile,
xscl * h * sys.widthScale, xscl * h * sys.widthScale,
yscl * v * sys.heightScale, vscl, 0, rot, 0, int32(a.mask), nil, window,
yscl * v * sys.heightScale, vscl, rxadd, rot, 0, int32(a.mask), nil, window,
(x + float32(sys.gameWidth)/2) * sys.widthScale, y * sys.heightScale,
projectionMode, fLength,
xscl * posLocalscl * h * (float32(a.frames[a.drawidx].X) + a.interpolate_offset_x) * (1 / a.scale_x),
Expand Down Expand Up @@ -971,6 +971,11 @@ func (sl ShadowList) draw(x, y, scl float32) {
}
color = color&0xff*alpha<<8&0xff0000 |
color&0xff00*alpha>>8&0xff00 | color&0xff0000*alpha>>24&0xff
xshear := sys.stage.sdw.xshear
if sys.stage.sdw.yscale > 0 {
xshear = -xshear
}
xshearoff := -sys.stage.sdw.xshear*(float32(s.anim.spr.Size[1])*sys.stage.localscl-s.pos[1])
if s.window[0] != 0 || s.window[1] != 0 || s.window[2] != 0 || s.window[3] != 0 {
w := s.window
w[1], w[3] = -w[1], -w[3]
Expand All @@ -982,20 +987,20 @@ func (sl ShadowList) draw(x, y, scl float32) {
}
var window [4]int32

window[0] = int32((sys.cam.Offset[0] - ((x - s.pos[0]) * scl) + w[0]*scl + float32(sys.gameWidth)/2) * sys.widthScale)
window[0] = int32((sys.cam.Offset[0] - ((x - s.pos[0] - xshearoff) * scl) + w[0]*scl + float32(sys.gameWidth)/2) * sys.widthScale)
window[1] = int32((sys.cam.GroundLevel() + sys.cam.Offset[1] - sys.envShake.getOffset() - (y+s.pos[1]*sys.stage.sdw.yscale-s.offsetY)*scl + w[1]*sys.stage.sdw.yscale*scl) * sys.heightScale)
window[2] = int32(scl * (w[2] - w[0]) * sys.widthScale)
window[3] = int32(scl * (w[3] - w[1]) * sys.heightScale * sys.stage.sdw.yscale)
s.anim.ShadowDraw(&window, sys.cam.Offset[0]-(x-s.pos[0])*scl,
s.anim.ShadowDraw(&window, sys.cam.Offset[0]-(x-s.pos[0]-xshearoff)*scl,
sys.cam.GroundLevel()+sys.cam.Offset[1]-sys.envShake.getOffset()-
(y+s.pos[1]*sys.stage.sdw.yscale-s.offsetY)*scl,
scl*s.scl[0], scl*-s.scl[1], sys.stage.sdw.yscale, s.rot,
scl*s.scl[0], scl*-s.scl[1], sys.stage.sdw.yscale, xshear, s.rot,
&sys.bgPalFX, s.oldVer, uint32(color), intensity, s.facing, s.posLocalscl, s.projection, s.fLength)
} else {
s.anim.ShadowDraw(&sys.scrrect, sys.cam.Offset[0]-(x-s.pos[0])*scl,
s.anim.ShadowDraw(&sys.scrrect, sys.cam.Offset[0]-(x-s.pos[0]-xshearoff)*scl,
sys.cam.GroundLevel()+sys.cam.Offset[1]-sys.envShake.getOffset()-
(y+s.pos[1]*sys.stage.sdw.yscale-s.offsetY)*scl,
scl*s.scl[0], scl*-s.scl[1], sys.stage.sdw.yscale, s.rot,
scl*s.scl[0], scl*-s.scl[1], sys.stage.sdw.yscale, xshear, s.rot,
&sys.bgPalFX, s.oldVer, uint32(color), intensity, s.facing, s.posLocalscl, s.projection, s.fLength)
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ type stageShadow struct {
yscale float32
fadeend int32
fadebgn int32
xshear float32
}
type stagePlayer struct {
startx, starty, startz int32
Expand Down Expand Up @@ -843,6 +844,7 @@ func loadStage(def string, main bool) (*Stage, error) {
sec[0].ReadF32("yscale", &s.sdw.yscale)
sec[0].ReadBool("reflect", &reflect)
sec[0].readI32ForStage("fade.range", &s.sdw.fadeend, &s.sdw.fadebgn)
sec[0].ReadF32("xshear", &s.sdw.xshear)
}
if reflect {
if sec := defmap["reflection"]; len(sec) > 0 {
Expand Down

0 comments on commit 657d73b

Please sign in to comment.