• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

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ão2403f3dadda74df7c8b5a01294492894d3514c5f (tree)
Hora2016-12-06 23:59:48
AutorSUEHIRO <supersuehiro@user...>
CommiterSUEHIRO

Mensagem de Log

キャラクターの読み込みやコマンドのremapの読み込み

Mudança Sumário

Diff

--- a/src/char.go
+++ b/src/char.go
@@ -5,153 +5,47 @@ import (
55 "strings"
66 )
77
8-type CharGlobalInfo struct {
9- def string
10- displayname string
11- author string
12- palkeymap [12]int
13- sff *Sff
14- snd *Snd
15- anim AnimationTable
16- palno, drawpalno int32
17- ver [2]int16
18- data struct {
19- life int32
20- power int32
21- attack int32
22- defence int32
23- fall struct {
24- defence_mul float32
25- }
26- liedown struct {
27- time int32
28- }
29- airjuggle int32
30- sparkno int32
31- guard struct {
32- sparkno int32
33- }
34- ko struct {
35- echo int32
36- }
37- volume int32
38- intpersistindex int32
39- floatpersistindex int32
40- }
41- velocity struct {
42- walk struct {
43- fwd float32
44- back float32
45- up struct {
46- x float32
47- }
48- down struct {
49- x float32
50- }
51- }
52- run struct {
53- fwd [2]float32
54- back [2]float32
55- up struct {
56- x float32
57- y float32
58- }
59- down struct {
60- x float32
61- y float32
62- }
63- }
64- jump struct {
65- neu [2]float32
66- back float32
67- fwd float32
68- up struct {
69- x float32
70- }
71- down struct {
72- x float32
73- }
74- }
75- runjump struct {
76- back [2]float32
77- fwd [2]float32
78- up struct {
79- x float32
80- }
81- down struct {
82- x float32
83- }
84- }
85- airjump struct {
86- neu [2]float32
87- back float32
88- fwd float32
89- up struct {
90- x float32
91- }
92- down struct {
93- x float32
94- }
95- }
96- air struct {
97- gethit struct {
98- groundrecover [2]float32
99- airrecover struct {
100- mul [2]float32
101- add [2]float32
102- back float32
103- fwd float32
104- up float32
105- down float32
106- }
107- }
108- }
8+type CharData struct {
9+ life int32
10+ power int32
11+ attack int32
12+ defence int32
13+ fall struct {
14+ defence_mul float32
10915 }
110- movement struct {
111- airjump struct {
112- num int32
113- height int32
114- }
115- yaccel float32
116- stand struct {
117- friction float32
118- friction_threshold float32
119- }
120- crouch struct {
121- friction float32
122- friction_threshold float32
123- }
124- air struct {
125- gethit struct {
126- groundlevel float32
127- groundrecover struct {
128- ground struct {
129- threshold float32
130- }
131- groundlevel float32
132- }
133- airrecover struct {
134- threshold float32
135- yaccel float32
136- }
137- trip struct {
138- groundlevel float32
139- }
140- }
141- }
142- down struct {
143- bounce struct {
144- offset [2]float32
145- yaccel float32
146- groundlevel float32
147- }
148- friction struct {
149- threshold float32
150- }
151- }
16+ liedown struct {
17+ time int32
18+ }
19+ airjuggle int32
20+ sparkno int32
21+ guard struct {
22+ sparkno int32
23+ }
24+ ko struct {
25+ echo int32
15226 }
153- wakewakaLength int
27+ volume int32
28+ intpersistindex int32
29+ floatpersistindex int32
15430 }
31+
32+func (cd *CharData) init() {
33+ *cd = CharData{}
34+ cd.life = 1000
35+ cd.power = 3000
36+ cd.attack = 100
37+ cd.defence = 100
38+ cd.fall.defence_mul = 1.5
39+ cd.liedown.time = 60
40+ cd.airjuggle = 15
41+ cd.sparkno = 2
42+ cd.guard.sparkno = 40
43+ cd.ko.echo = 0
44+ cd.volume = 256
45+ cd.intpersistindex = 0
46+ cd.floatpersistindex = 0
47+}
48+
15549 type CharSize struct {
15650 xscale float32
15751 yscale float32
@@ -192,8 +86,191 @@ type CharSize struct {
19286 width int32
19387 }
19488 }
89+
90+func (cs *CharSize) init() {
91+ *cs = CharSize{}
92+ cs.xscale = 1
93+ cs.yscale = 1
94+ cs.ground.back = 15
95+ cs.ground.front = 16
96+ cs.air.back = 12
97+ cs.air.front = 12
98+ cs.height = 60
99+ cs.attack.dist = 160
100+ cs.proj.attack.dist = 90
101+ cs.proj.doscale = 0
102+ cs.proj.xscale = 1
103+ cs.proj.yscale = 1
104+ cs.head.pos = [2]int32{-5, -90}
105+ cs.mid.pos = [2]int32{-5, -60}
106+ cs.shadowoffset = 0
107+ cs.draw.offset = [2]int32{0, 0}
108+ cs.z.width = 3
109+ cs.attack.z.width = [2]int32{4, 4}
110+}
111+
112+type CharVelocity struct {
113+ walk struct {
114+ fwd float32
115+ back float32
116+ up struct {
117+ x float32
118+ }
119+ down struct {
120+ x float32
121+ }
122+ }
123+ run struct {
124+ fwd [2]float32
125+ back [2]float32
126+ up struct {
127+ x float32
128+ y float32
129+ }
130+ down struct {
131+ x float32
132+ y float32
133+ }
134+ }
135+ jump struct {
136+ neu [2]float32
137+ back float32
138+ fwd float32
139+ up struct {
140+ x float32
141+ }
142+ down struct {
143+ x float32
144+ }
145+ }
146+ runjump struct {
147+ back [2]float32
148+ fwd [2]float32
149+ up struct {
150+ x float32
151+ }
152+ down struct {
153+ x float32
154+ }
155+ }
156+ airjump struct {
157+ neu [2]float32
158+ back float32
159+ fwd float32
160+ up struct {
161+ x float32
162+ }
163+ down struct {
164+ x float32
165+ }
166+ }
167+ air struct {
168+ gethit struct {
169+ groundrecover [2]float32
170+ airrecover struct {
171+ mul [2]float32
172+ add [2]float32
173+ back float32
174+ fwd float32
175+ up float32
176+ down float32
177+ }
178+ }
179+ }
180+}
181+
182+func (cv *CharVelocity) init() {
183+ *cv = CharVelocity{}
184+ cv.air.gethit.groundrecover = [2]float32{-0.15, -3.5}
185+ cv.air.gethit.airrecover.mul = [2]float32{0.5, 0.2}
186+ cv.air.gethit.airrecover.add = [2]float32{0.0, -4.5}
187+ cv.air.gethit.airrecover.back = -1.0
188+ cv.air.gethit.airrecover.fwd = 0.0
189+ cv.air.gethit.airrecover.up = -2.0
190+ cv.air.gethit.airrecover.down = 1.5
191+}
192+
193+type CharMovement struct {
194+ airjump struct {
195+ num int32
196+ height int32
197+ }
198+ yaccel float32
199+ stand struct {
200+ friction float32
201+ friction_threshold float32
202+ }
203+ crouch struct {
204+ friction float32
205+ friction_threshold float32
206+ }
207+ air struct {
208+ gethit struct {
209+ groundlevel float32
210+ groundrecover struct {
211+ ground struct {
212+ threshold float32
213+ }
214+ groundlevel float32
215+ }
216+ airrecover struct {
217+ threshold float32
218+ yaccel float32
219+ }
220+ trip struct {
221+ groundlevel float32
222+ }
223+ }
224+ }
225+ down struct {
226+ bounce struct {
227+ offset [2]float32
228+ yaccel float32
229+ groundlevel float32
230+ }
231+ friction_threshold float32
232+ }
233+}
234+
235+func (cm *CharMovement) init() {
236+ *cm = CharMovement{}
237+ cm.airjump.num = 0
238+ cm.airjump.height = 35
239+ cm.yaccel = 0.44
240+ cm.stand.friction = 0.85
241+ cm.stand.friction_threshold = 2.0
242+ cm.crouch.friction = 0.82
243+ cm.crouch.friction_threshold = 0.0
244+ cm.air.gethit.groundlevel = 10.0
245+ cm.air.gethit.groundrecover.ground.threshold = -20.0
246+ cm.air.gethit.groundrecover.groundlevel = 10.0
247+ cm.air.gethit.airrecover.threshold = -1.0
248+ cm.air.gethit.airrecover.yaccel = 0.35
249+ cm.air.gethit.trip.groundlevel = 15.0
250+ cm.down.bounce.offset = [2]float32{0.0, 20.0}
251+ cm.down.bounce.yaccel = 0.4
252+ cm.down.bounce.groundlevel = 12.0
253+ cm.down.friction_threshold = 0.05
254+}
255+
256+type CharGlobalInfo struct {
257+ def string
258+ displayname string
259+ author string
260+ palkeymap [12]int
261+ sff *Sff
262+ snd *Snd
263+ anim AnimationTable
264+ palno, drawpalno int32
265+ ver [2]int16
266+ data CharData
267+ velocity CharVelocity
268+ movement CharMovement
269+ wakewakaLength int
270+}
195271 type Char struct {
196272 name string
273+ cmd []CommandList
197274 key int
198275 helperindex int
199276 playerno int
@@ -280,36 +357,9 @@ func (c *Char) load(def string) error {
280357 }); err != nil {
281358 return err
282359 }
283- gi.data.life = 1000
284- gi.data.power = 3000
285- gi.data.attack = 100
286- gi.data.defence = 100
287- gi.data.fall.defence_mul = 1.5
288- gi.data.liedown.time = 60
289- gi.data.airjuggle = 15
290- gi.data.sparkno = 2
291- gi.data.guard.sparkno = 40
292- gi.data.ko.echo = 0
293- gi.data.volume = 256
294- gi.data.intpersistindex = 0
295- gi.data.floatpersistindex = 0
296- c.size.xscale = 1
297- c.size.yscale = 1
298- c.size.ground.back = 15
299- c.size.ground.front = 16
300- c.size.air.back = 12
301- c.size.air.front = 12
302- c.size.height = 60
303- c.size.attack.dist = 160
304- c.size.proj.attack.dist = 90
305- c.size.proj.doscale = 0
306- c.size.proj.xscale, c.size.proj.yscale = 1, 1
307- c.size.head.pos = [2]int32{-5, -90}
308- c.size.mid.pos = [2]int32{-5, -60}
309- c.size.shadowoffset = 0
310- c.size.draw.offset = [2]int32{0, 0}
311- c.size.z.width = 3
312- c.size.attack.z.width = [2]int32{4, 4}
360+ gi.data.init()
361+ c.size.init()
362+ gi.velocity.init()
313363 data, size, velocity, movement := true, true, true, true
314364 for i < len(lines) {
315365 is, name, _ := ReadIniSection(lines, &i)
@@ -325,7 +375,9 @@ func (c *Char) load(def string) error {
325375 if is.ReadI32("fall.defence_up", &i32) {
326376 gi.data.fall.defence_mul = (float32(i32) + 100) / 100
327377 }
328- is.ReadI32("liedown.time", &gi.data.liedown.time)
378+ if is.ReadI32("liedown.time", &i32) {
379+ gi.data.liedown.time = Max(1, i32)
380+ }
329381 is.ReadI32("airjuggle", &gi.data.airjuggle)
330382 is.ReadI32("sparkno", &gi.data.sparkno)
331383 is.ReadI32("guard.sparkno", &gi.data.guard.sparkno)
@@ -368,13 +420,116 @@ func (c *Char) load(def string) error {
368420 case "velocity":
369421 if velocity {
370422 velocity = false
423+ is.ReadF32("walk.fwd", &gi.velocity.walk.fwd)
424+ is.ReadF32("walk.back", &gi.velocity.walk.back)
425+ is.ReadF32("walk.up.x", &gi.velocity.walk.up.x)
426+ is.ReadF32("walk.down.x", &gi.velocity.walk.down.x)
427+ is.ReadF32("run.fwd", &gi.velocity.run.fwd[0], &gi.velocity.run.fwd[1])
428+ is.ReadF32("run.back",
429+ &gi.velocity.run.back[0], &gi.velocity.run.back[1])
430+ is.ReadF32("run.up.x", &gi.velocity.run.up.x)
431+ is.ReadF32("run.up.y", &gi.velocity.run.up.y)
432+ is.ReadF32("run.down.x", &gi.velocity.run.down.x)
433+ is.ReadF32("run.down.y", &gi.velocity.run.down.y)
434+ is.ReadF32("jump.neu",
435+ &gi.velocity.jump.neu[0], &gi.velocity.jump.neu[1])
436+ is.ReadF32("jump.back", &gi.velocity.jump.back)
437+ is.ReadF32("jump.fwd", &gi.velocity.jump.fwd)
438+ is.ReadF32("jump.up.x", &gi.velocity.jump.up.x)
439+ is.ReadF32("jump.down.x", &gi.velocity.jump.down.x)
440+ is.ReadF32("runjump.back",
441+ &gi.velocity.runjump.back[0], &gi.velocity.runjump.back[1])
442+ is.ReadF32("runjump.fwd",
443+ &gi.velocity.runjump.fwd[0], &gi.velocity.runjump.fwd[1])
444+ is.ReadF32("runjump.up.x", &gi.velocity.runjump.up.x)
445+ is.ReadF32("runjump.down.x", &gi.velocity.runjump.down.x)
446+ is.ReadF32("airjump.neu",
447+ &gi.velocity.airjump.neu[0], &gi.velocity.airjump.neu[1])
448+ is.ReadF32("airjump.back", &gi.velocity.airjump.back)
449+ is.ReadF32("airjump.fwd", &gi.velocity.airjump.fwd)
450+ is.ReadF32("airjump.up.x", &gi.velocity.airjump.up.x)
451+ is.ReadF32("airjump.down.x", &gi.velocity.airjump.down.x)
452+ is.ReadF32("air.gethit.groundrecover",
453+ &gi.velocity.air.gethit.groundrecover[0],
454+ &gi.velocity.air.gethit.groundrecover[1])
455+ is.ReadF32("air.gethit.airrecover.mul",
456+ &gi.velocity.air.gethit.airrecover.mul[0],
457+ &gi.velocity.air.gethit.airrecover.mul[1])
458+ is.ReadF32("air.gethit.airrecover.add",
459+ &gi.velocity.air.gethit.airrecover.add[0],
460+ &gi.velocity.air.gethit.airrecover.add[1])
461+ is.ReadF32("air.gethit.airrecover.back",
462+ &gi.velocity.air.gethit.airrecover.back)
463+ is.ReadF32("air.gethit.airrecover.fwd",
464+ &gi.velocity.air.gethit.airrecover.fwd)
465+ is.ReadF32("air.gethit.airrecover.up",
466+ &gi.velocity.air.gethit.airrecover.up)
467+ is.ReadF32("air.gethit.airrecover.down",
468+ &gi.velocity.air.gethit.airrecover.down)
371469 }
372470 case "movement":
373471 if movement {
374472 movement = false
473+ is.ReadI32("airjump.num", &gi.movement.airjump.num)
474+ is.ReadI32("airjump.height", &gi.movement.airjump.height)
475+ is.ReadF32("yaccel", &gi.movement.yaccel)
476+ is.ReadF32("stand.friction", &gi.movement.stand.friction)
477+ is.ReadF32("stand.friction.threshold",
478+ &gi.movement.stand.friction_threshold)
479+ is.ReadF32("crouch.friction", &gi.movement.crouch.friction)
480+ is.ReadF32("crouch.friction.threshold",
481+ &gi.movement.crouch.friction_threshold)
482+ is.ReadF32("air.gethit.groundlevel",
483+ &gi.movement.air.gethit.groundlevel)
484+ is.ReadF32("air.gethit.groundrecover.ground.threshold",
485+ &gi.movement.air.gethit.groundrecover.ground.threshold)
486+ is.ReadF32("air.gethit.groundrecover.groundlevel",
487+ &gi.movement.air.gethit.groundrecover.groundlevel)
488+ is.ReadF32("air.gethit.airrecover.threshold",
489+ &gi.movement.air.gethit.airrecover.threshold)
490+ is.ReadF32("air.gethit.airrecover.yaccel",
491+ &gi.movement.air.gethit.airrecover.yaccel)
492+ is.ReadF32("air.gethit.trip.groundlevel",
493+ &gi.movement.air.gethit.trip.groundlevel)
494+ is.ReadF32("down.bounce.offset",
495+ &gi.movement.down.bounce.offset[0],
496+ &gi.movement.down.bounce.offset[1])
497+ is.ReadF32("down.bounce.yaccel", &gi.movement.down.bounce.yaccel)
498+ is.ReadF32("down.bounce.groundlevel",
499+ &gi.movement.down.bounce.groundlevel)
500+ is.ReadF32("down.friction.threshold",
501+ &gi.movement.down.friction_threshold)
375502 }
376503 }
377504 }
378- unimplemented()
505+ if LoadFile(&sprite, def, func(filename string) error {
506+ var err error
507+ gi.sff, err = LoadSff(filename, false)
508+ return err
509+ }); err != nil {
510+ return err
511+ }
512+ if LoadFile(&anim, def, func(filename string) error {
513+ str, err := LoadText(filename)
514+ if err != nil {
515+ return err
516+ }
517+ lines, i := SplitAndTrim(str, "\n"), 0
518+ gi.anim = ReadAnimationTable(gi.sff, lines, &i)
519+ return nil
520+ }); err != nil {
521+ return err
522+ }
523+ if len(sound) > 0 {
524+ if LoadFile(&sound, def, func(filename string) error {
525+ var err error
526+ gi.snd, err = LoadSnd(filename)
527+ return err
528+ }); err != nil {
529+ return err
530+ }
531+ } else {
532+ gi.snd = newSnd()
533+ }
379534 return nil
380535 }
--- a/src/compiler.go
+++ b/src/compiler.go
@@ -1,6 +1,9 @@
11 package main
22
3-import "fmt"
3+import (
4+ "fmt"
5+ "strings"
6+)
47
58 type ByteCode struct{}
69
@@ -43,6 +46,63 @@ func (c *Compiler) Compile(n int, def string) (*ByteCode, error) {
4346 }
4447 }
4548 }
49+ if err := LoadFile(&cmd, def, func(filename string) error {
50+ str, err := LoadText(filename)
51+ if err != nil {
52+ return err
53+ }
54+ lines, i = SplitAndTrim(str, "\n"), 0
55+ return nil
56+ }); err != nil {
57+ return nil, err
58+ }
59+ if sys.chars[n][0].cmd == nil {
60+ sys.chars[n][0].cmd = make([]CommandList, MaxSimul*2)
61+ b := newCommandBuffer()
62+ for i := range sys.chars[n][0].cmd {
63+ sys.chars[n][0].cmd[i] = *NewCommandList(b)
64+ }
65+ }
66+ cl, remap, defaults := &sys.chars[n][0].cmd[n], true, true
67+ ckr := NewCommandKeyRemap()
68+ for i < len(lines) {
69+ is, name, _ := ReadIniSection(lines, &i)
70+ switch name {
71+ case "remap":
72+ if remap {
73+ remap = false
74+ rm := func(name string, k, nk *CommandKey) {
75+ switch strings.ToLower(is[name]) {
76+ case "x":
77+ *k, *nk = CK_x, CK_nx
78+ case "y":
79+ *k, *nk = CK_y, CK_ny
80+ case "z":
81+ *k, *nk = CK_z, CK_nz
82+ case "a":
83+ *k, *nk = CK_a, CK_na
84+ case "b":
85+ *k, *nk = CK_b, CK_nb
86+ case "c":
87+ *k, *nk = CK_c, CK_nc
88+ case "s":
89+ *k, *nk = CK_s, CK_ns
90+ }
91+ }
92+ rm("x", &ckr.x, &ckr.nx)
93+ rm("y", &ckr.y, &ckr.ny)
94+ rm("z", &ckr.z, &ckr.nz)
95+ rm("a", &ckr.a, &ckr.na)
96+ rm("b", &ckr.b, &ckr.nb)
97+ rm("c", &ckr.c, &ckr.nc)
98+ rm("s", &ckr.s, &ckr.ns)
99+ }
100+ case "defaults":
101+ if defaults {
102+ defaults = false
103+ }
104+ }
105+ }
46106 unimplemented()
47107 return bc, nil
48108 }