Go で書き直した Ikemen
Revision | 5285bac7ea45cec054b767200f9c770fe087df46 (tree) |
---|---|
Zeit | 2019-09-15 02:31:15 |
Autor | neatunsou <sisiy4excite@gmai...> |
Commiter | neatunsou |
StoryboardのBGCtrlの移動量がlocalcoordの影響を受けるように修正
StoryboardのCtrldef名が重複して上書きされる場合があったのを修正
Storyboardにskipbuttonオプションを追加
Targetbindの基準posにlocalcoordを考慮してなかったのを修正
AIRのinterploateオプションでアニメがloopした場合の動作を修正
@@ -569,7 +569,7 @@ function main.f_ctrlBG(t_bg, t_ctrl) | ||
569 | 569 | end |
570 | 570 | |
571 | 571 | --draw background layers |
572 | -function main.f_drawBG(data, info, layerno, timer) | |
572 | +function main.f_drawBG(data, info, layerno, timer, localcoord) | |
573 | 573 | timer = timer or 0 |
574 | 574 | --loop through all backgrounds |
575 | 575 | for i = 1, #data do |
@@ -605,34 +605,38 @@ function main.f_drawBG(data, info, layerno, timer) | ||
605 | 605 | info[i].ctrl_flags.enabled = t.value |
606 | 606 | elseif k == 'velset' or k == 'posset' then |
607 | 607 | if t.x ~= nil then |
608 | - info[i].ctrl_flags.velx = 0 - info[i].velocity[1] + t.x | |
608 | + info[i].ctrl_flags.velx = 0 - info[i].velocity[1] + t.x * 320/localcoord[1] | |
609 | 609 | end |
610 | 610 | if t.y ~= nil then |
611 | - info[i].ctrl_flags.vely = 0 - info[i].velocity[2] + t.y | |
611 | + info[i].ctrl_flags.vely = 0 - info[i].velocity[2] + t.y * 240/localcoord[2] | |
612 | 612 | end |
613 | - elseif k == 'veladd' or k == 'posadd' then | |
613 | + elseif k == 'veladd' then --or k == 'posadd' then | |
614 | 614 | if t.x ~= nil then |
615 | - info[i].ctrl_flags.velx = info[i].ctrl_flags.velx + t.x | |
615 | + info[i].ctrl_flags.velx = info[i].ctrl_flags.velx + t.x * 320/localcoord[1] | |
616 | 616 | end |
617 | 617 | if t.y ~= nil then |
618 | - info[i].ctrl_flags.vely = info[i].ctrl_flags.vely + t.y | |
618 | + info[i].ctrl_flags.vely = info[i].ctrl_flags.vely + t.y * 240/localcoord[2] | |
619 | 619 | end |
620 | + elseif k == 'posadd' then | |
621 | + if t.x ~= nil then x = t.x * 320/localcoord[1] end | |
622 | + if t.y ~= nil then y = t.y * 240/localcoord[2] end | |
623 | + animAddPos(data[i], x, y) | |
620 | 624 | --[[elseif k == 'posset' then |
621 | 625 | if t.x ~= nil then |
622 | - x = t.x | |
626 | + x = t.x * 320/localcoord[1] | |
623 | 627 | else |
624 | 628 | x = info[i].start[1] |
625 | 629 | end |
626 | - if t.y == nil then | |
627 | - y = t.y | |
630 | + if t.y ~= nil then | |
631 | + y = t.y * 240/localcoord[2] | |
628 | 632 | else |
629 | 633 | y = info[i].start[2] |
630 | 634 | end |
631 | 635 | animSetPos(data[i], x, y) |
632 | 636 | animAddPos(data[i], 160, 0) --for some reason needed in ikemen |
633 | 637 | elseif k == 'posadd' then |
634 | - if t.x ~= nil then x = t.x end | |
635 | - if t.y ~= nil then y = t.y end | |
638 | + if t.x ~= nil then x = t.x * 320/localcoord[1] end | |
639 | + if t.y ~= nil then y = t.y * 240/localcoord[2] end | |
636 | 640 | animAddPos(data[i], x, y)]] |
637 | 641 | --elseif k == 'anim' then --not supported yet |
638 | 642 | --elseif k == 'sinx' then --not supported yet |
@@ -725,9 +729,9 @@ function main.f_warning(t, info, background, font_info, title, box) | ||
725 | 729 | --draw clearcolor |
726 | 730 | animDraw(background.bgclearcolor_data) |
727 | 731 | --draw layerno = 0 backgrounds |
728 | - main.f_drawBG(background.bg_data, background.bg, 0, background.timer) | |
732 | + main.f_drawBG(background.bg_data, background.bg, 0, background.timer, {320,240}) | |
729 | 733 | --draw layerno = 1 backgrounds |
730 | - main.f_drawBG(background.bg_data, background.bg, 1, background.timer) | |
734 | + main.f_drawBG(background.bg_data, background.bg, 1, background.timer, {320,240}) | |
731 | 735 | --draw menu box |
732 | 736 | animDraw(box) |
733 | 737 | --draw title |
@@ -794,9 +798,9 @@ function main.f_input(t, info, background, type) | ||
794 | 798 | --draw clearcolor |
795 | 799 | animDraw(background.bgclearcolor_data) |
796 | 800 | --draw layerno = 0 backgrounds |
797 | - main.f_drawBG(background.bg_data, background.bg, 0, background.timer) | |
801 | + main.f_drawBG(background.bg_data, background.bg, 0, background.timer, {320,240}) | |
798 | 802 | --draw layerno = 1 backgrounds |
799 | - main.f_drawBG(background.bg_data, background.bg, 1, background.timer) | |
803 | + main.f_drawBG(background.bg_data, background.bg, 1, background.timer, {320,240}) | |
800 | 804 | --draw menu box |
801 | 805 | animDraw(main.warningBox) |
802 | 806 | --draw text |
@@ -1106,7 +1110,7 @@ file:close() | ||
1106 | 1110 | content = content:gsub('([^\r\n;]*)%s*;[^\r\n]*', '%1') |
1107 | 1111 | content = content:gsub('\n%s*\n', '\n') |
1108 | 1112 | for line in content:gmatch('[^\r\n]+') do |
1109 | - if chars + stages == 90 then | |
1113 | + if chars + stages == 100 then | |
1110 | 1114 | SetGCPercent(100) |
1111 | 1115 | end |
1112 | 1116 | --for line in io.lines("data/select.def") do |
@@ -1488,7 +1492,7 @@ function main.f_menuCommon2(cursorPosY, moveTxt, item, t) | ||
1488 | 1492 | --draw clearcolor |
1489 | 1493 | animDraw(motif.titlebgdef.bgclearcolor_data) |
1490 | 1494 | --draw layerno = 0 backgrounds |
1491 | - main.f_drawBG(motif.titlebgdef.bg_data, motif.titlebgdef.bg, 0, motif.titlebgdef.timer) | |
1495 | + main.f_drawBG(motif.titlebgdef.bg_data, motif.titlebgdef.bg, 0, motif.titlebgdef.timer, {320,240}) | |
1492 | 1496 | --draw menu items |
1493 | 1497 | local items_shown = item + motif.title_info.menu_window_visibleitems - cursorPosY |
1494 | 1498 | if motif.title_info.menu_window_margins_y[2] ~= 0 and items_shown < #t then |
@@ -1545,7 +1549,7 @@ function main.f_menuCommon2(cursorPosY, moveTxt, item, t) | ||
1545 | 1549 | animDraw(main.cursorBox) |
1546 | 1550 | end |
1547 | 1551 | --draw layerno = 1 backgrounds |
1548 | - main.f_drawBG(motif.titlebgdef.bg_data, motif.titlebgdef.bg, 1, motif.titlebgdef.timer) | |
1552 | + main.f_drawBG(motif.titlebgdef.bg_data, motif.titlebgdef.bg, 1, motif.titlebgdef.timer, {320,240}) | |
1549 | 1553 | --footer draw |
1550 | 1554 | if motif.title_info.footer_boxbackground_visible == 1 then |
1551 | 1555 | animDraw(footerBox) |
@@ -1738,9 +1742,9 @@ function main.f_connect(server, t) | ||
1738 | 1742 | --draw clearcolor |
1739 | 1743 | animDraw(motif.titlebgdef.bgclearcolor_data) |
1740 | 1744 | --draw layerno = 0 backgrounds |
1741 | - main.f_drawBG(motif.titlebgdef.bg_data, motif.titlebgdef.bg, 0, motif.titlebgdef.timer) | |
1745 | + main.f_drawBG(motif.titlebgdef.bg_data, motif.titlebgdef.bg, 0, motif.titlebgdef.timer, {320,240}) | |
1742 | 1746 | --draw layerno = 1 backgrounds |
1743 | - main.f_drawBG(motif.titlebgdef.bg_data, motif.titlebgdef.bg, 1, motif.titlebgdef.timer) | |
1747 | + main.f_drawBG(motif.titlebgdef.bg_data, motif.titlebgdef.bg, 1, motif.titlebgdef.timer, {320,240}) | |
1744 | 1748 | --draw menu box |
1745 | 1749 | animDraw(main.warningBox) |
1746 | 1750 | --draw text |
@@ -190,7 +190,7 @@ function options.f_menuCommon2(cursorPosY, moveTxt, item, t) | ||
190 | 190 | --draw clearcolor |
191 | 191 | animDraw(motif.optionbgdef.bgclearcolor_data) |
192 | 192 | --draw layerno = 0 backgrounds |
193 | - main.f_drawBG(motif.optionbgdef.bg_data, motif.optionbgdef.bg, 0, motif.optionbgdef.timer) | |
193 | + main.f_drawBG(motif.optionbgdef.bg_data, motif.optionbgdef.bg, 0, motif.optionbgdef.timer, {320,240}) | |
194 | 194 | --draw menu box |
195 | 195 | if motif.option_info.menu_boxbackground_visible == 1 then |
196 | 196 | if #t > motif.option_info.menu_window_visibleitems and moveTxt == (#t - motif.option_info.menu_window_visibleitems) * motif.option_info.menu_item_spacing[2] then |
@@ -295,7 +295,7 @@ function options.f_menuCommon2(cursorPosY, moveTxt, item, t) | ||
295 | 295 | animDraw(main.cursorBox) |
296 | 296 | end |
297 | 297 | --draw layerno = 1 backgrounds |
298 | - main.f_drawBG(motif.optionbgdef.bg_data, motif.optionbgdef.bg, 1, motif.optionbgdef.timer) | |
298 | + main.f_drawBG(motif.optionbgdef.bg_data, motif.optionbgdef.bg, 1, motif.optionbgdef.timer, {320,240}) | |
299 | 299 | --draw fadein |
300 | 300 | animDraw(motif.option_info.fadein_data) |
301 | 301 | animUpdate(motif.option_info.fadein_data) |
@@ -1031,10 +1031,10 @@ function select.f_selectTournamentScreen() | ||
1031 | 1031 | --draw clearcolor |
1032 | 1032 | animDraw(motif.tournamentbgdef.bgclearcolor_data) |
1033 | 1033 | --draw layerno = 0 backgrounds |
1034 | - main.f_drawBG(motif.tournamentbgdef.bg_data, motif.tournamentbgdef.bg, 0, motif.tournamentbgdef.timer) | |
1034 | + main.f_drawBG(motif.tournamentbgdef.bg_data, motif.tournamentbgdef.bg, 0, motif.tournamentbgdef.timer, {320,240}) | |
1035 | 1035 | |
1036 | 1036 | --draw layerno = 1 backgrounds |
1037 | - main.f_drawBG(motif.tournamentbgdef.bg_data, motif.tournamentbgdef.bg, 1, motif.tournamentbgdef.timer) | |
1037 | + main.f_drawBG(motif.tournamentbgdef.bg_data, motif.tournamentbgdef.bg, 1, motif.tournamentbgdef.timer, {320,240}) | |
1038 | 1038 | --draw fadein |
1039 | 1039 | animDraw(motif.tournament_info.fadein_data) |
1040 | 1040 | animUpdate(motif.tournament_info.fadein_data) |
@@ -1086,7 +1086,7 @@ function select.f_selectScreen() | ||
1086 | 1086 | --draw clearcolor |
1087 | 1087 | animDraw(motif.selectbgdef.bgclearcolor_data) |
1088 | 1088 | --draw layerno = 0 backgrounds |
1089 | - main.f_drawBG(motif.selectbgdef.bg_data, motif.selectbgdef.bg, 0, motif.selectbgdef.timer) | |
1089 | + main.f_drawBG(motif.selectbgdef.bg_data, motif.selectbgdef.bg, 0, motif.selectbgdef.timer, {320,240}) | |
1090 | 1090 | --draw title |
1091 | 1091 | textImgDraw(main.txt_mainSelect) |
1092 | 1092 | if p1Cell then |
@@ -1263,7 +1263,7 @@ function select.f_selectScreen() | ||
1263 | 1263 | end |
1264 | 1264 | end |
1265 | 1265 | --draw layerno = 1 backgrounds |
1266 | - main.f_drawBG(motif.selectbgdef.bg_data, motif.selectbgdef.bg, 1, motif.selectbgdef.timer) | |
1266 | + main.f_drawBG(motif.selectbgdef.bg_data, motif.selectbgdef.bg, 1, motif.selectbgdef.timer, {320,240}) | |
1267 | 1267 | --draw fadein |
1268 | 1268 | animDraw(motif.select_info.fadein_data) |
1269 | 1269 | animUpdate(motif.select_info.fadein_data) |
@@ -2195,7 +2195,7 @@ function select.f_selectVersus() | ||
2195 | 2195 | --draw clearcolor |
2196 | 2196 | animDraw(motif.versusbgdef.bgclearcolor_data) |
2197 | 2197 | --draw layerno = 0 backgrounds |
2198 | - main.f_drawBG(motif.versusbgdef.bg_data, motif.versusbgdef.bg, 0, motif.versusbgdef.timer) | |
2198 | + main.f_drawBG(motif.versusbgdef.bg_data, motif.versusbgdef.bg, 0, motif.versusbgdef.timer, {320,240}) | |
2199 | 2199 | --draw portraits |
2200 | 2200 | select.f_drawPortrait( |
2201 | 2201 | t_p1Selected, |
@@ -2253,7 +2253,7 @@ function select.f_selectVersus() | ||
2253 | 2253 | textImgDraw(txt_matchNo) |
2254 | 2254 | end |
2255 | 2255 | --draw layerno = 1 backgrounds |
2256 | - main.f_drawBG(motif.versusbgdef.bg_data, motif.versusbgdef.bg, 1, motif.versusbgdef.timer) | |
2256 | + main.f_drawBG(motif.versusbgdef.bg_data, motif.versusbgdef.bg, 1, motif.versusbgdef.timer, {320,240}) | |
2257 | 2257 | --draw fadein |
2258 | 2258 | animDraw(motif.vs_screen.fadein_data) |
2259 | 2259 | animUpdate(motif.vs_screen.fadein_data) |
@@ -2334,7 +2334,7 @@ function select.f_result(state) | ||
2334 | 2334 | --draw clearcolor |
2335 | 2335 | --animDraw(motif.resultsbgdef.bgclearcolor_data) --disabled to not cover game screen |
2336 | 2336 | --draw layerno = 0 backgrounds |
2337 | - main.f_drawBG(motif.resultsbgdef.bg_data, motif.resultsbgdef.bg, 0, motif.resultsbgdef.timer) | |
2337 | + main.f_drawBG(motif.resultsbgdef.bg_data, motif.resultsbgdef.bg, 0, motif.resultsbgdef.timer, {320,240}) | |
2338 | 2338 | --draw text |
2339 | 2339 | for i = 1, #t_resultText do |
2340 | 2340 | textImgSetText(txt, t_resultText[i]) |
@@ -2346,7 +2346,7 @@ function select.f_result(state) | ||
2346 | 2346 | textImgDraw(txt) |
2347 | 2347 | end |
2348 | 2348 | --draw layerno = 1 backgrounds |
2349 | - main.f_drawBG(motif.resultsbgdef.bg_data, motif.resultsbgdef.bg, 1, motif.resultsbgdef.timer) | |
2349 | + main.f_drawBG(motif.resultsbgdef.bg_data, motif.resultsbgdef.bg, 1, motif.resultsbgdef.timer, {320,240}) | |
2350 | 2350 | --draw fadein |
2351 | 2351 | animDraw(t.fadein_data) |
2352 | 2352 | animUpdate(t.fadein_data) |
@@ -2440,7 +2440,7 @@ function select.f_selectVictory() | ||
2440 | 2440 | --draw clearcolor |
2441 | 2441 | animDraw(motif.victorybgdef.bgclearcolor_data) |
2442 | 2442 | --draw layerno = 0 backgrounds |
2443 | - main.f_drawBG(motif.victorybgdef.bg_data, motif.victorybgdef.bg, 0, motif.victorybgdef.timer) | |
2443 | + main.f_drawBG(motif.victorybgdef.bg_data, motif.victorybgdef.bg, 0, motif.victorybgdef.timer, {320,240}) | |
2444 | 2444 | --draw portraits |
2445 | 2445 | if motif.victory_screen.p2_display == 0 then |
2446 | 2446 | drawVictoryPortrait( |
@@ -2484,7 +2484,7 @@ function select.f_selectVictory() | ||
2484 | 2484 | motif.victory_screen.winquote_length |
2485 | 2485 | ) |
2486 | 2486 | --draw layerno = 1 backgrounds |
2487 | - main.f_drawBG(motif.victorybgdef.bg_data, motif.victorybgdef.bg, 1, motif.victorybgdef.timer) | |
2487 | + main.f_drawBG(motif.victorybgdef.bg_data, motif.victorybgdef.bg, 1, motif.victorybgdef.timer, {320,240}) | |
2488 | 2488 | --draw fadein |
2489 | 2489 | animDraw(motif.victory_screen.fadein_data) |
2490 | 2490 | animUpdate(motif.victory_screen.fadein_data) |
@@ -2525,7 +2525,7 @@ function select.f_continue() | ||
2525 | 2525 | --draw clearcolor (disabled to not cover area) |
2526 | 2526 | --animDraw(motif.continuebgdef.bgclearcolor_data) |
2527 | 2527 | --draw layerno = 0 backgrounds |
2528 | - main.f_drawBG(motif.continuebgdef.bg_data, motif.continuebgdef.bg, 0, motif.continuebgdef.timer) | |
2528 | + main.f_drawBG(motif.continuebgdef.bg_data, motif.continuebgdef.bg, 0, motif.continuebgdef.timer, {320,240}) | |
2529 | 2529 | --continue screen state |
2530 | 2530 | if esc() or motif.continuebgdef.timer > motif.continue_screen.endtime then |
2531 | 2531 | main.f_cmdInput() |
@@ -2600,7 +2600,7 @@ function select.f_continue() | ||
2600 | 2600 | animUpdate(motif.continue_screen.continue_anim_data) |
2601 | 2601 | animDraw(motif.continue_screen.continue_anim_data) |
2602 | 2602 | --draw layerno = 1 backgrounds |
2603 | - main.f_drawBG(motif.continuebgdef.bg_data, motif.continuebgdef.bg, 1, motif.continuebgdef.timer) | |
2603 | + main.f_drawBG(motif.continuebgdef.bg_data, motif.continuebgdef.bg, 1, motif.continuebgdef.timer, {320,240}) | |
2604 | 2604 | --draw fadein |
2605 | 2605 | animDraw(motif.continue_screen.fadein_data) |
2606 | 2606 | animUpdate(motif.continue_screen.fadein_data) |
@@ -54,7 +54,7 @@ local function f_play(t) | ||
54 | 54 | if k >= t.scenedef.startscene then |
55 | 55 | for i = 0, t.scene[k].end_time do |
56 | 56 | --end storyboard |
57 | - if esc() or main.f_btnPalNo(main.p1Cmd) > 0 then | |
57 | + if esc() or main.f_btnPalNo(main.p1Cmd) > 0 and t.scenedef.skipbutton > 0 then | |
58 | 58 | main.f_cmdInput() |
59 | 59 | refresh() |
60 | 60 | return |
@@ -75,7 +75,7 @@ local function f_play(t) | ||
75 | 75 | animDraw(t.scene[k].clearcolor_data) |
76 | 76 | --draw layerno = 0 backgrounds |
77 | 77 | if t.scene[k].bg_name ~= '' then |
78 | - main.f_drawBG(t.scene[k].bg_data, t[t.scene[k].bg_name .. 'def'], 0, i) | |
78 | + main.f_drawBG(t.scene[k].bg_data, t[t.scene[k].bg_name .. 'def'], 0, i, t.info.localcoord) | |
79 | 79 | end |
80 | 80 | --loop through layers in order |
81 | 81 | for k2, v2 in main.f_sortKeys(t.scene[k].layer) do |
@@ -103,7 +103,7 @@ local function f_play(t) | ||
103 | 103 | end |
104 | 104 | --draw layerno = 1 backgrounds |
105 | 105 | if t.scene[k].bg_name ~= '' then |
106 | - main.f_drawBG(t.scene[k].bg_data, t[t.scene[k].bg_name .. 'def'], 1, i) | |
106 | + main.f_drawBG(t.scene[k].bg_data, t[t.scene[k].bg_name .. 'def'], 1, i, t.info.localcoord) | |
107 | 107 | end |
108 | 108 | --fadein |
109 | 109 | if i <= t.scene[k].fadein_time then |
@@ -115,6 +115,13 @@ local function f_play(t) | ||
115 | 115 | animDraw(t.scene[k].fadeout_data) |
116 | 116 | animUpdate(t.scene[k].fadeout_data) |
117 | 117 | end |
118 | + if main.f_btnPalNo(main.p1Cmd) > 0 and t.scenedef.skipbutton <= 0 then | |
119 | + main.f_cmdInput() | |
120 | + refresh() | |
121 | + do | |
122 | + break | |
123 | + end | |
124 | + end | |
118 | 125 | main.f_cmdInput() |
119 | 126 | refresh() |
120 | 127 | end |
@@ -146,7 +153,7 @@ local function f_parse(path) | ||
146 | 153 | local t_default = |
147 | 154 | { |
148 | 155 | info = {localcoord = {320, 240}}, |
149 | - scenedef = {spr = '', snd = '', font = {[1] = 'font/f-6x9.fnt'}, font_height = {}, startscene = 0, font_data = {}}, | |
156 | + scenedef = {spr = '', snd = '', font = {[1] = 'font/f-6x9.fnt'}, font_height = {}, startscene = 0, skipbutton = 1, font_data = {}}, | |
150 | 157 | scene = {}, |
151 | 158 | ctrldef = {} |
152 | 159 | } |
@@ -160,6 +167,9 @@ local function f_parse(path) | ||
160 | 167 | if row:match('.+ctrldef') then --matched ctrldef start |
161 | 168 | bgctrl = row |
162 | 169 | bgctrl_match = bgctrl:match('^(.-ctrl)def') |
170 | + if t.ctrldef[bgdef .. 'def'][bgctrl] ~= nil then --Ctrldef名の重複を避ける | |
171 | + bgctrl = bgctrl..tostring(os.clock()) | |
172 | + end | |
163 | 173 | t.ctrldef[bgdef .. 'def'][bgctrl] = {} |
164 | 174 | t.ctrldef[bgdef .. 'def'][bgctrl].ctrl = {} |
165 | 175 | pos = t.ctrldef[bgdef .. 'def'][bgctrl] |
@@ -225,6 +235,7 @@ local function f_parse(path) | ||
225 | 235 | t.scene[row] = {} |
226 | 236 | pos = t.scene[row] |
227 | 237 | pos.layer = {} |
238 | + pos.sound = {} | |
228 | 239 | t_default.scene[row] = |
229 | 240 | { |
230 | 241 | end_time = 0, |
@@ -477,10 +488,10 @@ local function f_parse(path) | ||
477 | 488 | if t_bgdef[k2].window ~= nil then |
478 | 489 | animSetWindow( |
479 | 490 | anim, |
480 | - t_bgdef[k2].window[1], | |
481 | - t_bgdef[k2].window[2], | |
482 | - t_bgdef[k2].window[3] - t_bgdef[k2].window[1] + 1, | |
483 | - t_bgdef[k2].window[4] - t_bgdef[k2].window[2] + 1 | |
491 | + t_bgdef[k2].window[1] * 320/t.info.localcoord[1], | |
492 | + t_bgdef[k2].window[2] * 240/t.info.localcoord[2], | |
493 | + (t_bgdef[k2].window[3] - t_bgdef[k2].window[1] + 1)* 320/t.info.localcoord[1], | |
494 | + (t_bgdef[k2].window[4] - t_bgdef[k2].window[2] + 1) * 240/t.info.localcoord[2] | |
484 | 495 | ) |
485 | 496 | else |
486 | 497 | animSetWindow(anim, 0, 0, t.info.localcoord[1], t.info.localcoord[2]) |
@@ -484,66 +484,68 @@ func (a *Animation) UpdateSprite() { | ||
484 | 484 | } |
485 | 485 | } |
486 | 486 | } |
487 | - if int(a.drawidx) < len(a.frames)-1 { | |
488 | - for _, i := range a.interpolate_offset { | |
489 | - if a.drawidx+1 == i { | |
490 | - a.interpolate_offset_x = float32(a.frames[a.drawidx+1].X-a.frames[a.drawidx].X) / float32(a.curFrame().Time) * float32(a.time) | |
491 | - a.interpolate_offset_y = float32(a.frames[a.drawidx+1].Y-a.frames[a.drawidx].Y) / float32(a.curFrame().Time) * float32(a.time) | |
492 | - break | |
493 | - } | |
487 | + nextDrawidx := a.drawidx + 1 | |
488 | + if int(a.drawidx) >= len(a.frames)-1 { | |
489 | + nextDrawidx = a.loopstart | |
490 | + } | |
491 | + for _, i := range a.interpolate_offset { | |
492 | + if nextDrawidx == i { | |
493 | + a.interpolate_offset_x = float32(a.frames[nextDrawidx].X-a.frames[a.drawidx].X) / float32(a.curFrame().Time) * float32(a.time) | |
494 | + a.interpolate_offset_y = float32(a.frames[nextDrawidx].Y-a.frames[a.drawidx].Y) / float32(a.curFrame().Time) * float32(a.time) | |
495 | + break | |
494 | 496 | } |
495 | - for _, i := range a.interpolate_scale { | |
496 | - if a.drawidx+1 == i { | |
497 | - var drawframe_scale_x, nextframe_scale_x, drawframe_scale_y, nextframe_scale_y float32 = 1, 1, 1, 1 | |
498 | - if len(a.frames[a.drawidx].Ex) > 2 { | |
499 | - if len(a.frames[a.drawidx].Ex[2]) > 0 { | |
500 | - drawframe_scale_x = a.frames[a.drawidx].Ex[2][0] | |
501 | - } | |
502 | - if len(a.frames[a.drawidx].Ex[2]) > 1 { | |
503 | - drawframe_scale_y = a.frames[a.drawidx].Ex[2][1] | |
504 | - } | |
497 | + } | |
498 | + for _, i := range a.interpolate_scale { | |
499 | + if nextDrawidx == i { | |
500 | + var drawframe_scale_x, nextframe_scale_x, drawframe_scale_y, nextframe_scale_y float32 = 1, 1, 1, 1 | |
501 | + if len(a.frames[a.drawidx].Ex) > 2 { | |
502 | + if len(a.frames[a.drawidx].Ex[2]) > 0 { | |
503 | + drawframe_scale_x = a.frames[a.drawidx].Ex[2][0] | |
505 | 504 | } |
506 | - if len(a.frames[a.drawidx+1].Ex) > 2 { | |
507 | - if len(a.frames[a.drawidx+1].Ex[2]) > 0 { | |
508 | - nextframe_scale_x = a.frames[a.drawidx+1].Ex[2][0] | |
509 | - } | |
510 | - if len(a.frames[a.drawidx+1].Ex[2]) > 1 { | |
511 | - nextframe_scale_y = a.frames[a.drawidx+1].Ex[2][1] | |
512 | - } | |
505 | + if len(a.frames[a.drawidx].Ex[2]) > 1 { | |
506 | + drawframe_scale_y = a.frames[a.drawidx].Ex[2][1] | |
507 | + } | |
508 | + } | |
509 | + if len(a.frames[nextDrawidx].Ex) > 2 { | |
510 | + if len(a.frames[nextDrawidx].Ex[2]) > 0 { | |
511 | + nextframe_scale_x = a.frames[nextDrawidx].Ex[2][0] | |
512 | + } | |
513 | + if len(a.frames[nextDrawidx].Ex[2]) > 1 { | |
514 | + nextframe_scale_y = a.frames[nextDrawidx].Ex[2][1] | |
513 | 515 | } |
514 | - a.scale_x += (nextframe_scale_x - drawframe_scale_x) / float32(a.curFrame().Time) * float32(a.time) | |
515 | - a.scale_y += (nextframe_scale_y - drawframe_scale_y) / float32(a.curFrame().Time) * float32(a.time) | |
516 | - break | |
517 | 516 | } |
517 | + a.scale_x += (nextframe_scale_x - drawframe_scale_x) / float32(a.curFrame().Time) * float32(a.time) | |
518 | + a.scale_y += (nextframe_scale_y - drawframe_scale_y) / float32(a.curFrame().Time) * float32(a.time) | |
519 | + break | |
518 | 520 | } |
519 | - for _, i := range a.interpolate_angle { | |
520 | - if a.drawidx+1 == i { | |
521 | - var drawframe_angle, nextframe_angle float32 = 0, 0 | |
522 | - if len(a.frames[a.drawidx].Ex) > 2 { | |
523 | - if len(a.frames[a.drawidx].Ex[2]) > 2 { | |
524 | - drawframe_angle = a.frames[a.drawidx].Ex[2][2] | |
525 | - } | |
521 | + } | |
522 | + for _, i := range a.interpolate_angle { | |
523 | + if nextDrawidx == i { | |
524 | + var drawframe_angle, nextframe_angle float32 = 0, 0 | |
525 | + if len(a.frames[a.drawidx].Ex) > 2 { | |
526 | + if len(a.frames[a.drawidx].Ex[2]) > 2 { | |
527 | + drawframe_angle = a.frames[a.drawidx].Ex[2][2] | |
526 | 528 | } |
527 | - if len(a.frames[a.drawidx+1].Ex) > 2 { | |
528 | - if len(a.frames[a.drawidx+1].Ex[2]) > 2 { | |
529 | - nextframe_angle = a.frames[a.drawidx+1].Ex[2][2] | |
530 | - } | |
529 | + } | |
530 | + if len(a.frames[nextDrawidx].Ex) > 2 { | |
531 | + if len(a.frames[nextDrawidx].Ex[2]) > 2 { | |
532 | + nextframe_angle = a.frames[nextDrawidx].Ex[2][2] | |
531 | 533 | } |
532 | - a.angle += (nextframe_angle - drawframe_angle) / float32(a.curFrame().Time) * float32(a.time) | |
533 | - break | |
534 | 534 | } |
535 | + a.angle += (nextframe_angle - drawframe_angle) / float32(a.curFrame().Time) * float32(a.time) | |
536 | + break | |
535 | 537 | } |
536 | - if byte(a.interpolate_blend_srcalpha) != 1 || | |
537 | - byte(a.interpolate_blend_dstalpha) != 255 { | |
538 | - for _, i := range a.interpolate_blend { | |
539 | - if a.drawidx+1 == i { | |
540 | - a.interpolate_blend_srcalpha += (float32(a.frames[a.drawidx+1].SrcAlpha) - a.interpolate_blend_srcalpha) / float32(a.curFrame().Time) * float32(a.time) | |
541 | - a.interpolate_blend_dstalpha += (float32(a.frames[a.drawidx+1].DstAlpha) - a.interpolate_blend_dstalpha) / float32(a.curFrame().Time) * float32(a.time) | |
542 | - if byte(a.interpolate_blend_srcalpha) == 1 && byte(a.interpolate_blend_dstalpha) == 255 { | |
543 | - a.interpolate_blend_srcalpha = 0 | |
544 | - } | |
545 | - break | |
538 | + } | |
539 | + if byte(a.interpolate_blend_srcalpha) != 1 || | |
540 | + byte(a.interpolate_blend_dstalpha) != 255 { | |
541 | + for _, i := range a.interpolate_blend { | |
542 | + if nextDrawidx == i { | |
543 | + a.interpolate_blend_srcalpha += (float32(a.frames[nextDrawidx].SrcAlpha) - a.interpolate_blend_srcalpha) / float32(a.curFrame().Time) * float32(a.time) | |
544 | + a.interpolate_blend_dstalpha += (float32(a.frames[nextDrawidx].DstAlpha) - a.interpolate_blend_dstalpha) / float32(a.curFrame().Time) * float32(a.time) | |
545 | + if byte(a.interpolate_blend_srcalpha) == 1 && byte(a.interpolate_blend_dstalpha) == 255 { | |
546 | + a.interpolate_blend_srcalpha = 0 | |
546 | 547 | } |
548 | + break | |
547 | 549 | } |
548 | 550 | } |
549 | 551 | } |
@@ -4014,14 +4014,14 @@ func (c *Char) bind() { | ||
4014 | 4014 | if AbsF(c.bindFacing) == 2 { |
4015 | 4015 | f = c.bindFacing / 2 |
4016 | 4016 | } |
4017 | - c.setX(bt.pos[0] + f*c.bindPos[0]) | |
4017 | + c.setX(bt.pos[0]*bt.localscl/c.localscl + f*c.bindPos[0]) | |
4018 | 4018 | c.drawPos[0] += bt.drawPos[0] - bt.pos[0] |
4019 | 4019 | c.oldPos[0] += bt.oldPos[0] - bt.pos[0] |
4020 | 4020 | c.pushed = c.pushed || bt.pushed |
4021 | 4021 | c.ghv.xoff = 0 |
4022 | 4022 | } |
4023 | 4023 | if !math.IsNaN(float64(c.bindPos[1])) { |
4024 | - c.setY(bt.pos[1] + c.bindPos[1]) | |
4024 | + c.setY(bt.pos[1]*bt.localscl/c.localscl + c.bindPos[1]) | |
4025 | 4025 | c.drawPos[1] += bt.drawPos[1] - bt.pos[1] |
4026 | 4026 | c.oldPos[1] += bt.oldPos[1] - bt.pos[1] |
4027 | 4027 | c.ghv.yoff = 0 |