• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Go で書き直した Ikemen


Commit MetaInfo

Revisão150fe933407d67a972cd92c574632faa7888d97f (tree)
Hora2019-03-02 19:33:55
Autorneatunsou <sisiy4excite@gmai...>
Commiterneatunsou

Mensagem de Log

mp3にリサンプル処理をしてなかったのを修正
animにtileを記述してなおかつtilespacingが0だとtileを無効にするようにした
アルファ入りpngの表示が微妙に暗くなっていたのを修正
Windblade氏の更新を適応

Mudança Sumário

Diff

--- a/get.sh
+++ b/get.sh
@@ -11,3 +11,5 @@ go get -u github.com/faiface/beep
1111 go get -u github.com/hajimehoshi/oto
1212 go get -u github.com/hajimehoshi/go-mp3
1313 go get -u github.com/pkg/errors
14+go get -u github.com/jfreymuth/oggvorbis
15+go get -u github.com/mewkiz/flac
--- a/src/render.go
+++ b/src/render.go
@@ -75,8 +75,8 @@ func RenderInit() {
7575 "texcoord[0] = left / (left + right);" + // ここまで
7676 "}" +
7777 "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;" +
8080 "c.rgb *= mul;" +
8181 "c.a *= a;" +
8282 "gl_FragColor = c;" +
@@ -359,7 +359,11 @@ func rmMainSub(a int32, size [2]uint16, x, y float32, tl *[4]int32,
359359 agl, yagl, xagl, rcx, rcy)
360360 case trans < 512:
361361 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+ }
363367 gl.BlendEquation(gl.FUNC_ADD)
364368 rmTileSub(size[0], size[1], x, y, tl, renderMode, xts, xbs, ys, vs, rxadd,
365369 agl, yagl, xagl, rcx, rcy)
--- a/src/script.go
+++ b/src/script.go
@@ -313,13 +313,15 @@ func systemScriptInit(l *lua.LState) {
313313 }
314314 ts.text = strArg(l, 2)
315315 return 0
316- })
316+ })
317317 luaRegister(l, "textImgSetPos", func(*lua.LState) int {
318318 ts, ok := toUserData(l, 1).(*TextSprite)
319319 if !ok {
320320 userDataError(l, 1, ts)
321321 }
322+ if boolArg(l, 3) {
322323 ts.x, ts.y = float32((numArg(l, 2)/sys.luaSpriteScale)+sys.luaSpriteOffsetX), float32(numArg(l, 3)/sys.luaSpriteScale)
324+ }
323325 return 0
324326 })
325327 luaRegister(l, "textImgSetScale", func(*lua.LState) int {
--- a/src/sound.go
+++ b/src/sound.go
@@ -12,6 +12,7 @@ import (
1212 "github.com/timshannon/go-openal/openal"
1313
1414 "github.com/faiface/beep"
15+ "github.com/faiface/beep/flac"
1516 "github.com/faiface/beep/mp3"
1617 "github.com/faiface/beep/speaker"
1718 )
@@ -352,6 +353,10 @@ func (bgm *Bgm) IsMp3() bool {
352353 return filepath.Ext(bgm.filename) == ".mp3"
353354 }
354355
356+func (bgm *Bgm) IsFLAC() bool {
357+ return filepath.Ext(bgm.filename) == ".flac"
358+}
359+
355360 func (bgm *Bgm) Open(filename string) {
356361 if filepath.Base(bgm.filename) != filepath.Base(filename) {
357362 bgm.filename = filename
@@ -361,21 +366,39 @@ func (bgm *Bgm) Open(filename string) {
361366 bgm.vorbis.Open(filename)
362367 } else if bgm.IsMp3() {
363368 bgm.ReadMp3()
369+ } else if bgm.IsFLAC() {
370+ bgm.ReadFLAC()
364371 }
372+
365373 }
366374 }
367375
368376 func (bgm *Bgm) ReadMp3() {
369377 f, _ := os.Open(bgm.filename)
370- s, _, err := mp3.Decode(f)
378+ s, format, err := mp3.Decode(f)
371379 if err != nil {
372380 return
373381 }
374382 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}
376385 speaker.Play(bgm.ctrlmp3)
377386 return
378387 }
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+
379402 func (bgm *Bgm) Mp3Paused() {
380403 speaker.Lock()
381404 bgm.ctrlmp3.Paused = true
--- a/src/stage.go
+++ b/src/stage.go
@@ -256,6 +256,13 @@ func readBackGround(is IniSection, link *backGround,
256256 bg.anim.tile[0] += int32(spr.Size[0])
257257 bg.anim.tile[1] += int32(spr.Size[1])
258258 }
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+ }
259266 }
260267 }
261268 if is.readI32ForStage("window", &bg.startrect[0], &bg.startrect[1],