• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

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

Go で書き直した Ikemen


Commit MetaInfo

Revisionda016619bdedf5fdfbedd6769261c9a6718c0714 (tree)
Zeit2016-12-02 23:59:36
AutorSUEHIRO <supersuehiro@user...>
CommiterSUEHIRO

Log Message

エラーになるところを書いていく

Ändern Zusammenfassung

Diff

--- a/src/char.go
+++ b/src/char.go
@@ -1,4 +1,7 @@
11 package main
22
3-type CharGlobalInfo struct{ drawpalno int32 }
3+type CharGlobalInfo struct {
4+ drawpalno int32
5+ wakewakaLength int
6+}
47 type Char struct{}
--- a/src/compiler.go
+++ b/src/compiler.go
@@ -1,3 +1,4 @@
11 package main
22
3+type ByteCode struct{}
34 type Compiler struct{}
--- a/src/input.go
+++ b/src/input.go
@@ -70,12 +70,14 @@ const (
7070 var keySatate = make(map[glfw.Key]bool)
7171
7272 func keyCallback(_ *glfw.Window, key glfw.Key, _ int,
73- action glfw.Action, _ glfw.ModifierKey) {
73+ action glfw.Action, mk glfw.ModifierKey) {
7474 switch action {
7575 case glfw.Release:
7676 keySatate[key] = false
7777 case glfw.Press:
7878 keySatate[key] = true
79+ sys.esc = sys.esc ||
80+ key == glfw.KeyEscape && mk&(glfw.ModControl|glfw.ModAlt) == 0
7981 }
8082 }
8183
--- a/src/script.go
+++ b/src/script.go
@@ -130,6 +130,10 @@ func scriptCommonInit(l *lua.LState) {
130130 sys.bgm.Open(strArg(l, 1))
131131 return 0
132132 })
133+ luaRegister(l, "esc", func(l *lua.LState) int {
134+ l.Push(lua.LBool(sys.esc))
135+ return 1
136+ })
133137 luaRegister(l, "setRoundTime", func(l *lua.LState) int {
134138 sys.roundTime = int32(numArg(l, 1))
135139 return 0
--- a/src/system.go
+++ b/src/system.go
@@ -5,6 +5,7 @@ import (
55 "github.com/go-gl/glfw/v3.2/glfw"
66 "github.com/timshannon/go-openal/openal"
77 "github.com/yuin/gopher-lua"
8+ "runtime"
89 "strings"
910 "time"
1011 )
@@ -30,7 +31,17 @@ var sys = System{
3031 match: 1,
3132 inputRemap: [...]int{0, 1, 2, 3, 4, 5, 6, 7},
3233 listenPort: "7500",
33- loader: *newLoader()}
34+ loader: *newLoader(),
35+ numSimul: [2]int{2, 2},
36+ numTurns: [2]int{2, 2}}
37+
38+type TeamMode int32
39+
40+const (
41+ TM_Single TeamMode = iota
42+ TM_Simul
43+ TM_Turns
44+)
3445
3546 type System struct {
3647 randseed int32
@@ -73,6 +84,10 @@ type System struct {
7384 loader Loader
7485 chars [MaxSimul * 2][]*Char
7586 cgi [MaxSimul * 2]CharGlobalInfo
87+ tmode [2]TeamMode
88+ numSimul [2]int
89+ numTurns [2]int
90+ esc bool
7691 }
7792
7893 func (s *System) init(w, h int32) *lua.LState {
@@ -133,6 +148,7 @@ func (s *System) await(fps int) {
133148 }
134149 s.frameSkip = true
135150 }
151+ s.esc = false
136152 glfw.PollEvents()
137153 s.gameEnd = s.window.ShouldClose()
138154 if !s.frameSkip {
@@ -280,7 +296,7 @@ func (s *Select) AddStage(def string) error {
280296 return nil
281297 }
282298 func (s *Select) ClearSelected() {
283- s.selected = [2][][2]int{[][2]int{}, [][2]int{}}
299+ s.selected = [2][][2]int{}
284300 s.selectedStageNo = -1
285301 }
286302
@@ -299,11 +315,44 @@ type Loader struct {
299315 loadExit chan LoaderState
300316 compiler *Compiler
301317 err error
318+ code [MaxSimul * 2]*ByteCode
302319 }
303320
304321 func newLoader() *Loader {
305322 return &Loader{state: LS_NotYet, loadExit: make(chan LoaderState, 1)}
306323 }
324+func (l *Loader) loadChar(pn int) int {
325+ nsel := len(sys.sel.selected[pn&1])
326+ if sys.tmode[pn&1] == TM_Simul {
327+ if pn>>1 >= sys.numSimul[pn&1] {
328+ l.code[pn] = nil
329+ sys.chars[pn] = nil
330+ return 1
331+ }
332+ } else if pn >= 2 {
333+ return 0
334+ }
335+ if sys.tmode[pn&1] == TM_Turns && nsel < sys.numTurns[pn&1] {
336+ return 0
337+ }
338+ memberNo := pn >> 1
339+ if sys.tmode[pn&1] == TM_Turns {
340+ memberNo = int(sys.wins[^pn&1])
341+ }
342+ if nsel <= memberNo {
343+ return 0
344+ }
345+ unimplemented()
346+ return 1
347+}
348+func (l *Loader) loadStage() bool {
349+ unimplemented()
350+ return true
351+}
352+func (l *Loader) stateCompile() bool {
353+ unimplemented()
354+ return true
355+}
307356 func (l *Loader) load() {
308357 defer func() { l.loadExit <- l.state }()
309358 charDone, codeDone, stageDone := make([]bool, len(sys.chars)), false, false
@@ -316,7 +365,43 @@ func (l *Loader) load() {
316365 return true
317366 }
318367 for !codeDone || !stageDone || !allCharDone() {
319- unimplemented()
368+ runtime.LockOSThread()
369+ for i, b := range charDone {
370+ if !b {
371+ result := l.loadChar(i)
372+ if result > 0 {
373+ charDone[i] = true
374+ } else if result < 0 {
375+ l.state = LS_Error
376+ return
377+ }
378+ }
379+ }
380+ for i := 0; i < 2; i++ {
381+ if !charDone[i+2] && len(sys.sel.selected[i]) > 0 &&
382+ sys.tmode[i] != TM_Simul {
383+ for j := i + 2; j < len(sys.chars); j += 2 {
384+ sys.chars[j], l.code[j], charDone[j] = nil, nil, true
385+ sys.cgi[j].wakewakaLength = 0
386+ }
387+ }
388+ }
389+ if !stageDone && sys.sel.selectedStageNo >= 0 {
390+ if !l.loadStage() {
391+ l.state = LS_Error
392+ return
393+ }
394+ stageDone = true
395+ }
396+ runtime.UnlockOSThread()
397+ if !codeDone && allCharDone() {
398+ if !l.stateCompile() {
399+ l.state = LS_Error
400+ return
401+ }
402+ codeDone = true
403+ }
404+ time.Sleep(10 * time.Millisecond)
320405 if sys.gameEnd {
321406 l.state = LS_Cancel
322407 }