Go で書き直した Ikemen
Revisão | 150fe933407d67a972cd92c574632faa7888d97f (tree) |
---|---|
Hora | 2019-03-02 19:33:55 |
Autor | neatunsou <sisiy4excite@gmai...> |
Commiter | neatunsou |
mp3にリサンプル処理をしてなかったのを修正
animにtileを記述してなおかつtilespacingが0だとtileを無効にするようにした
アルファ入りpngの表示が微妙に暗くなっていたのを修正
Windblade氏の更新を適応
@@ -11,3 +11,5 @@ go get -u github.com/faiface/beep | ||
11 | 11 | go get -u github.com/hajimehoshi/oto |
12 | 12 | go get -u github.com/hajimehoshi/go-mp3 |
13 | 13 | go get -u github.com/pkg/errors |
14 | +go get -u github.com/jfreymuth/oggvorbis | |
15 | +go get -u github.com/mewkiz/flac |
@@ -75,8 +75,8 @@ func RenderInit() { | ||
75 | 75 | "texcoord[0] = left / (left + right);" + // ここまで |
76 | 76 | "}" + |
77 | 77 | "vec4 c = texture2D(tex, texcoord);" + |
78 | - "if(neg) c.rgb = vec3(1.0) - c.rgb;" + | |
79 | - "c.rgb += (vec3((c.r + c.g + c.b) / 3.0) - c.rgb) * gray + add;" + | |
78 | + "if(neg) c.rgb = vec3(1.0 * c.a) - c.rgb;" + | |
79 | + "c.rgb += (vec3((c.r + c.g + c.b) / 3.0) - c.rgb) * gray + add * c.a;" + | |
80 | 80 | "c.rgb *= mul;" + |
81 | 81 | "c.a *= a;" + |
82 | 82 | "gl_FragColor = c;" + |
@@ -359,7 +359,11 @@ func rmMainSub(a int32, size [2]uint16, x, y float32, tl *[4]int32, | ||
359 | 359 | agl, yagl, xagl, rcx, rcy) |
360 | 360 | case trans < 512: |
361 | 361 | gl.Uniform1fARB(a, 1) |
362 | - gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA) | |
362 | + if renderMode == 1 { | |
363 | + gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA) | |
364 | + } else { | |
365 | + gl.BlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA) | |
366 | + } | |
363 | 367 | gl.BlendEquation(gl.FUNC_ADD) |
364 | 368 | rmTileSub(size[0], size[1], x, y, tl, renderMode, xts, xbs, ys, vs, rxadd, |
365 | 369 | agl, yagl, xagl, rcx, rcy) |
@@ -313,13 +313,15 @@ func systemScriptInit(l *lua.LState) { | ||
313 | 313 | } |
314 | 314 | ts.text = strArg(l, 2) |
315 | 315 | return 0 |
316 | - }) | |
316 | + }) | |
317 | 317 | luaRegister(l, "textImgSetPos", func(*lua.LState) int { |
318 | 318 | ts, ok := toUserData(l, 1).(*TextSprite) |
319 | 319 | if !ok { |
320 | 320 | userDataError(l, 1, ts) |
321 | 321 | } |
322 | + if boolArg(l, 3) { | |
322 | 323 | ts.x, ts.y = float32((numArg(l, 2)/sys.luaSpriteScale)+sys.luaSpriteOffsetX), float32(numArg(l, 3)/sys.luaSpriteScale) |
324 | + } | |
323 | 325 | return 0 |
324 | 326 | }) |
325 | 327 | luaRegister(l, "textImgSetScale", func(*lua.LState) int { |
@@ -12,6 +12,7 @@ import ( | ||
12 | 12 | "github.com/timshannon/go-openal/openal" |
13 | 13 | |
14 | 14 | "github.com/faiface/beep" |
15 | + "github.com/faiface/beep/flac" | |
15 | 16 | "github.com/faiface/beep/mp3" |
16 | 17 | "github.com/faiface/beep/speaker" |
17 | 18 | ) |
@@ -352,6 +353,10 @@ func (bgm *Bgm) IsMp3() bool { | ||
352 | 353 | return filepath.Ext(bgm.filename) == ".mp3" |
353 | 354 | } |
354 | 355 | |
356 | +func (bgm *Bgm) IsFLAC() bool { | |
357 | + return filepath.Ext(bgm.filename) == ".flac" | |
358 | +} | |
359 | + | |
355 | 360 | func (bgm *Bgm) Open(filename string) { |
356 | 361 | if filepath.Base(bgm.filename) != filepath.Base(filename) { |
357 | 362 | bgm.filename = filename |
@@ -361,21 +366,39 @@ func (bgm *Bgm) Open(filename string) { | ||
361 | 366 | bgm.vorbis.Open(filename) |
362 | 367 | } else if bgm.IsMp3() { |
363 | 368 | bgm.ReadMp3() |
369 | + } else if bgm.IsFLAC() { | |
370 | + bgm.ReadFLAC() | |
364 | 371 | } |
372 | + | |
365 | 373 | } |
366 | 374 | } |
367 | 375 | |
368 | 376 | func (bgm *Bgm) ReadMp3() { |
369 | 377 | f, _ := os.Open(bgm.filename) |
370 | - s, _, err := mp3.Decode(f) | |
378 | + s, format, err := mp3.Decode(f) | |
371 | 379 | if err != nil { |
372 | 380 | return |
373 | 381 | } |
374 | 382 | streamer := beep.Loop(-1, s) |
375 | - bgm.ctrlmp3 = &beep.Ctrl{Streamer: streamer} | |
383 | + resample := beep.Resample(int(3), format.SampleRate, beep.SampleRate(Mp3SampleRate), streamer) | |
384 | + bgm.ctrlmp3 = &beep.Ctrl{Streamer: resample} | |
376 | 385 | speaker.Play(bgm.ctrlmp3) |
377 | 386 | return |
378 | 387 | } |
388 | + | |
389 | +func (bgm *Bgm) ReadFLAC() { | |
390 | + f, _ := os.Open(bgm.filename) | |
391 | + s, format, err := flac.Decode(f) | |
392 | + if err != nil { | |
393 | + return | |
394 | + } | |
395 | + streamer := beep.Loop(-1, s) | |
396 | + resample := beep.Resample(int(3), format.SampleRate, beep.SampleRate(Mp3SampleRate), streamer) | |
397 | + bgm.ctrlmp3 = &beep.Ctrl{Streamer: resample} | |
398 | + speaker.Play(bgm.ctrlmp3) | |
399 | + return | |
400 | +} | |
401 | + | |
379 | 402 | func (bgm *Bgm) Mp3Paused() { |
380 | 403 | speaker.Lock() |
381 | 404 | bgm.ctrlmp3.Paused = true |
@@ -256,6 +256,13 @@ func readBackGround(is IniSection, link *backGround, | ||
256 | 256 | bg.anim.tile[0] += int32(spr.Size[0]) |
257 | 257 | bg.anim.tile[1] += int32(spr.Size[1]) |
258 | 258 | } |
259 | + } else { | |
260 | + if bg.anim.tile[0] == 0 { | |
261 | + bg.anim.tile[2] = 0 | |
262 | + } | |
263 | + if bg.anim.tile[1] == 0 { | |
264 | + bg.anim.tile[3] = 0 | |
265 | + } | |
259 | 266 | } |
260 | 267 | } |
261 | 268 | if is.readI32ForStage("window", &bg.startrect[0], &bg.startrect[1], |