From 3098440644768f86fbd0a9cfdc77a0ce810bcb7b Mon Sep 17 00:00:00 2001 From: Trevor Peterson Date: Mon, 19 Nov 2012 16:35:27 -0700 Subject: [PATCH 1/4] Revert "Finally moved Choose2 -> Choose and Map2 -> Map" This reverts commit 4a97a272b7342bb15f038ad6b3e53cf72ad94436. --- util/algorithm/generic.go | 60 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/util/algorithm/generic.go b/util/algorithm/generic.go index 96849aa6..a9ba4a5e 100644 --- a/util/algorithm/generic.go +++ b/util/algorithm/generic.go @@ -7,11 +7,37 @@ import ( type Chooser func(interface{}) bool +// Given a slice and a Chooser, returns a slice of the same type as the input +// slice that contains only those elements of the input slice for which +// choose() returns true. The elements of the returned slice will be in the +// same order that they were in in the input slice. +func Choose(_a interface{}, choose Chooser) interface{} { + a := reflect.ValueOf(_a) + if a.Kind() != reflect.Slice { + panic(fmt.Sprintf("Can only Choose from a slice, not a %v", a)) + } + count := 0 + for i := 0; i < a.Len(); i++ { + if choose(a.Index(i).Interface()) { + count++ + } + } + ret := reflect.MakeSlice(a.Type(), count, count) + cur := 0 + for i := 0; i < a.Len(); i++ { + if choose(a.Index(i).Interface()) { + ret.Index(cur).Set(a.Index(i)) + cur++ + } + } + return ret.Interface() +} + // // Given a pointer to a slice and a Chooser, type as the input // // slice that contains only those elements of the input slice for which // // choose() returns true. The elements of the returned slice will be in the // // same order that they were in in the input slice. -func Choose(_a interface{}, chooser interface{}) { +func Choose2(_a interface{}, chooser interface{}) { a := reflect.ValueOf(_a) if a.Kind() != reflect.Ptr || a.Elem().Kind() != reflect.Slice { panic(fmt.Sprintf("Can only Choose from a pointer to a slice, not a %v", a)) @@ -40,17 +66,37 @@ func Choose(_a interface{}, chooser interface{}) { out = c.Call(in) if out[0].Bool() { if count > 0 { - slice.Index(i - count).Set(slice.Index(i)) + slice.Index(i-count).Set(slice.Index(i)) } } else { count++ } } - slice.Set(slice.Slice(0, slice.Len()-count)) + slice.Set(slice.Slice(0, slice.Len() - count)) } type Mapper func(a interface{}) interface{} +func Map(_a interface{}, _b interface{}, mapper Mapper) interface{} { + a := reflect.ValueOf(_a) + if a.Kind() != reflect.Slice { + panic(fmt.Sprintf("Can only Map from a slice, not a %v", a)) + } + + b := reflect.ValueOf(_b) + if b.Kind() != reflect.Slice { + panic(fmt.Sprintf("Can only Map to a slice, not a %v", b)) + } + + ret := reflect.MakeSlice(b.Type(), a.Len(), a.Len()) + for i := 0; i < a.Len(); i++ { + el := reflect.ValueOf(mapper(a.Index(i).Interface())) + ret.Index(i).Set(el) + } + + return ret.Interface() +} + func Map2(_in interface{}, _out interface{}, mapper interface{}) { in := reflect.ValueOf(_in) if in.Kind() != reflect.Slice { @@ -90,3 +136,11 @@ func Map2(_in interface{}, _out interface{}, mapper interface{}) { out.Elem().Index(i).Set(v[0]) } } + + + + + + + + From cc7e006afcf448fe6cfea1e0c6995f14f7883891 Mon Sep 17 00:00:00 2001 From: Trevor Peterson Date: Tue, 20 Nov 2012 12:01:03 -0700 Subject: [PATCH 2/4] changes --- ai/README.md | 29 ----- ai/ai.go | 132 --------------------- ai/ai_test.go | 132 --------------------- ai/all_specs_test.go | 16 --- ai/sample.png | Bin 7443 -> 0 bytes ai/state.xgml | 255 ---------------------------------------- gos/cgo_windows.go | 4 +- gui/check_box.go | 4 +- gui/combo.go | 2 +- gui/file_chooser.go | 2 +- gui/gui.go | 4 +- gui/scroll.go | 2 +- gui/tables.go | 2 +- gui/text.go | 10 +- gui/text_edit_line.go | 4 +- gui/text_line.go | 9 +- gui/widgets.go | 4 +- sprite/shared_sprite.go | 4 +- sprite/sheet.go | 10 +- sprite/sprite.go | 10 +- system/system.go | 2 +- 21 files changed, 38 insertions(+), 599 deletions(-) delete mode 100644 ai/README.md delete mode 100644 ai/ai.go delete mode 100644 ai/ai_test.go delete mode 100644 ai/all_specs_test.go delete mode 100644 ai/sample.png delete mode 100644 ai/state.xgml diff --git a/ai/README.md b/ai/README.md deleted file mode 100644 index 65a723f6..00000000 --- a/ai/README.md +++ /dev/null @@ -1,29 +0,0 @@ -The ai package provides a way of having a program run user-code at runtime. This is done using two separate packages, yedparse and polish. - - yedparse: github.com/runningwild/yedparse - polish: github.com/runningwild/Polish - - -An ai script is supplied as a yed graph saved as a .xgml file. The format is as follows: - - * There must be exactly one start node, specified by being labeled with the text 'start', this node should have exactly one edge leading to another node. It is this node at which the graph will begin evaluating. - * Each node should have a single expression in polish notation that will be evaluated using the polish package. The functions available to the expression should be known a-priori. - * Each node may have any number of output edges colored black. - * Each node may have output edges colored either red or green, but if there are any red edges there must be at least one green edge and vice-versa. - * If there are any red or green output edges from a node then when that node's expression is evaluated it must evaluate to either true or false. If it evaluates to true then an edge is randomly selected among all output edges that are colored either green or black. If it evaluates to false then an edge is randomly selected among all output edges that are colored either red or black. The selected edge is followed to find the next node to evaluate. - * If there are no output edges that are colored green or red then when that node's expression is evaluated it does not need to evaluate to anything. After evaluating an edge is randomly selected out of all output edges (which are implicitly colored black), and that edge is followed to find the next node to evaluate. - - -![sample ai graph](/runningwild/go-glop/raw/master/ai/sample.png) - -The following functions and variables are used in the above graph: - - numVisibleEnemies - distBetween - nearestEnemy - attack - advanceTowards - done - me - -There are two nodes with red and green output edges, their expressions both evaluate to a boolean value. There are two nodes (other than the start node) with only black output edges, these nodes do not evaluate to boolean values, but that is ok since the result of the expression will never be checked since there are no red or green output edges. diff --git a/ai/ai.go b/ai/ai.go deleted file mode 100644 index 23988e2c..00000000 --- a/ai/ai.go +++ /dev/null @@ -1,132 +0,0 @@ -package ai - -import ( - "fmt" - "github.com/runningwild/yedparse" - "github.com/runningwild/polish" - "math/rand" -) - -type Error struct { - ErrorString string -} -func (e *Error) Error() string { - return e.ErrorString -} - -var InterruptError error = &Error{ "Evaluation was terminated due to an interrupt." } -var TermError error = &Error{ "Evaluation was terminated early." } -var StartError error = &Error{ "No start node was found." } - -type AiGraph struct { - Graph *yed.Graph - Context *polish.Context - - // If a signal is sent along this channel it will terminate evaluation with - // the error that was sent - term chan error -} - -func NewGraph() *AiGraph { - return &AiGraph{ - term: make(chan error, 1), - } -} - -func (aig *AiGraph) Term() chan<- error { - return aig.term -} - -func (aig *AiGraph) subEval(labels *[]string, node *yed.Node) (out_node *yed.Node, err error) { - defer func() { - if r := recover(); r != nil { - err = &Error{fmt.Sprintf("%v", r)} - } - } () - select { - case err := <-aig.term: - return nil, err - - default: - } - *labels = append(*labels, node.Label()) - res, err := aig.Context.Eval(node.Label()) - if err != nil { - return nil, err - } - var red,green,black []*yed.Edge - for i := 0; i < node.NumOutputs(); i++ { - edge := node.Output(i) - r,g,b,_ := edge.RGBA() - if r > 200 && g < 100 && b < 100 { - red = append(red, edge) - } else if g > 200 && r < 100 && b < 100 { - green = append(green, edge) - } else { - black = append(black, edge) - } - } - if (len(red) == 0) != (len(green) == 0) { - panic("A node cannot have red edges without green edges or vice versa.") - } - - // A node can have green, red, and black edges. In this case the condition - // will be evaluated and if true either a green or black edge will be - // traversed, and if false a red or black edge will be traversed. - - var edges []*yed.Edge - if len(green) > 0 { - for _,edge := range black { - red = append(red, edge) - green = append(green, edge) - } - if len(res) != 1 { - panic("Needed to evaluate a node, but it didn't leave exactly one value after evalutation.") - } - if res[0].Bool() { - edges = green - } else { - edges = red - } - } else { - edges = black - } - - if len(edges) == 0 { - return nil, nil - } - follow := edges[rand.Intn(len(edges))] - return follow.Dst(), nil -} - -// chunk_size is the number of nodes that will be evaluated at a time. -// After that many nodes are evaluated, if evaluation has not already -// terminated, cont will be called and evaluation will only continue if -// cont returns true. -func (aig *AiGraph) Eval(chunk_size int, cont func() bool) ([]string, error) { - var labels []string - var node *yed.Node - for i := 0; i < aig.Graph.NumNodes(); i++ { - node = aig.Graph.Node(i) - if node.Label() == "start" { - break - } - } - if node == nil || node.NumOutputs() == 0 { - return labels, StartError - } - node = node.Output(0).Dst() - var err error - for node != nil { - for i := 0; i < chunk_size && node != nil; i++ { - node, err = aig.subEval(&labels, node) - if err != nil { - return labels, err - } - } - if !cont() { - break - } - } - return labels, nil -} diff --git a/ai/ai_test.go b/ai/ai_test.go deleted file mode 100644 index 267e3d71..00000000 --- a/ai/ai_test.go +++ /dev/null @@ -1,132 +0,0 @@ -package ai_test - -import ( - . "github.com/orfjackal/gospec/src/gospec" - "github.com/orfjackal/gospec/src/gospec" - "github.com/runningwild/yedparse" - "github.com/runningwild/polish" - "github.com/runningwild/glop/ai" -) - -func AiSpec(c gospec.Context) { - c.Specify("Load a simple .xgml file.", func() { - g, err := yed.ParseFromFile("state.xgml") - c.Assume(err, Equals, nil) - aig := ai.NewGraph() - aig.Graph = &g.Graph - aig.Context = polish.MakeContext() - polish.AddIntMathContext(aig.Context) - - dist := 0 - dist_func := func() int { - return dist - } - - var nearest int = 7 - nearest_func := func() int { - return nearest - } - - attacks := 0 - attack_func := func() int { - attacks++ - return 0 - } - - aig.Context.AddFunc("dist", dist_func) - aig.Context.AddFunc("nearest", nearest_func) - aig.Context.AddFunc("move", func() int { nearest--; return 0 }) - aig.Context.AddFunc("wait", func() int { return 0 }) - aig.Context.AddFunc("attack", attack_func) - aig.Eval(2, func() bool { return true }) - - c.Expect(attacks, Equals, 0) - c.Expect(nearest, Equals, 4) - }) -} - -func TermSpec(c gospec.Context) { - g, err := yed.ParseFromFile("state.xgml") - c.Assume(err, Equals, nil) - aig := ai.NewGraph() - aig.Graph = &g.Graph - aig.Context = polish.MakeContext() - polish.AddIntMathContext(aig.Context) - polish.AddIntMathContext(aig.Context) - c.Specify("Calling AiGraph.Term() will terminate evaluation early.", func() { - var nearest int = 7 - nearest_func := func() int { - return nearest - } - - dist := 0 - term := true - dist_func := func() int { - if nearest == 6 && term { - aig.Term() <- nil - } - return dist - } - - attacks := 0 - attack_func := func() int { - attacks++ - return 0 - } - - aig.Context.AddFunc("dist", dist_func) - aig.Context.AddFunc("nearest", nearest_func) - aig.Context.AddFunc("move", func() int { nearest--; return 0 }) - aig.Context.AddFunc("wait", func() int { return 0 }) - aig.Context.AddFunc("attack", attack_func) - aig.Eval(2, func() bool { return true }) - - c.Expect(attacks, Equals, 0) - c.Expect(nearest, Equals, 6) - - term = false - aig.Eval(2, func() bool { return true }) - c.Expect(nearest, Equals, 4) - }) -} - -func ChunkSpec(c gospec.Context) { - g, err := yed.ParseFromFile("state.xgml") - c.Assume(err, Equals, nil) - aig := ai.NewGraph() - aig.Graph = &g.Graph - aig.Context = polish.MakeContext() - polish.AddIntMathContext(aig.Context) - polish.AddIntMathContext(aig.Context) - c.Specify("cont() returning false will terminate evaluation early.", func() { - var nearest int = 7 - nearest_func := func() int { - return nearest - } - - dist := 0 - term := true - dist_func := func() int { - if nearest == 6 && term { - aig.Term() <- nil - } - return dist - } - - attacks := 0 - attack_func := func() int { - attacks++ - return 0 - } - - aig.Context.AddFunc("dist", dist_func) - aig.Context.AddFunc("nearest", nearest_func) - aig.Context.AddFunc("move", func() int { nearest--; return 0 }) - aig.Context.AddFunc("wait", func() int { return 0 }) - aig.Context.AddFunc("attack", attack_func) - _, err := aig.Eval(4, func() bool { return false }) - // Only have time for 1 move before we terminate early - c.Expect(err, Equals, nil) - c.Expect(nearest, Equals, 6) - }) -} \ No newline at end of file diff --git a/ai/all_specs_test.go b/ai/all_specs_test.go deleted file mode 100644 index bb4646d3..00000000 --- a/ai/all_specs_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package ai_test - -import ( - "github.com/orfjackal/gospec/src/gospec" - "testing" -) - - -func TestAllSpecs(t *testing.T) { - r := gospec.NewRunner() - r.AddSpec(AiSpec) - r.AddSpec(TermSpec) - r.AddSpec(ChunkSpec) - gospec.MainGoTest(r, t) -} - diff --git a/ai/sample.png b/ai/sample.png deleted file mode 100644 index c44903fcd4b8f5bf44c9066038d10c9fd7876f78..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7443 zcmb7Jc|4R~+ec}!Bvi^0NyswFntk6HyGcw+glvVe@02Yh4cYgd5m^W0S0ZB#gNB$a zV;N)LlI^`m^}IdL=Xw8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qM07t z_c=h&_v5YCf>IHZ1dTmI84>%&`=ZMG)AG%8-%-Q38=B&Jrl02g)`?q1+N${~NPCm4 z?eP>YXP#2cQu!xK^Ht}rbF!y5Q8AfaT7gsv1M(v z5x?46?kcmDHLe)IwCm?EP1owKt=lt~^mS$m+1U?1*l0(;J7*L~VHxDm4n1-asB!XOjaLI6;#B9&KG zty1^I-IYaPAH-ZY4JN~#DtX{mAGk)nb19A1_)|aEuYF$MxGCf3%njRp96j-j-Q#WK zhw;Z=53BV?8es>|dPS4Ba*Y!NUti2f(|aAZMi~9c;($nW4V1BcYaw<`M&OIP;7@RU zYqQ%6fA^?=b98RGQa#1z=*I*z%SfNl*^11kiSTM$V58`2^<+fmIyxe{0t2t5=pnx? zd9jQa=75~W=D1S%o+UJ*_^^|0;yX_D6{8u-^C7dyOD`LRxAP1IF5}V*4R4Vc()Q)) zX0f8uWDK0w+#NqIvV{H&kThYL)t-|hN6ytOyJ@}a%hSc&=3M+Tl9{}EenVTkrlrxU zBUm>MwvB}|I`X6bfr{$jI^8-O*#}UM^pwuv8&bMBr7YkyY%kSj^q(i=XXv40GqpYK zo7QpK=eeiM4TTKrCK!<7>h|i2YbQ!zgWYq4q(M;myk=3e|n8VqZKJ$zY?s8zatC zxLeGYX?sUFAguXzd{cu9kk?Hv8C*WCPrH;8gLk1s@}Zu#NqB1FSke?~ct(zHP^=gd zykh_J5(PX0c@LtrzcE0&P}zu*FxjuL=VB+vp%3IJxkI+iIlNkW$4 zu@E=S$(S=D&YC d{Ql3z(d3<0tMpj#MPLjvO;xZ8Lg_)s{{ZC?Z~*`S diff --git a/ai/state.xgml b/ai/state.xgml deleted file mode 100644 index 64bea13e..00000000 --- a/ai/state.xgml +++ /dev/null @@ -1,255 +0,0 @@ - -
- yFiles - 2.8 -
- 1 - - 1 -
- 0 - < 2 dist -
- 79.0 - -300.0 - 128.0 - 30.0 - rectangle - #FFCC00 - #000000 -
-
- < 2 dist - 12 - Dialog - c -
-
-
- 1 - > nearest 4 -
- 180.0 - -240.0 - 128.0 - 30.0 - rectangle - #FFCC00 - #000000 -
-
- > nearest 4 - 12 - Dialog - c -
-
-
- 2 - attack -
- 180.0 - -90.0 - 128.0 - 30.0 - rectangle - #FFCC00 - #000000 -
-
- attack - 12 - Dialog - c -
-
-
- 3 - move -
- 270.0 - -196.0 - 128.0 - 30.0 - rectangle - #FFCC00 - #000000 -
-
- move - 12 - Dialog - c -
-
-
- 4 - wait -
- 270.0 - -150.0 - 128.0 - 30.0 - rectangle - #FFCC00 - #000000 -
-
- wait - 12 - Dialog - c -
-
-
- 5 - start -
- 79.0 - -401.0 - 128.0 - 30.0 - rectangle - #FFCC00 - #000000 -
-
- start - 12 - Dialog - c -
-
-
- 0 - 1 -
- #FF0000 - standard -
-
- 79.0 - -300.0 -
-
- 90.0 - -240.0 -
-
- 180.0 - -240.0 -
-
-
-
- 0.171875 -
-
-
- 0 - 2 -
- #00FF00 - standard -
-
- 79.0 - -300.0 -
-
- 60.0 - -90.0 -
-
- 180.0 - -90.0 -
-
-
-
- -0.296875 -
-
-
- 1 - 3 -
- #00FF00 - standard -
-
- 180.0 - -240.0 -
-
- 180.0 - -196.0 -
-
- 270.0 - -196.0 -
-
-
-
-
- 1 - 4 -
- #FF0000 - standard -
-
- 180.0 - -240.0 -
-
- 150.0 - -150.0 -
-
- 270.0 - -150.0 -
-
-
-
- -0.46875 -
-
-
- 5 - 0 -
- #000000 - standard -
-
-
- 3 - 0 -
- #000000 - standard -
-
- 270.0 - -196.0 -
-
- 270.0 - -311.5 -
-
- 79.0 - -300.0 -
-
-
-
- 0.4765625 - -0.7666666507720947 -
-
-
-
diff --git a/gos/cgo_windows.go b/gos/cgo_windows.go index 0e7237fd..e3edf23c 100644 --- a/gos/cgo_windows.go +++ b/gos/cgo_windows.go @@ -5,8 +5,8 @@ package gos import "C" import ( - "github.com/runningwild/glop/system" - "github.com/runningwild/glop/gin" + "github.com/MobRulesGames/glop/system" + "github.com/MobRulesGames/glop/gin" "unsafe" ) diff --git a/gui/check_box.go b/gui/check_box.go index 6ec3c182..923ea5c6 100644 --- a/gui/check_box.go +++ b/gui/check_box.go @@ -1,8 +1,8 @@ package gui import ( - "github.com/runningwild/glop/gin" - "github.com/runningwild/opengl/gl" + "github.com/MobRulesGames/glop/gin" + "github.com/MobRulesGames/opengl/gl" "reflect" ) diff --git a/gui/combo.go b/gui/combo.go index 416108ce..a8e01767 100644 --- a/gui/combo.go +++ b/gui/combo.go @@ -1,7 +1,7 @@ package gui import ( - "github.com/runningwild/glop/gin" + "github.com/MobRulesGames/glop/gin" ) type ComboBox struct { diff --git a/gui/file_chooser.go b/gui/file_chooser.go index 83851b7c..1fe551fc 100644 --- a/gui/file_chooser.go +++ b/gui/file_chooser.go @@ -1,7 +1,7 @@ package gui import ( - "github.com/runningwild/glop/gin" + "github.com/MobRulesGames/glop/gin" "fmt" "path/filepath" "os" diff --git a/gui/gui.go b/gui/gui.go index 4e9ea3de..10c5ffca 100644 --- a/gui/gui.go +++ b/gui/gui.go @@ -1,8 +1,8 @@ package gui import ( - "github.com/runningwild/glop/gin" - "github.com/runningwild/opengl/gl" + "github.com/MobRulesGames/glop/gin" + "github.com/MobRulesGames/opengl/gl" ) type Point struct { diff --git a/gui/scroll.go b/gui/scroll.go index 347e076e..658e9643 100644 --- a/gui/scroll.go +++ b/gui/scroll.go @@ -1,7 +1,7 @@ package gui import ( - "github.com/runningwild/glop/gin" + "github.com/MobRulesGames/glop/gin" "math" ) diff --git a/gui/tables.go b/gui/tables.go index 6a0d0a30..3eb2daba 100644 --- a/gui/tables.go +++ b/gui/tables.go @@ -1,6 +1,6 @@ package gui -import "github.com/runningwild/opengl/gl" +import "github.com/MobRulesGames/opengl/gl" type TableParams struct { Spacing int diff --git a/gui/text.go b/gui/text.go index 695b66ed..c15070ac 100644 --- a/gui/text.go +++ b/gui/text.go @@ -6,7 +6,7 @@ import ( "code.google.com/p/freetype-go/freetype/truetype" "encoding/gob" "fmt" - "github.com/runningwild/glop/render" + "github.com/MobRulesGames/glop/render" "image" "image/color" "image/draw" @@ -14,9 +14,9 @@ import ( "runtime" "sort" "unsafe" - // "github.com/runningwild/opengl/gl" - gl "github.com/chsc/gogl/gl21" - "github.com/runningwild/opengl/glu" + // "github.com/MobRulesGames/opengl/gl" + gl "github.com/MobRulesGames/gogl/gl21" + "github.com/MobRulesGames/opengl/glu" ) type subImage struct { @@ -470,7 +470,7 @@ func MakeDictionary(font *truetype.Font, size int) *Dictionary { context.SetSrc(image.White) dpi := 150 context.SetFontSize(float64(size)) - context.SetDPI(dpi) + context.SetDPI(float64(dpi)) var letters []image.Image rune_mapping := make(map[rune]image.Image) rune_info := make(map[rune]runeInfo) diff --git a/gui/text_edit_line.go b/gui/text_edit_line.go index 96c6c14e..91b42629 100644 --- a/gui/text_edit_line.go +++ b/gui/text_edit_line.go @@ -1,9 +1,9 @@ package gui import ( - "github.com/runningwild/glop/gin" + "github.com/MobRulesGames/glop/gin" "code.google.com/p/freetype-go/freetype" - "github.com/runningwild/opengl/gl" + "github.com/MobRulesGames/opengl/gl" ) type cursor struct { diff --git a/gui/text_line.go b/gui/text_line.go index d2bc770a..eeffe43c 100644 --- a/gui/text_line.go +++ b/gui/text_line.go @@ -1,14 +1,15 @@ package gui import ( + "flag" "fmt" "image" "image/draw" "image/color" "code.google.com/p/freetype-go/freetype" "code.google.com/p/freetype-go/freetype/truetype" - "github.com/runningwild/opengl/gl" - "github.com/runningwild/opengl/glu" + "github.com/MobRulesGames/opengl/gl" + "github.com/MobRulesGames/opengl/glu" "io/ioutil" ) @@ -59,6 +60,8 @@ func GetDict(name string) *Dictionary { return basic_dicts[name] } +var size = flag.Float64("size", 12, "font size in points") + func drawText(font *truetype.Font, c *freetype.Context, color color.Color, rgba *image.RGBA, text string) (int, int) { fg := image.NewUniform(color) bg := image.Transparent @@ -72,7 +75,7 @@ func drawText(font *truetype.Font, c *freetype.Context, color color.Color, rgba // TODO: wtf - this is all wrong! // fix fonts - we can't change the font size easily height := 1.3 - pt := freetype.Pt(0, int(float64(c.FUnitToPixelRU(font.UnitsPerEm()))*height)) + pt := freetype.Pt(0, int(float64(c.PointToFix32(*size)>>8)*height)) adv, _ := c.DrawString(text, pt) pt.X += adv.X py := int(float64(pt.Y>>8)/height + 0.01) diff --git a/gui/widgets.go b/gui/widgets.go index a7e78561..35cbaacc 100644 --- a/gui/widgets.go +++ b/gui/widgets.go @@ -5,8 +5,8 @@ import ( _ "image/png" _ "image/jpeg" "os" - "github.com/runningwild/opengl/gl" - "github.com/runningwild/opengl/glu" + "github.com/MobRulesGames/opengl/gl" + "github.com/MobRulesGames/opengl/glu" "runtime" ) diff --git a/sprite/shared_sprite.go b/sprite/shared_sprite.go index b2fdecc7..1021aede 100644 --- a/sprite/shared_sprite.go +++ b/sprite/shared_sprite.go @@ -9,8 +9,8 @@ import ( "sort" "strconv" "strings" - "github.com/runningwild/glop/util/algorithm" - "github.com/runningwild/yedparse" + "github.com/MobRulesGames/glop/util/algorithm" + "github.com/MobRulesGames/yedparse" ) type sharedSprite struct { diff --git a/sprite/sheet.go b/sprite/sheet.go index 34dcd359..03a2d999 100644 --- a/sprite/sheet.go +++ b/sprite/sheet.go @@ -3,11 +3,11 @@ package sprite import ( "encoding/binary" "fmt" - "github.com/runningwild/glop/render" - "github.com/runningwild/memory" - "github.com/runningwild/opengl/gl" - "github.com/runningwild/opengl/glu" - "github.com/runningwild/yedparse" + "github.com/MobRulesGames/glop/render" + "github.com/MobRulesGames/memory" + "github.com/MobRulesGames/opengl/gl" + "github.com/MobRulesGames/opengl/glu" + "github.com/MobRulesGames/yedparse" "hash/fnv" "image" "image/draw" diff --git a/sprite/sprite.go b/sprite/sprite.go index bebc31d4..88596dfa 100644 --- a/sprite/sprite.go +++ b/sprite/sprite.go @@ -5,11 +5,11 @@ import ( "encoding/gob" "errors" "fmt" - "github.com/runningwild/glop/render" - "github.com/runningwild/glop/util/algorithm" - "github.com/runningwild/opengl/gl" - "github.com/runningwild/opengl/glu" - "github.com/runningwild/yedparse" + "github.com/MobRulesGames/glop/render" + "github.com/MobRulesGames/glop/util/algorithm" + "github.com/MobRulesGames/opengl/gl" + "github.com/MobRulesGames/opengl/glu" + "github.com/MobRulesGames/yedparse" "math/rand" "os" "path/filepath" diff --git a/system/system.go b/system/system.go index d018d955..83b9da8a 100644 --- a/system/system.go +++ b/system/system.go @@ -1,7 +1,7 @@ package system import ( - "github.com/runningwild/glop/gin" + "github.com/MobRulesGames/glop/gin" ) type System interface { From 97d9ce89772fe8e65465a2c11c0e2b59f0bdf1f5 Mon Sep 17 00:00:00 2001 From: Trevor Peterson Date: Tue, 4 Dec 2012 23:43:08 -0700 Subject: [PATCH 3/4] added newline at EOF --- ai/ai_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ai/ai_test.go b/ai/ai_test.go index 09c2c78c..574ff3e2 100644 --- a/ai/ai_test.go +++ b/ai/ai_test.go @@ -129,4 +129,4 @@ func ChunkSpec(c gospec.Context) { c.Expect(err, Equals, nil) c.Expect(nearest, Equals, 6) }) -} \ No newline at end of file +} From f1496b2a2e282ebc4d316d2c9077664ccd706bef Mon Sep 17 00:00:00 2001 From: Trevor Peterson Date: Wed, 5 Dec 2012 00:08:11 -0700 Subject: [PATCH 4/4] missed a change to Choose2 --- sprite/sprite.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sprite/sprite.go b/sprite/sprite.go index 0cb763c6..88596dfa 100644 --- a/sprite/sprite.go +++ b/sprite/sprite.go @@ -848,7 +848,7 @@ func (s *Sprite) Think(dt int64) { s.waiters[i].states = nil } } - algorithm.Choose(&s.waiters, func(w *waiter) bool { + algorithm.Choose2(&s.waiters, func(w *waiter) bool { return w.states != nil }) }