Go で書き直した Ikemen
Revision | d3d8ea78a34d1f81f4c434cae1fd0952f47ef3ff (tree) |
---|---|
Zeit | 2018-10-03 19:19:43 |
Autor | neatunsou <sisiy4excite@gmai...> |
Commiter | neatunsou |
Zoomdeltaに対応。
Maskwindowに対応。
Windowのズームアウト時の挙動をMUGEN1.1に合わせた。
ステージdefに新パラメータを追加した。
@@ -83,36 +83,41 @@ func (bga *bgAction) action() { | ||
83 | 83 | } |
84 | 84 | |
85 | 85 | type backGround struct { |
86 | - anim Animation | |
87 | - bga bgAction | |
88 | - id int32 | |
89 | - start [2]float32 | |
90 | - xofs float32 | |
91 | - camstartx float32 | |
92 | - delta [2]float32 | |
93 | - xscale [2]float32 | |
94 | - rasterx [2]float32 | |
95 | - yscalestart float32 | |
96 | - yscaledelta float32 | |
97 | - actionno int32 | |
98 | - startv [2]float32 | |
99 | - startrad [2]float32 | |
100 | - startsint [2]int32 | |
101 | - startsinlt [2]int32 | |
102 | - visible bool | |
103 | - active bool | |
104 | - positionlink bool | |
105 | - toplayer bool | |
106 | - startrect [4]int32 | |
107 | - windowdelta [2]float32 | |
108 | - scalestart [2]float32 | |
109 | - scaledelta [2]float32 | |
86 | + anim Animation | |
87 | + bga bgAction | |
88 | + id int32 | |
89 | + start [2]float32 | |
90 | + xofs float32 | |
91 | + camstartx float32 | |
92 | + delta [2]float32 | |
93 | + xscale [2]float32 | |
94 | + rasterx [2]float32 | |
95 | + yscalestart float32 | |
96 | + yscaledelta float32 | |
97 | + actionno int32 | |
98 | + startv [2]float32 | |
99 | + startrad [2]float32 | |
100 | + startsint [2]int32 | |
101 | + startsinlt [2]int32 | |
102 | + visible bool | |
103 | + active bool | |
104 | + positionlink bool | |
105 | + toplayer bool | |
106 | + autoresizeparallax bool | |
107 | + notmaskwindow int32 | |
108 | + startrect [4]int32 | |
109 | + windowdelta [2]float32 | |
110 | + scalestart [2]float32 | |
111 | + scaledelta [2]float32 | |
112 | + zoomdelta [2]float32 | |
113 | + zoomscaledelta [2]float32 | |
114 | + xbottomzoomdelta float32 | |
110 | 115 | } |
111 | 116 | |
112 | 117 | func newBackGround(sff *Sff) *backGround { |
113 | - return &backGround{anim: *newAnimation(sff), delta: [...]float32{1, 1}, | |
114 | - xscale: [...]float32{1, 1}, rasterx: [...]float32{1, 1}, yscalestart: 100, scalestart: [...]float32{1, 1}, | |
115 | - actionno: -1, visible: true, active: true, | |
118 | + return &backGround{anim: *newAnimation(sff), delta: [...]float32{1, 1}, zoomdelta: [...]float32{math.MaxFloat32, math.MaxFloat32}, | |
119 | + xscale: [...]float32{1, 1}, rasterx: [...]float32{1, 1}, yscalestart: 100, scalestart: [...]float32{1, 1}, xbottomzoomdelta: math.MaxFloat32, | |
120 | + zoomscaledelta: [...]float32{1, 1}, actionno: -1, visible: true, active: true, autoresizeparallax: true, | |
116 | 121 | startrect: [...]int32{-32768, -32768, 65535, 65535}} |
117 | 122 | } |
118 | 123 | func readBackGround(is IniSection, link *backGround, |
@@ -161,10 +166,17 @@ func readBackGround(is IniSection, link *backGround, | ||
161 | 166 | bg.startv = link.startv |
162 | 167 | bg.delta = link.delta |
163 | 168 | } |
169 | + is.ReadBool("autoresizeparallax", &bg.autoresizeparallax) | |
164 | 170 | is.readF32ForStage("start", &bg.start[0], &bg.start[1]) |
165 | 171 | is.readF32ForStage("delta", &bg.delta[0], &bg.delta[1]) |
166 | 172 | is.readF32ForStage("scalestart", &bg.scalestart[0], &bg.scalestart[1]) |
167 | 173 | is.readF32ForStage("scaledelta", &bg.scaledelta[0], &bg.scaledelta[1]) |
174 | + is.readF32ForStage("xbottomzoomdelta", &bg.xbottomzoomdelta) | |
175 | + is.readF32ForStage("zoomscaledelta", &bg.zoomscaledelta[0], &bg.zoomscaledelta[1]) | |
176 | + is.readF32ForStage("zoomdelta", &bg.zoomdelta[0], &bg.zoomdelta[1]) | |
177 | + if bg.zoomdelta[0] != math.MaxFloat32 && bg.zoomdelta[1] == math.MaxFloat32 { | |
178 | + bg.zoomdelta[1] = bg.zoomdelta[0] | |
179 | + } | |
168 | 180 | if t != 1 { |
169 | 181 | if is.ReadI32("mask", &tmp) { |
170 | 182 | if tmp != 0 { |
@@ -250,6 +262,13 @@ func readBackGround(is IniSection, link *backGround, | ||
250 | 262 | &bg.startrect[2], &bg.startrect[3]) { |
251 | 263 | bg.startrect[2] = Max(0, bg.startrect[2]+1-bg.startrect[0]) |
252 | 264 | bg.startrect[3] = Max(0, bg.startrect[3]+1-bg.startrect[1]) |
265 | + bg.notmaskwindow = 1 | |
266 | + } | |
267 | + if is.readI32ForStage("maskwindow", &bg.startrect[0], &bg.startrect[1], | |
268 | + &bg.startrect[2], &bg.startrect[3]) { | |
269 | + bg.startrect[2] = Max(0, bg.startrect[2]+1-bg.startrect[0]) | |
270 | + bg.startrect[3] = Max(0, bg.startrect[3]+1-bg.startrect[1]) | |
271 | + bg.notmaskwindow = 0 | |
253 | 272 | } |
254 | 273 | is.readF32ForStage("windowdelta", &bg.windowdelta[0], &bg.windowdelta[1]) |
255 | 274 | is.ReadI32("id", &bg.id) |
@@ -296,16 +315,30 @@ func (bg backGround) draw(pos [2]float32, scl, bgscl, lclscl float32, | ||
296 | 315 | xras := (bg.rasterx[1] - bg.rasterx[0]) / bg.rasterx[0] |
297 | 316 | xbs, dx := bg.xscale[1], MaxF(0, bg.delta[0]*bgscl) |
298 | 317 | sclx := MaxF(0, scl+(1-scl)*(1-dx)) |
318 | + scly := MaxF(0, scl+(1-scl)*(1-MaxF(0, bg.delta[1]*bgscl))) | |
319 | + var sclx_recip float32 = 1 | |
299 | 320 | lscl := [...]float32{lclscl * stgscl[0], lclscl * stgscl[1]} |
300 | - if sclx != 0 { | |
321 | + if sclx != 0 && bg.autoresizeparallax == true { | |
301 | 322 | tmp := 1 / sclx |
302 | - xbs *= MaxF(0, scl+(1-scl)*(1-dx*(xbs/bg.xscale[0]))) * tmp | |
323 | + if bg.xbottomzoomdelta != math.MaxFloat32 { | |
324 | + xbs *= MaxF(0, scl+(1-scl)*(1-bg.xbottomzoomdelta*(xbs/bg.xscale[0]))) * tmp | |
325 | + } else { | |
326 | + xbs *= MaxF(0, scl+(1-scl)*(1-dx*(xbs/bg.xscale[0]))) * tmp | |
327 | + } | |
303 | 328 | tmp *= MaxF(0, scl+(1-scl)*(1-dx*(xras+1))) |
304 | 329 | xras -= tmp - 1 |
305 | 330 | xbs *= tmp |
306 | 331 | } |
332 | + if bg.zoomdelta[0] != math.MaxFloat32 { | |
333 | + sclx = scl + (1-scl)*(1-bg.zoomdelta[0]) | |
334 | + scly = scl + (1-scl)*(1-bg.zoomdelta[1]) | |
335 | + if bg.autoresizeparallax == false { | |
336 | + sclx_recip = (1 + bg.zoomdelta[0]*((1/(sclx*lscl[0])*lscl[0])-1)) | |
337 | + } | |
338 | + } | |
339 | + | |
340 | + scly *= lclscl | |
307 | 341 | sclx *= lscl[0] |
308 | - scly := MaxF(0, scl+(1-scl)*(1-MaxF(0, bg.delta[1]*bgscl))) * lclscl | |
309 | 342 | x := bg.start[0] + bg.xofs - (pos[0]/stgscl[0]+bg.camstartx)*bg.delta[0] + |
310 | 343 | bg.bga.offset[0] |
311 | 344 | y := bg.start[1] - (pos[1]/stgscl[1])*bg.delta[1] + bg.bga.offset[1] |
@@ -320,27 +353,34 @@ func (bg backGround) draw(pos [2]float32, scl, bgscl, lclscl float32, | ||
320 | 353 | } |
321 | 354 | ys := (100 - pos[1]*bg.yscaledelta) * bgscl / bg.yscalestart |
322 | 355 | ys2 := bg.scaledelta[1] * pos[1] * bg.delta[1] * bgscl |
323 | - xs := bg.scaledelta[0] * pos[0] * dx | |
356 | + xs := bg.scaledelta[0] * pos[0] * bg.delta[0] * bgscl | |
357 | + xs3 := 1 + (1-scl)*(1-bg.zoomscaledelta[0]) | |
358 | + ys3 := 1 + (1-scl)*(1-bg.zoomscaledelta[1]) | |
324 | 359 | x *= bgscl |
325 | 360 | y = y*bgscl + ((float32(sys.gameHeight)-shakeY)/scly-240)/stgscl[1] |
326 | 361 | scly *= stgscl[1] |
327 | 362 | rect := bg.startrect |
328 | 363 | var wscl [2]float32 |
329 | 364 | for i := range wscl { |
330 | - wscl[i] = MaxF(0, scl+(1-scl)*(1-MaxF(0, bg.windowdelta[i]*bgscl))) * | |
331 | - bgscl * lscl[i] | |
365 | + if bg.zoomdelta[i] != math.MaxFloat32 { | |
366 | + wscl[i] = MaxF(0, scl+(1-scl)*(1-MaxF(0, bg.zoomdelta[i]))) * | |
367 | + bgscl * lscl[i] | |
368 | + } else { | |
369 | + wscl[i] = MaxF(0, scl+(1-scl)*(1-MaxF(0, bg.windowdelta[i]*bgscl))) * | |
370 | + bgscl * lscl[i] | |
371 | + } | |
332 | 372 | } |
333 | 373 | rect[0] = int32(math.Floor(float64((float32(rect[0]) - |
334 | - (pos[0]+bg.camstartx)*bg.windowdelta[0]) * sys.widthScale * wscl[0]))) | |
374 | + (pos[0]+bg.camstartx)*bg.windowdelta[0] + (float32(sys.gameWidth)/2/sclx - float32(bg.notmaskwindow)*160*(1/lscl[0]))) * sys.widthScale * wscl[0]))) | |
335 | 375 | rect[1] = int32(math.Floor(float64(((float32(rect[1])- |
336 | - pos[1]*bg.windowdelta[1])*wscl[1] - shakeY + float32(sys.gameHeight-240)) * | |
376 | + pos[1]*bg.windowdelta[1]+(float32(sys.gameHeight)/scly-240))*wscl[1] - shakeY) * | |
337 | 377 | sys.heightScale))) |
338 | 378 | rect[2] = int32(math.Ceil(float64(float32(rect[2]) * sys.widthScale * |
339 | 379 | wscl[0]))) |
340 | 380 | rect[3] = int32(math.Ceil(float64(float32(rect[3]) * sys.heightScale * |
341 | 381 | wscl[1]))) |
342 | - bg.anim.Draw(&rect, x, y, sclx, scly, bg.xscale[0]*bgscl*(bg.scalestart[0]+xs), xbs*bgscl*(bg.scalestart[0]+xs), ys*(bg.scalestart[1]+ys2), | |
343 | - xras*x/(AbsF(ys)*lscl[1]*float32(bg.anim.spr.Size[1])), | |
382 | + bg.anim.Draw(&rect, x, y, sclx, scly, bg.xscale[0]*bgscl*(bg.scalestart[0]+xs)*xs3, xbs*bgscl*(bg.scalestart[0]+xs)*xs3, ys*(bg.scalestart[1]+ys2)*ys3, | |
383 | + xras*x/(AbsF(ys*ys3)*lscl[1]*float32(bg.anim.spr.Size[1]))*sclx_recip, | |
344 | 384 | 0, float32(sys.gameWidth)/2, &sys.bgPalFX, true) |
345 | 385 | } |
346 | 386 |