Go で書き直した Ikemen
Revision | 0c2d7a0cac53c4212b40d2988feb9714fa82b8cb (tree) |
---|---|
Time | 2019-12-05 22:25:27 |
Author | neatunsou <sisiy4excite@gmai...> |
Commiter | neatunsou |
Windblade氏の更新に対応
@@ -1,15 +1,13 @@ | ||
1 | 1 | #!/bin/sh |
2 | 2 | export GOPATH=$PWD/go |
3 | 3 | go get -u github.com/yuin/gopher-lua |
4 | -go get -u github.com/go-gl/glfw/v3.2/glfw | |
4 | +go get -u github.com/go-gl/glfw/v3.3/glfw | |
5 | 5 | go get -u github.com/go-gl/gl/v2.1/gl |
6 | -go get -u github.com/jfreymuth/go-vorbis/ogg/vorbis | |
7 | 6 | go get -u github.com/timshannon/go-openal/openal |
8 | -go get -u github.com/K4thos/glfont | |
7 | +go get -u github.com/Windblade-GR01/glfont | |
9 | 8 | go get -u github.com/flopp/go-findfont |
10 | 9 | go get -u github.com/faiface/beep |
11 | 10 | go get -u github.com/hajimehoshi/oto |
12 | 11 | go get -u github.com/hajimehoshi/go-mp3 |
13 | 12 | go get -u github.com/pkg/errors |
14 | -go get -u github.com/jfreymuth/oggvorbis | |
15 | -go get -u github.com/mewkiz/flac | |
13 | +go get -u github.com/jfreymuth/oggvorbis | |
\ No newline at end of file |
@@ -1622,7 +1622,7 @@ for i = 1, #t_dir do | ||
1622 | 1622 | animSetAlpha(anim, 1, 255) |
1623 | 1623 | end |
1624 | 1624 | animAddPos(anim, 160, 0) --for some reason needed in ikemen |
1625 | - if t_bgdef[k].window ~= nil then | |
1625 | + if t_bgdef[k].window ~= nil and t_bgdef[k].window[1] ~= nil and t_bgdef[k].window[2] ~= nil and t_bgdef[k].window[3] ~= nil and t_bgdef[k].window[4] ~= nil then | |
1626 | 1626 | animSetWindow( |
1627 | 1627 | anim, |
1628 | 1628 | t_bgdef[k].window[1], |
@@ -8,7 +8,13 @@ setSelColRow(motif.select_info.columns, motif.select_info.rows) | ||
8 | 8 | --setRandomSpr(motif.selectbgdef.spr_data, motif.select_info.cell_random_spr[1], motif.select_info.cell_random_spr[2], motif.select_info.cell_random_scale[1], motif.select_info.cell_random_scale[2]) |
9 | 9 | --setCellSpr(motif.selectbgdef.spr_data, motif.select_info.cell_bg_spr[1], motif.select_info.cell_bg_spr[2], motif.select_info.cell_bg_scale[1], motif.select_info.cell_bg_scale[2]) |
10 | 10 | |
11 | -setSelCellSize(motif.select_info.cell_size[1] + motif.select_info.cell_spacing, motif.select_info.cell_size[2] + motif.select_info.cell_spacing) | |
11 | +-- cell.size type check | |
12 | +if type(motif.select_info.cell_spacing) == "table" then | |
13 | + setSelCellSize(motif.select_info.cell_size[1] + motif.select_info.cell_spacing[1], motif.select_info.cell_size[2] + motif.select_info.cell_spacing[2]) | |
14 | +else | |
15 | + setSelCellSize(motif.select_info.cell_size[1] + motif.select_info.cell_spacing, motif.select_info.cell_size[2] + motif.select_info.cell_spacing) | |
16 | +end | |
17 | + | |
12 | 18 | setSelCellScale(motif.select_info.portrait_scale[1], motif.select_info.portrait_scale[2]) |
13 | 19 | |
14 | 20 | --default team count after starting the game |
@@ -88,7 +94,14 @@ for i = 1, (motif.select_info.rows + motif.select_info.rows_scrolling) * motif.s | ||
88 | 94 | t_grid[row] = {} |
89 | 95 | end |
90 | 96 | col = #t_grid[row] + 1 |
91 | - t_grid[row][col] = {num = i - 1, x = (col - 1) * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing), y = (row - 1) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing)} | |
97 | + | |
98 | + -- cell.spacing type check | |
99 | + if type(motif.select_info.cell_spacing) == "table" then | |
100 | + t_grid[row][col] = {num = i - 1, x = (col - 1) * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing[1]), y = (row - 1) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing[2])} | |
101 | + else | |
102 | + t_grid[row][col] = {num = i - 1, x = (col - 1) * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing), y = (row - 1) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing)} | |
103 | + end | |
104 | + | |
92 | 105 | if main.t_selChars[i].char ~= nil then |
93 | 106 | t_grid[row][col].char = main.t_selChars[i].char |
94 | 107 | t_grid[row][col].hidden = main.t_selChars[i].hidden |
@@ -1830,8 +1843,17 @@ function select.f_p1SelectMenu() | ||
1830 | 1843 | p1SelX, p1SelY, p1FaceOffset, p1RowOffset = select.f_cellMovement(p1SelX, p1SelY, main.p1Cmd, p1FaceOffset, p1RowOffset, motif.select_info.p1_cursor_move_snd) |
1831 | 1844 | p1Cell = p1SelX + motif.select_info.columns * p1SelY |
1832 | 1845 | --draw active cursor |
1833 | - local cursorX = p1FaceX + p1SelX * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing) | |
1834 | - local cursorY = p1FaceY + (p1SelY - p1RowOffset) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing) | |
1846 | + -- cell.spacing type check | |
1847 | + local cursorX = 0 | |
1848 | + local cursorY = 0 | |
1849 | + if type(motif.select_info.cell_spacing) == "table" then | |
1850 | + cursorX = p1FaceX + p1SelX * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing[1]) | |
1851 | + cursorY = p1FaceY + (p1SelY - p1RowOffset) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing[2]) | |
1852 | + else | |
1853 | + cursorX = p1FaceX + p1SelX * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing) | |
1854 | + cursorY = p1FaceY + (p1SelY - p1RowOffset) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing) | |
1855 | + end | |
1856 | + | |
1835 | 1857 | if resetgrid == true then |
1836 | 1858 | select.f_resetGrid() |
1837 | 1859 | end |
@@ -1885,8 +1907,16 @@ function select.f_p2SelectMenu() | ||
1885 | 1907 | p2SelX, p2SelY, p2FaceOffset, p2RowOffset = select.f_cellMovement(p2SelX, p2SelY, main.p2Cmd, p2FaceOffset, p2RowOffset, motif.select_info.p2_cursor_move_snd) |
1886 | 1908 | p2Cell = p2SelX + motif.select_info.columns * p2SelY |
1887 | 1909 | --draw active cursor |
1888 | - local cursorX = p2FaceX + p2SelX * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing) | |
1889 | - local cursorY = p2FaceY + (p2SelY - p2RowOffset) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing) | |
1910 | + -- cell.spacing type check | |
1911 | + local cursorX = 0 | |
1912 | + local cursorY = 0 | |
1913 | + if type(motif.select_info.cell_spacing) == "table" then | |
1914 | + cursorX = p2FaceX + p2SelX * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing[1]) | |
1915 | + cursorY = p2FaceY + (p2SelY - p2RowOffset) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing[2]) | |
1916 | + else | |
1917 | + cursorX = p2FaceX + p2SelX * (motif.select_info.cell_size[1] + motif.select_info.cell_spacing) | |
1918 | + cursorY = p2FaceY + (p2SelY - p2RowOffset) * (motif.select_info.cell_size[2] + motif.select_info.cell_spacing) | |
1919 | + end | |
1890 | 1920 | if resetgrid == true then |
1891 | 1921 | select.f_resetGrid() |
1892 | 1922 | end |
@@ -367,9 +367,6 @@ const ( | ||
367 | 367 | OC_ex_groundangle |
368 | 368 | OC_ex_stagefrontedge |
369 | 369 | OC_ex_stagebackedge |
370 | - OC_ex_const240p | |
371 | - OC_ex_const480p | |
372 | - OC_ex_const720p | |
373 | 370 | OC_ex_gethitvar_animtype |
374 | 371 | OC_ex_gethitvar_airtype |
375 | 372 | OC_ex_gethitvar_groundtype |
@@ -403,6 +400,12 @@ const ( | ||
403 | 400 | OC_ex_gethitvar_fall_envshake_phase |
404 | 401 | ) |
405 | 402 | const ( |
403 | + OC_ex_const240p OpCode = iota + 100 | |
404 | + OC_ex_const480p | |
405 | + OC_ex_const720p | |
406 | + OC_ailevelf // float version of AILevel | |
407 | +) | |
408 | +const ( | |
406 | 409 | NumVar = OC_sysvar0 - OC_var0 |
407 | 410 | NumSysVar = OC_fvar0 - OC_sysvar0 |
408 | 411 | NumFvar = OC_sysfvar0 - OC_fvar0 |
@@ -975,7 +978,9 @@ func (be BytecodeExp) run(c *Char) BytecodeValue { | ||
975 | 978 | case OC_swap: |
976 | 979 | sys.bcStack.Swap() |
977 | 980 | case OC_ailevel: |
978 | - sys.bcStack.PushI(c.aiLevel()) | |
981 | + sys.bcStack.PushI(int32(c.aiLevel())) | |
982 | + case OC_ailevelf: | |
983 | + sys.bcStack.PushF(c.aiLevel()) | |
979 | 984 | case OC_alive: |
980 | 985 | sys.bcStack.PushB(c.alive()) |
981 | 986 | case OC_anim: |
@@ -2270,7 +2270,7 @@ func (c *Char) p2() *Char { | ||
2270 | 2270 | } |
2271 | 2271 | return p2 |
2272 | 2272 | } |
2273 | -func (c *Char) aiLevel() int32 { | |
2273 | +func (c *Char) aiLevel() float32 { | |
2274 | 2274 | if c.helperIndex != 0 && c.gi().ver[0] == 1 { |
2275 | 2275 | return 0 |
2276 | 2276 | } |
@@ -691,8 +691,9 @@ func (c *Compiler) kyuushikiSuperDX(out *BytecodeExp, in *string, | ||
691 | 691 | default: |
692 | 692 | if hissu && !comma { |
693 | 693 | return Error("比較演算子がありません" + |
694 | - " / " + | |
695 | - "No comparison operator") | |
694 | + "\n" + | |
695 | + "No comparison operator" + | |
696 | + "\n[ECID 1]\n") | |
696 | 697 | } |
697 | 698 | hikaku = false |
698 | 699 | } |
@@ -736,8 +737,9 @@ func (c *Compiler) kyuushikiSuperDX(out *BytecodeExp, in *string, | ||
736 | 737 | if err != nil { |
737 | 738 | if hissu && !hikaku { |
738 | 739 | return Error("比較演算子がありません" + |
739 | - " / " + | |
740 | - "No comparison operator") | |
740 | + "\n" + | |
741 | + "No comparison operator" + | |
742 | + "\n[ECID 2]\n") | |
741 | 743 | } |
742 | 744 | if hikaku { |
743 | 745 | return err |
@@ -1148,6 +1150,8 @@ func (c *Compiler) expValue(out *BytecodeExp, in *string, | ||
1148 | 1150 | } |
1149 | 1151 | case "ailevel": |
1150 | 1152 | out.append(OC_ailevel) |
1153 | + case "ailevelf": | |
1154 | + out.append(OC_ailevelf) | |
1151 | 1155 | case "alive": |
1152 | 1156 | out.append(OC_alive) |
1153 | 1157 | case "anim": |
@@ -2169,7 +2173,12 @@ func (c *Compiler) expPostNot(out *BytecodeExp, in *string) (BytecodeValue, | ||
2169 | 2173 | if len(c.maeOp) == 0 { |
2170 | 2174 | if opp := c.isOperator(c.token); opp == 0 { |
2171 | 2175 | if !sys.ignoreMostErrors || !c.usiroOp && c.token == "(" { |
2172 | - return bvNone(), Error("演算子がありません") | |
2176 | + return bvNone(), Error("演算子がありません" + | |
2177 | + "\n" + | |
2178 | + "No comparison operator" + | |
2179 | + "\n" + | |
2180 | + "Token = '" + c.token + "' String = '" + *in + "'" + | |
2181 | + "\n[ECID 3]\n") | |
2173 | 2182 | } |
2174 | 2183 | oldtoken, oldin := c.token, *in |
2175 | 2184 | var dummyout BytecodeExp |
@@ -2178,7 +2187,10 @@ func (c *Compiler) expPostNot(out *BytecodeExp, in *string) (BytecodeValue, | ||
2178 | 2187 | } |
2179 | 2188 | if c.usiroOp { |
2180 | 2189 | if c.isOperator(c.token) <= 0 { |
2181 | - return bvNone(), Error("演算子がありません") | |
2190 | + return bvNone(), Error("演算子がありません" + | |
2191 | + "\n" + | |
2192 | + "No comparison operator" + | |
2193 | + "\n[ECID 4]\n") | |
2182 | 2194 | } |
2183 | 2195 | if err := c.renzokuEnzansihaError(in); err != nil { |
2184 | 2196 | return bvNone(), err |
@@ -6,7 +6,7 @@ import ( | ||
6 | 6 | "regexp" |
7 | 7 | "strings" |
8 | 8 | |
9 | - "github.com/K4thos/glfont" | |
9 | + "github.com/Windblade-GR01/glfont" | |
10 | 10 | findfont "github.com/flopp/go-findfont" |
11 | 11 | ) |
12 | 12 |
@@ -351,8 +351,8 @@ func loadFntTtf(f *Fnt, fontfile string, filename string) { | ||
351 | 351 | panic(err) |
352 | 352 | } |
353 | 353 | f.ttf = ttf |
354 | - | |
355 | - //Create Ttf palettes | |
354 | + | |
355 | + //Create Ttf dummy palettes | |
356 | 356 | f.palettes = make([][256]uint32, 1) |
357 | 357 | for i := 0; i < 256; i++ { |
358 | 358 | f.palettes[0][i] = 0 |
@@ -595,7 +595,7 @@ func (ts *TextSprite) SetColor(r, g, b, alphaSrc, alphaDst float32) { | ||
595 | 595 | func (ts *TextSprite) Draw() { |
596 | 596 | if !sys.frameSkip && ts.fnt != nil { |
597 | 597 | if ts.fnt.Type == "truetype" { |
598 | - ts.fnt.ttf.Printf(ts.x, ts.y, ts.yscl, ts.align, false, ts.text) //x, y, scale, align, string, printf args | |
598 | + ts.fnt.ttf.Printf(ts.x, ts.y, (ts.xscl + ts.yscl) / 2, ts.align, true, ts.text) //x, y, scale, align, blend ,string, printf args | |
599 | 599 | } else { |
600 | 600 | ts.fnt.DrawText(ts.text, ts.x, ts.y, ts.xscl, ts.yscl, ts.bank, ts.align) |
601 | 601 | } |
@@ -7,7 +7,7 @@ import ( | ||
7 | 7 | "strings" |
8 | 8 | "time" |
9 | 9 | |
10 | - "github.com/go-gl/glfw/v3.2/glfw" | |
10 | + "github.com/go-gl/glfw/v3.3/glfw" | |
11 | 11 | ) |
12 | 12 | |
13 | 13 | type CommandKey byte |
@@ -618,19 +618,22 @@ func JoystickState(joy, button int) bool { | ||
618 | 618 | if joy >= len(joystick) { |
619 | 619 | return false |
620 | 620 | } |
621 | - btns := glfw.GetJoystickButtons(joystick[joy]) | |
621 | + btns := joystick[joy].GetButtons() | |
622 | 622 | if button < 0 { |
623 | 623 | button = -button - 1 |
624 | - axes := glfw.GetJoystickAxes(joystick[joy]) | |
624 | + axes := joystick[joy].GetAxes() | |
625 | + | |
625 | 626 | if len(axes)*2 <= button { |
626 | 627 | return false |
627 | 628 | } |
628 | - if (button == 8 || button == 10) && glfw.GetJoystickName(joystick[joy]) == "Xbox 360 Controller" { //Xbox360コントローラーのLRトリガー判定 | |
629 | + | |
630 | + //Xbox360コントローラーのLRトリガー判定 | |
631 | + if (button == 9 || button == 11) && (joystick[joy].GetGamepadName() == "Xbox 360 Controller" || strings.Contains(joystick[joy].GetGamepadName(), "XInput")) { | |
629 | 632 | return axes[button/2] > sys.xinputTriggerSensitivity |
630 | 633 | } |
631 | 634 | |
632 | 635 | // Ignore trigger axis on PS4 (We already have buttons) |
633 | - if (button >= 6 && button <= 9) && glfw.GetJoystickName(joystick[joy]) == "Wireless Controller" { | |
636 | + if (button >= 6 && button <= 9) && joystick[joy].GetGamepadName() == "Wireless Controller" { | |
634 | 637 | return false |
635 | 638 | } |
636 | 639 |
@@ -1368,7 +1371,7 @@ func (__ *AiInput) Update(level float32) { | ||
1368 | 1371 | if dec(&__.dt) { |
1369 | 1372 | __.dir = Rand(0, 7) |
1370 | 1373 | } |
1371 | - osu, hanasu = int32(-11.25*level+165), 30 | |
1374 | + osu, hanasu = int32((-11.25*level+165)*7), 30 | |
1372 | 1375 | dec(&__.at) |
1373 | 1376 | dec(&__.bt) |
1374 | 1377 | dec(&__.ct) |
@@ -10,7 +10,7 @@ import ( | ||
10 | 10 | "strconv" |
11 | 11 | "strings" |
12 | 12 | |
13 | - "github.com/go-gl/glfw/v3.2/glfw" | |
13 | + "github.com/go-gl/glfw/v3.3/glfw" | |
14 | 14 | lua "github.com/yuin/gopher-lua" |
15 | 15 | ) |
16 | 16 |
@@ -78,6 +78,7 @@ func main() { | ||
78 | 78 | defer glfw.Terminate() |
79 | 79 | defcfg := []byte(strings.Join(strings.Split( |
80 | 80 | `{ |
81 | + "WindowTitle": "Ikemen GO", | |
81 | 82 | "HelperMax": 56, |
82 | 83 | "PlayerProjectileMax": 256, |
83 | 84 | "ExplodMax": 512, |
@@ -104,12 +105,12 @@ func main() { | ||
104 | 105 | ], |
105 | 106 | "JoystickConfig": [ |
106 | 107 | { |
107 | - "Joystick": 1, | |
108 | - "Buttons": ["-7", "-8", "-5", "-6", "0", "1", "4", "2", "3", "5", "7", "6", "8"] | |
108 | + "Joystick": 0, | |
109 | + "Buttons": ["-3", "-4", "-1", "-2", "0", "1", "4", "2", "3", "5", "7", "-10", "-12"] | |
109 | 110 | }, |
110 | 111 | { |
111 | 112 | "Joystick": 1, |
112 | - "Buttons": ["-7", "-8", "-5", "-6", "0", "1", "4", "2", "3", "5", "7", "6", "8"] | |
113 | + "Buttons": ["-3", "-4", "-1", "-2", "0", "1", "4", "2", "3", "5", "7", "-10", "-12"] | |
113 | 114 | } |
114 | 115 | ], |
115 | 116 | "ControllerStickSensitivity": 0.4, |
@@ -151,8 +152,7 @@ func main() { | ||
151 | 152 | "LocalcoordScalingType": 1, |
152 | 153 | "MSAA": false, |
153 | 154 | "WindowMainIconLocation": [ |
154 | - "script/Icons/16x16.png", | |
155 | - "script/Icons/24x24.png" | |
155 | + "script/Icons/IkemenCylia.png" | |
156 | 156 | ] |
157 | 157 | } |
158 | 158 | `, "\n"), "\r\n")) |
@@ -195,6 +195,7 @@ func main() { | ||
195 | 195 | ControllerStickSensitivity float32 |
196 | 196 | XinputTriggerSensitivity float32 |
197 | 197 | WindowMainIconLocation []string |
198 | + WindowTitle string | |
198 | 199 | }{} |
199 | 200 | chk(json.Unmarshal(defcfg, &tmp)) |
200 | 201 | const configFile = "save/config.json" |
@@ -212,6 +213,7 @@ func main() { | ||
212 | 213 | } |
213 | 214 | sys.controllerStickSensitivity = tmp.ControllerStickSensitivity |
214 | 215 | sys.xinputTriggerSensitivity = tmp.XinputTriggerSensitivity |
216 | + sys.windowTitle = tmp.WindowTitle | |
215 | 217 | sys.helperMax = tmp.HelperMax |
216 | 218 | sys.playerProjectileMax = tmp.PlayerProjectileMax |
217 | 219 | sys.explodMax = tmp.ExplodMax |
@@ -8,7 +8,7 @@ import ( | ||
8 | 8 | "strconv" |
9 | 9 | "strings" |
10 | 10 | |
11 | - "github.com/go-gl/glfw/v3.2/glfw" | |
11 | + "github.com/go-gl/glfw/v3.3/glfw" | |
12 | 12 | lua "github.com/yuin/gopher-lua" |
13 | 13 | ) |
14 | 14 |
@@ -285,6 +285,12 @@ func scriptCommonInit(l *lua.LState) { | ||
285 | 285 | sys.lifebarOffsetX = float32(numArg(l, 1)) |
286 | 286 | return 0 |
287 | 287 | }) |
288 | + | |
289 | + luaRegister(l, "setWindowTitle", func(*lua.LState) int { | |
290 | + sys.windowTitle = string(strArg(l, 1)) | |
291 | + sys.window.SetTitle(sys.windowTitle) | |
292 | + return 0 | |
293 | + }) | |
288 | 294 | } |
289 | 295 | |
290 | 296 | // System Script |
@@ -504,10 +510,16 @@ func systemScriptInit(l *lua.LState) { | ||
504 | 510 | }) |
505 | 511 | luaRegister(l, "setCom", func(*lua.LState) int { |
506 | 512 | pn := int(numArg(l, 1)) |
513 | + ailv := float32(numArg(l, 2)) | |
507 | 514 | if pn < 1 || pn > MaxSimul*2+MaxAttachedChar { |
508 | 515 | l.RaiseError("プレイヤー番号(%v)が不正です。", pn) |
509 | 516 | } |
510 | - sys.com[pn-1] = Max(0, int32(numArg(l, 2))) | |
517 | + if ailv > 0 { | |
518 | + sys.com[pn-1] = ailv | |
519 | + } else { | |
520 | + sys.com[pn-1] = 0 | |
521 | + } | |
522 | + | |
511 | 523 | return 0 |
512 | 524 | }) |
513 | 525 | luaRegister(l, "setAutoLevel", func(*lua.LState) int { |
@@ -1212,23 +1224,29 @@ func systemScriptInit(l *lua.LState) { | ||
1212 | 1224 | l.Push(lua.LString(f)) |
1213 | 1225 | return 6 |
1214 | 1226 | }) |
1227 | + luaRegister(l, "getGamepadName", func(*lua.LState) int { | |
1228 | + l.Push(lua.LString(joystick[int(numArg(l, 1))].GetGamepadName())) | |
1229 | + return 1 | |
1230 | + }) | |
1215 | 1231 | luaRegister(l, "getKey", func(*lua.LState) int { |
1216 | 1232 | s := "" |
1217 | 1233 | if sys.keyInput != glfw.KeyUnknown { |
1218 | 1234 | s = KeyToString(sys.keyInput) |
1219 | 1235 | } |
1220 | - for j := 0; j < 2; j++ { | |
1221 | - if glfw.JoystickPresent(joystick[j]) { | |
1222 | - axes := glfw.GetJoystickAxes(joystick[j]) | |
1223 | - btns := glfw.GetJoystickButtons(joystick[j]) | |
1236 | + for j := 0; j < 1; j++ { | |
1237 | + if joystick[j].GetGamepadState != nil { | |
1238 | + axes := joystick[j].GetAxes() | |
1239 | + btns := joystick[j].GetButtons() | |
1224 | 1240 | for i := range axes { |
1225 | - if glfw.GetJoystickName(joystick[j]) == "Xbox 360 Controller" { //Xbox360コントローラー判定 | |
1226 | - if axes[i] > 0 { | |
1241 | + if joystick[j].GetGamepadName() == "Xbox 360 Controller" || strings.Contains(joystick[j].GetGamepadName(), "XInput") { //Xbox360コントローラー判定 | |
1242 | + if axes[i] > 0.5 { | |
1243 | + s = strconv.Itoa(-i*2 - 2) | |
1244 | + } else if axes[i] < -0.5 && i < 4 { | |
1227 | 1245 | s = strconv.Itoa(-i*2 - 1) |
1228 | 1246 | } |
1229 | 1247 | } else { |
1230 | 1248 | // PS4 Controller support |
1231 | - if glfw.GetJoystickName(joystick[j]) != "Wireless Controller" || !(i == 3 || i == 4) { | |
1249 | + if joystick[j].GetGamepadName() != "Wireless Controller" || !(i == 3 || i == 4) { | |
1232 | 1250 | if axes[i] < -0.2 { |
1233 | 1251 | s = strconv.Itoa(-i*2 - 1) |
1234 | 1252 | } else if axes[i] > 0.2 { |
@@ -1252,7 +1270,7 @@ func systemScriptInit(l *lua.LState) { | ||
1252 | 1270 | s := "" |
1253 | 1271 | if sys.keyInput != glfw.KeyUnknown { |
1254 | 1272 | if sys.keyInput == glfw.KeyInsert { |
1255 | - s, _ = sys.window.GetClipboardString() | |
1273 | + s = sys.window.GetClipboardString() | |
1256 | 1274 | } else { |
1257 | 1275 | s = sys.keyString |
1258 | 1276 | } |
@@ -2251,7 +2269,7 @@ func debugScriptInit(l *lua.LState, file string) error { | ||
2251 | 2269 | }) |
2252 | 2270 | luaRegister(l, "setAILevel", func(*lua.LState) int { |
2253 | 2271 | if sys.netInput == nil && sys.fileInput == nil { |
2254 | - level := int32(numArg(l, 1)) | |
2272 | + level := float32(numArg(l, 1)) | |
2255 | 2273 | sys.com[sys.debugWC.playerNo] = level |
2256 | 2274 | for _, c := range sys.chars[sys.debugWC.playerNo] { |
2257 | 2275 | if level == 0 { |
@@ -12,7 +12,7 @@ import ( | ||
12 | 12 | |
13 | 13 | "github.com/faiface/beep" |
14 | 14 | "github.com/faiface/beep/effects" |
15 | - "github.com/faiface/beep/flac" | |
15 | + //"github.com/faiface/beep/flac" | |
16 | 16 | "github.com/faiface/beep/mp3" |
17 | 17 | "github.com/faiface/beep/speaker" |
18 | 18 | "github.com/faiface/beep/vorbis" |
@@ -268,9 +268,9 @@ func (bgm *Bgm) IsMp3() bool { | ||
268 | 268 | return bgm.IsFormat(".mp3") |
269 | 269 | } |
270 | 270 | |
271 | -func (bgm *Bgm) IsFLAC() bool { | |
272 | - return bgm.IsFormat(".flac") | |
273 | -} | |
271 | +//func (bgm *Bgm) IsFLAC() bool { | |
272 | +// return bgm.IsFormat(".flac") | |
273 | +//} | |
274 | 274 | |
275 | 275 | func (bgm *Bgm) IsWAVE() bool { |
276 | 276 | return bgm.IsFormat(".wav") |
@@ -301,8 +301,8 @@ func (bgm *Bgm) Open(filename string, isDefaultBGM bool, loop, bgmVolume, bgmLoo | ||
301 | 301 | bgm.ReadVorbis(loop, bgmVolume) |
302 | 302 | } else if bgm.IsMp3() { |
303 | 303 | bgm.ReadMp3(loop, bgmVolume) |
304 | - } else if bgm.IsFLAC() { | |
305 | - bgm.ConvertFLAC(loop, bgmVolume) | |
304 | + //} else if bgm.IsFLAC() { | |
305 | + // bgm.ConvertFLAC(loop, bgmVolume) | |
306 | 306 | } else if bgm.IsWAVE() { |
307 | 307 | bgm.ReadWav(loop, bgmVolume) |
308 | 308 | } |
@@ -320,6 +320,7 @@ func (bgm *Bgm) ReadMp3(loop int, bgmVolume int) { | ||
320 | 320 | bgm.ReadFormat(format, loop, bgmVolume) |
321 | 321 | } |
322 | 322 | |
323 | +/* | |
323 | 324 | func (bgm *Bgm) ReadFLAC(loop int, bgmVolume int) { |
324 | 325 | f, _ := os.Open(bgm.filename) |
325 | 326 | s, format, err := flac.Decode(f) |
@@ -333,6 +334,7 @@ func (bgm *Bgm) ReadFLAC(loop int, bgmVolume int) { | ||
333 | 334 | } |
334 | 335 | |
335 | 336 | // SCREW THE FLAC.SEEK FUNCTION, IT DOES NOT WORK SO WE ARE GOING TO CONVERT THIS TO WAV |
337 | +// Update: Now the flac dependecy broke. (-_-) | |
336 | 338 | func (bgm *Bgm) ConvertFLAC(loop int, bgmVolume int) { |
337 | 339 | // We open the flac |
338 | 340 | f1, _ := os.Open(bgm.filename) |
@@ -355,6 +357,7 @@ func (bgm *Bgm) ConvertFLAC(loop int, bgmVolume int) { | ||
355 | 357 | |
356 | 358 | sys.FLAC_FrameWait = 120 |
357 | 359 | } |
360 | +*/ | |
358 | 361 | |
359 | 362 | func (bgm *Bgm) PlayMemAudio(loop int, bgmVolume int) { |
360 | 363 | f, _ := os.Open(bgm.filename) |
@@ -17,13 +17,13 @@ import ( | ||
17 | 17 | "github.com/faiface/beep" |
18 | 18 | "github.com/faiface/beep/speaker" |
19 | 19 | "github.com/go-gl/gl/v2.1/gl" |
20 | - "github.com/go-gl/glfw/v3.2/glfw" | |
20 | + "github.com/go-gl/glfw/v3.3/glfw" | |
21 | 21 | "github.com/timshannon/go-openal/openal" |
22 | 22 | lua "github.com/yuin/gopher-lua" |
23 | 23 | ) |
24 | 24 | |
25 | 25 | const ( |
26 | - MaxSimul = 8 | |
26 | + MaxSimul = 32 | |
27 | 27 | MaxAttachedChar = 2 |
28 | 28 | FPS = 60 |
29 | 29 | P1P3Dist = 25 |
@@ -66,7 +66,7 @@ var sys = System { | ||
66 | 66 | keyInput: glfw.KeyUnknown, |
67 | 67 | keyString: "", |
68 | 68 | comboExtraFrameWindow: 1, |
69 | - FLAC_FrameWait: -1, | |
69 | + //FLAC_FrameWait: -1, | |
70 | 70 | // Localcoord sceenpack |
71 | 71 | luaSpriteScale: 1, |
72 | 72 | luaSmallPortraitScale: 1, |
@@ -119,7 +119,7 @@ type System struct { | ||
119 | 119 | aiInput [MaxSimul*2 + MaxAttachedChar]AiInput |
120 | 120 | keyConfig []KeyConfig |
121 | 121 | JoystickConfig []KeyConfig |
122 | - com [MaxSimul*2 + MaxAttachedChar]int32 | |
122 | + com [MaxSimul*2 + MaxAttachedChar]float32 | |
123 | 123 | autolevel bool |
124 | 124 | home int |
125 | 125 | gameTime int32 |
@@ -251,7 +251,8 @@ type System struct { | ||
251 | 251 | wavVolume int |
252 | 252 | bgmVolume int |
253 | 253 | AudioDucking bool |
254 | - FLAC_FrameWait int | |
254 | + windowTitle string | |
255 | + //FLAC_FrameWait int | |
255 | 256 | |
256 | 257 | controllerStickSensitivity float32 |
257 | 258 | xinputTriggerSensitivity float32 |
@@ -284,10 +285,10 @@ func (s *System) init(w, h int32) *lua.LState { | ||
284 | 285 | var err error |
285 | 286 | if s.fullscreen { |
286 | 287 | s.window, err = glfw.CreateWindow(int(s.scrrect[2]), int(s.scrrect[3]), |
287 | - "Ikemen GO", glfw.GetPrimaryMonitor(), nil) | |
288 | + s.windowTitle, glfw.GetPrimaryMonitor(), nil) | |
288 | 289 | } else { |
289 | 290 | s.window, err = glfw.CreateWindow(int(s.scrrect[2]), int(s.scrrect[3]), |
290 | - "Ikemen GO", nil, nil) | |
291 | + s.windowTitle, nil, nil) | |
291 | 292 | } |
292 | 293 | chk(err) |
293 | 294 | s.window.MakeContextCurrent() |
@@ -473,12 +474,12 @@ func (s *System) soundWrite() { | ||
473 | 474 | } |
474 | 475 | } |
475 | 476 | |
476 | - if s.FLAC_FrameWait >= 0 { | |
477 | - if s.FLAC_FrameWait == 0 { | |
478 | - s.bgm.PlayMemAudio(s.bgm.loop, s.bgm.bgmVolume) | |
479 | - } | |
480 | - s.FLAC_FrameWait-- | |
481 | - } | |
477 | + //if s.FLAC_FrameWait >= 0 { | |
478 | + // if s.FLAC_FrameWait == 0 { | |
479 | + // s.bgm.PlayMemAudio(s.bgm.loop, s.bgm.bgmVolume) | |
480 | + // } | |
481 | + // s.FLAC_FrameWait-- | |
482 | + //} | |
482 | 483 | } |
483 | 484 | src.Delete() |
484 | 485 | openal.NullContext.Activate() |
@@ -765,7 +766,7 @@ func (s *System) commandUpdate() { | ||
765 | 766 | for _, c := range p { |
766 | 767 | if (c.helperIndex == 0 || |
767 | 768 | c.helperIndex > 0 && &c.cmd[0] != &r.cmd[0]) && |
768 | - c.cmd[0].Input(c.key, int32(c.facing), float32(sys.com[i])) { | |
769 | + c.cmd[0].Input(c.key, int32(c.facing), sys.com[i]) { | |
769 | 770 | hp := c.hitPause() |
770 | 771 | buftime := Btoi(hp && c.gi().ver[0] != 1) |
771 | 772 | if s.super > 0 { |
@@ -786,7 +787,7 @@ func (s *System) commandUpdate() { | ||
786 | 787 | cc := int32(-1) |
787 | 788 | // AI Scaling |
788 | 789 | // TODO: Balance AI Scaling |
789 | - if r.roundState() == 2 && RandF32(0, float32(sys.com[i])/2+32) > 32 { | |
790 | + if r.roundState() == 2 && RandF32(0, sys.com[i]/2+32) > 32 { | |
790 | 791 | cc = Rand(0, int32(len(r.cmd[r.ss.sb.playerNo].Commands))-1) |
791 | 792 | } else { |
792 | 793 | cc = -1 |