Go で書き直した Ikemen
修订版 | 64217da22f9d544da260847fb1ed83b9548299cf (tree) |
---|---|
时间 | 2018-09-03 18:56:20 |
作者 | suehiro <supersuehiro@user...> |
Commiter | suehiro |
プルリクエストのマージ
683e7efc622e824be9defcece2785b592a6d394f
Fixed addalpha trans on stages
6e8a56e97979722e1a9ed91e1c7a64ccc4c0f9c4
Scalestartに対応。trans = addだとaddalphaを読み込まないのを修正。
@@ -105,11 +105,12 @@ type backGround struct { | ||
105 | 105 | toplayer bool |
106 | 106 | startrect [4]int32 |
107 | 107 | windowdelta [2]float32 |
108 | + scalestart [2]float32 | |
108 | 109 | } |
109 | 110 | |
110 | 111 | func newBackGround(sff *Sff) *backGround { |
111 | 112 | return &backGround{anim: *newAnimation(sff), delta: [...]float32{1, 1}, |
112 | - xscale: [...]float32{1, 1}, rasterx: [...]float32{1, 1}, yscalestart: 100, | |
113 | + xscale: [...]float32{1, 1}, rasterx: [...]float32{1, 1}, yscalestart: 100, scalestart: [...]float32{1, 1}, | |
113 | 114 | actionno: -1, visible: true, active: true, |
114 | 115 | startrect: [...]int32{-32768, -32768, 65535, 65535}} |
115 | 116 | } |
@@ -161,6 +162,7 @@ func readBackGround(is IniSection, link *backGround, | ||
161 | 162 | } |
162 | 163 | is.readF32ForStage("start", &bg.start[0], &bg.start[1]) |
163 | 164 | is.readF32ForStage("delta", &bg.delta[0], &bg.delta[1]) |
165 | + is.readF32ForStage("scalestart", &bg.scalestart[0], &bg.scalestart[1]) | |
164 | 166 | if t != 1 { |
165 | 167 | if is.ReadI32("mask", &tmp) { |
166 | 168 | if tmp != 0 { |
@@ -174,6 +176,14 @@ func readBackGround(is IniSection, link *backGround, | ||
174 | 176 | bg.anim.mask = 0 |
175 | 177 | bg.anim.srcAlpha = 255 |
176 | 178 | bg.anim.dstAlpha = 255 |
179 | + s, d := int32(bg.anim.srcAlpha), int32(bg.anim.dstAlpha) | |
180 | + if is.readI32ForStage("alpha", &s, &d) { | |
181 | + bg.anim.srcAlpha = int16(Max(0, Min(255, s))) | |
182 | + bg.anim.dstAlpha = int16(Max(0, Min(255, d))) | |
183 | + if bg.anim.srcAlpha == 1 && bg.anim.dstAlpha == 255 { | |
184 | + bg.anim.srcAlpha = 0 | |
185 | + } | |
186 | + } | |
177 | 187 | case "add1": |
178 | 188 | bg.anim.mask = 0 |
179 | 189 | bg.anim.srcAlpha = 255 |
@@ -181,14 +191,14 @@ func readBackGround(is IniSection, link *backGround, | ||
181 | 191 | var s, d int32 = 255, 255 |
182 | 192 | if is.readI32ForStage("alpha", &s, &d) { |
183 | 193 | bg.anim.srcAlpha = int16(Min(255, s)) |
184 | - bg.anim.dstAlpha = ^int16(Max(0, Min(255, s))) | |
194 | + bg.anim.dstAlpha = ^int16(Max(0, Min(255, d))) | |
185 | 195 | } |
186 | 196 | case "addalpha": |
187 | 197 | bg.anim.mask = 0 |
188 | 198 | s, d := int32(bg.anim.srcAlpha), int32(bg.anim.dstAlpha) |
189 | 199 | if is.readI32ForStage("alpha", &s, &d) { |
190 | - bg.anim.srcAlpha = int16(Min(255, s)) | |
191 | - bg.anim.dstAlpha = int16(Max(0, Min(255, s))) | |
200 | + bg.anim.srcAlpha = int16(Max(0, Min(255, s))) | |
201 | + bg.anim.dstAlpha = int16(Max(0, Min(255, d))) | |
192 | 202 | if bg.anim.srcAlpha == 1 && bg.anim.dstAlpha == 255 { |
193 | 203 | bg.anim.srcAlpha = 0 |
194 | 204 | } |
@@ -325,7 +335,7 @@ func (bg backGround) draw(pos [2]float32, scl, bgscl, lclscl float32, | ||
325 | 335 | wscl[0]))) |
326 | 336 | rect[3] = int32(math.Ceil(float64(float32(rect[3]) * sys.heightScale * |
327 | 337 | wscl[1]))) |
328 | - bg.anim.Draw(&rect, x, y, sclx, scly, bg.xscale[0]*bgscl, xbs*bgscl, ys, | |
338 | + bg.anim.Draw(&rect, x, y, sclx, scly, bg.xscale[0]*bgscl*bg.scalestart[0], xbs*bgscl*bg.scalestart[0], ys*bg.scalestart[1], | |
329 | 339 | xras*x/(AbsF(ys)*lscl[1]*float32(bg.anim.spr.Size[1])), |
330 | 340 | 0, float32(sys.gameWidth)/2, &sys.bgPalFX, true) |
331 | 341 | } |