id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c12700
worker.DoWork() case <-drawDone: return } } case <-time.After(500 * time.Millisecond): return } }
c12701
<-resetLoopTicker: ticker.Stop() ticker = time.NewTicker(time.Duration(int(time.Second) / opts.FPSLimit)) } Time.Tick() if !opts.HeadlessMode { Input.update() } // Then update the world and all Systems currentUpdater.Update(Time.Delta()) Input.Mouse.Action = Neutral }
c12702
{ return AnimationComponent{ Animations: make(map[string]*Animation), Drawables: drawables, Rate: rate, } }
c12703
= ac.Animations[name] ac.index = 0 }
c12704
*Animation) { ac.CurrentAnimation = action ac.index = 0 }
c12705
*Animation) { ac.AddAnimation(action) ac.def = action }
c12706
*Animation) { ac.Animations[action.Name] = action }
c12707
{ for _, action := range actions { ac.AddAnimation(action) } }
c12708
zeroth drawable. If this is incorrect, add an action to the animation.") return ac.Drawables[0] } idx := ac.CurrentAnimation.Frames[ac.index] return ac.Drawables[idx] }
c12709
ac.index = 0 if !ac.CurrentAnimation.Loop { ac.CurrentAnimation = nil return } } }
c12710
a.entities = make(map[uint64]animationEntity) } a.entities[basic.ID()] = animationEntity{anim, render} }
c12711
o.GetAnimationComponent(), o.GetRenderComponent()) }
c12712
delete(a.entities, basic.ID()) } }
c12713
e.AnimationComponent.SelectAnimationByAction(e.AnimationComponent.def) } e.AnimationComponent.change += dt if e.AnimationComponent.change >= e.AnimationComponent.Rate { e.RenderComponent.Drawable = e.AnimationComponent.Cell() e.AnimationComponent.NextFrame() } } }
c12714
to:", title) } else { Window.SetTitle(title) } }
c12715
qt.MaxLevels = calcMaxLevel(aabbWidth(bounds), aabbHeight(bounds)) return qt }
c12716
qt.freeQuadtreeNode(qt.root) qt.root = nil }
c12717
//bottom left node (2) qt.Nodes[2] = qt.Tree.newNode(aabbRect(x, y+subHeight, subWidth, subHeight), nextLevel) //bottom right node (3) qt.Nodes[3] = qt.Tree.newNode(aabbRect(x+subWidth, y+subHeight, subWidth, subHeight), nextLevel) }
c12718
qt.root.Insert(qt.newQuadtreeNodeData(item, pRect)) }
c12719
item.AABB() qt.root.Remove(item, bounds) }
c12720
//if pRect does not fit into a subnode, check it against all subnodes for i := 0; i < 4; i++ { result = append(result, qt.Nodes[i].Retrieve(pRect)...) } } } return result }
c12721
filter(p)) { foundIntersections = append(foundIntersections, p) } } return foundIntersections }
c12722
qt.freeQuadtreeNode(qt.root) qt.root = qt.newNode(bounds, 0) qt.Total = 0 }
c12723
panic("unable to create gomonobold.ttf for the fps system! Error was: " + err.Error()) } txt := Text{ Font: f.fnt, Text: "Hello world!", } b := ecs.NewBasic() f.entity.BasicEntity = &b f.entity.RenderComponent = &RenderComponent{ Drawable: txt, } f.entity.RenderComponent.SetShader(HUDShader) ...
c12724
= Text{ Font: f.fnt, Text: text, } } if f.Terminal { log.Println(text) } f.frames = 0 f.elapsed -= 1 } }
c12725
if err != nil { return err } t.levels[url] = TMXResource{Level: lvl, url: url} return nil }
c12726
error { delete(t.levels, url) return nil }
c12727
not loaded by `FileLoader`: %q", url) } return tmx, nil }
c12728
Y: 0}).Y yMax := l.screenPoint(engo.Point{X: float32(l.width), Y: float32(l.height)}).Y + float32(l.TileHeight)/2 return engo.AABB{ Min: engo.Point{X: xMin, Y: yMin}, Max: engo.Point{X: xMax, Y: yMax}, } } return engo.AABB{} }
c12729
+ (screenPt.Y / float32(l.TileHeight)), Y: (screenPt.Y / float32(l.TileHeight)) - (screenPt.X / float32(l.TileWidth)), } } return engo.Point{X: 0, Y: 0} }
c12730
mapPt.Y) * float32(l.TileWidth) / 2, Y: (mapPt.X + mapPt.Y) * float32(l.TileHeight) / 2, } } return engo.Point{X: 0, Y: 0} }
c12731
{ return t.Image.View() }
c12732
nil { return err } i.fonts[url] = FontResource{Font: ttf, url: url} return nil }
c12733
error { delete(i.fonts, url) return nil }
c12734
fmt.Errorf("resource not loaded by `FileLoader`: %q", url) } return texture, nil }
c12735
nil case <-p.readLoopEndedCh: return fmt.Errorf("audio: the player is already closed") } }
c12736
o &= mask select { case p.seekCh <- seekArgs{o, io.SeekStart}: return <-p.seekedCh case <-p.readLoopEndedCh: return fmt.Errorf("audio: the player is already closed") } }
c12737
return time.Duration(sample) * time.Second / time.Duration(p.sampleRate) }
c12738
v = p.volume }) return v }
c12739
> 1 { log.Println("Volume can only be set between zero and one. Volume was not set.") return } p.sync(func() { p.volume = volume * masterVolume }) }
c12740
{ return engoimath.Nextafter(x, y) }
c12741
pairs { handlers[i] = pairs[i].MessageHandler } mm.RUnlock() for _, handler := range handlers { handler(message) } }
c12742
HandlerIDPair{MessageHandlerId: handlerID, MessageHandler: handler} mm.listeners[messageType] = append(mm.listeners[messageType], newHandlerIDPair) return handlerID }
c12743
} mm.handlersToRemove[messageType] = append(mm.handlersToRemove[messageType], handlerID) }
c12744
indexOfHandler = i break } } // A handler might have already been removed during a previous Dispatch(), no action necessary if indexOfHandler == -1 { return } mm.listeners[messageType] = append(mm.listeners[messageType][:indexOfHandler], mm.listeners[messageType][indexOfHandler+1:]...) }
c12745
&MessageManager{} doSetup = true } // Do the switch currentScene = s currentUpdater = wrapper.update Mailbox = wrapper.mailbox // doSetup is true whenever we're (re)initializing the Scene if doSetup { s.Preload() wrapper.mailbox.listeners = make(map[string][]HandlerIDPair) s.Setup(wrapper.update) ...
c12746
scenes[s.Type()] = &sceneWrapper{scene: s} sceneMutex.Unlock() } }
c12747
mapper: make(map[Key]KeyState), } }
c12748
ks := km.mapper[k] ks.set(state) km.mapper[k] = ks km.dirtmap[k] = k km.mutex.Unlock() }
c12749
ks := km.mapper[k] km.mutex.RUnlock() return ks }
c12750
} if key.currentState { return KeyStateJustDown } return KeyStateUp }
c12751
:= Input.keys.Get(trigger).Down() if v { return v } } return false }
c12752
Input.RegisterAxis(DefaultVerticalAxis, AxisKeyPair{KeyW, KeyS}, AxisKeyPair{KeyArrowUp, KeyArrowDown}) Input.RegisterAxis(DefaultMouseXAxis, NewAxisMouse(AxisMouseHori)) Input.RegisterAxis(DefaultMouseYAxis, NewAxisMouse(AxisMouseVert)) } Files.SetRoot(opts.AssetsRoot) currentUpdater = opts.Update // And ...
c12753
opts.FPSLimit = limit resetLoopTicker <- true return nil }
c12754
} case C.UITouchPhaseEnded, C.UITouchPhaseCancelled: Input.Mouse.Action = Release delete(Input.Touches, id) case C.UITouchPhaseMoved: Input.Mouse.Action = Move Input.Touches[id] = Point{ X: float32(x) / opts.GlobalScale.X, Y: float32(y) / opts.GlobalScale.Y, } } }
c12755
log.Println("Title set to:", title) } else { document.Set("title", title) } }
c12756
int(WindowHeight()) return }
c12757
Input.keys.Set(Key(key), state) delete(poll, key) } }
c12758
func(event js.Value) { window.Call("alert", "You're closing") })) } }
c12759
document.Get("body").Get("style").Set("cursor", "hand") } }
c12760
sdl.WINDOW_OPENGL) fatalErr(err) sdlGLContext, err = Window.GLCreateContext() fatalErr(err) Gl = gl.NewContext() if fullscreen { Window.SetFullscreen(sdl.WINDOW_FULLSCREEN) } if opts.NotResizable { Window.SetResizable(false) } else { Window.SetResizable(true) } gameWidth, gameHeight = float32(width...
c12761
:= Window.GetSize() return int(width), int(height) }
c12762
} case 1, 6: Input.Mouse.Action = Release delete(Input.Touches, id) case 2: Input.Mouse.Action = Move Input.Touches[id] = Point{ X: float32(x) / opts.GlobalScale.X, Y: float32(y) / opts.GlobalScale.Y, } } }
c12763
incrementally } if cammsg.Incremental { switch cammsg.Axis { case XAxis: cam.moveX(cammsg.Value) case YAxis: cam.moveY(cammsg.Value) case ZAxis: cam.zoom(cammsg.Value) case Angle: cam.rotate(cammsg.Value) } } else { switch cammsg.Axis { case XAxis: cam.moveToX(cammsg....
c12764
if cam.tracking.SpaceComponent == nil { log.Println("Should be tracking", cam.tracking.BasicEntity.ID(), "but SpaceComponent is nil") cam.tracking.BasicEntity = nil return } cam.centerCam(cam.tracking.SpaceComponent.Position.X+cam.tracking.SpaceComponent.Width/2, cam.tracking.SpaceComponent.Position.Y+cam...
c12765
cam.tracking = cameraEntity{basic, space} cam.trackRotation = trackRotation }
c12766
XAxis, Value: n.X * c.ScrollSpeed * dt, Incremental: true}) engo.Mailbox.Dispatch(CameraMessage{Axis: YAxis, Value: n.Y * c.ScrollSpeed * dt, Incremental: true}) }
c12767
c.keysMu.Lock() c.verticalAxis = vert c.horizontalAxis = hori defer c.keysMu.Unlock() }
c12768
{ kbs := &KeyboardScroller{ ScrollSpeed: scrollSpeed, } kbs.BindKeyboard(hori, vert) return kbs }
c12769
CameraBounds.Max.X = c.TrackingBounds.Max.X - (offsetX / engo.GetGlobalScale().X) CameraBounds.Max.Y = c.TrackingBounds.Max.Y - (offsetY / engo.GetGlobalScale().Y) }
c12770
pos.Y + height/2 engo.Mailbox.Dispatch(CameraMessage{Axis: XAxis, Value: trackToX, Incremental: false}) engo.Mailbox.Dispatch(CameraMessage{Axis: YAxis, Value: trackToY, Incremental: false}) if c.Rotation { engo.Mailbox.Dispatch(CameraMessage{Axis: Angle, Value: c.SpaceComponent.Rotation, Incremental: false}) }...
c12771
engo.Input.Mouse.ScrollY * c.ZoomSpeed, Incremental: true}) } }
c12772
engo.Mailbox.Dispatch(CameraMessage{Axis: Angle, Value: (c.oldX - engo.Input.Mouse.X) * -c.RotationSpeed, Incremental: true}) } c.oldX = engo.Input.Mouse.X }
c12773
= points[0].Y + sc.Height*cos points[3].X = points[0].X + sc.Width*cos - sc.Height*sin points[3].Y = points[0].Y + sc.Height*cos + sc.Width*sin return }
c12774
math.Pow(c, 2)) / (2 * b * c)) // Law of sines state: a / sin(alpha) = c / sin(gamma) height := (c / math.Sin(math.Pi/2)) * math.Sin(alpha) return (b * height) / 2 }
c12775
c.entities = append(c.entities, collisionEntity{basic, collision, space}) }
c12776
o.GetCollisionComponent(), o.GetSpaceComponent()) }
c12777
&& rect1.Min.X < rect2.Max.X && rect1.Max.Y > rect2.Min.Y && rect1.Min.Y < rect2.Max.Y { return true } return false }
c12778
doesn't intercept } if math.Abs(left) < right { mtd.X = left } else { mtd.X = right } if math.Abs(top) < bottom { mtd.Y = top } else { mtd.Y = bottom } if math.Abs(mtd.X) < math.Abs(mtd.Y) { mtd.Y = 0 } else { mtd.X = 0 } return mtd }
c12779
// Create the struct store := &MDBStore{ env: env, path: path, maxSize: maxSize, } // Initialize the db if err := store.initialize(); err != nil { env.Close() return nil, err } return store, nil }
c12780
nil { return err } // Open the DB if err := m.env.Open(m.path, mdb.NOTLS, 0755); err != nil { return err } // Create all the tables tx, _, err := m.startTxn(false, dbLogs, dbConf) if err != nil { tx.Abort() return err } return tx.Commit() }
c12781
dbi, err := tx.DBIOpen(name, dbFlags) if err != nil { tx.Abort() return nil, nil, err } dbs = append(dbs, dbi) } return tx, dbs, nil }
c12782
err == mdb.NotFound { return raft.ErrLogNotFound } else if err != nil { return err } // Convert the value to a log return decodeMsgPack(val, logOut) }
c12783
m.StoreLogs([]*raft.Log{log}) }
c12784
// Write to the table if err := tx.Put(dbis[0], key, val.Bytes(), 0); err != nil { tx.Abort() return err } } return tx.Commit() }
c12785
no further rows. var num int DELETE: num, err = m.innerDeleteRange(tx, dbis, minIdx, maxIdx) if err != nil { return err } if num > 0 { goto DELETE } return tx.Commit() }
c12786
make(chan *ProcEventExit), Error: make(chan error), done: make(chan bool, 1), closedMutex: &sync.Mutex{}, } go w.readEvents() return w, nil }
c12787
close(w.Exec) close(w.Exit) close(w.Error) }
c12788
w.unregister(pid) } w.watchesMutex.Unlock() w.done <- true w.listener.close() return nil }
c12789
if !ok { msg := fmt.Sprintf("watch for pid=%d does not exist", pid) return errors.New(msg) } delete(w.watches, pid) return w.unregister(pid) }
c12790
_LookupPrivilegeName(systemName, &luid, &buf[0], &bufSize) if err != nil { return "", errors.Wrapf(err, "LookupPrivilegeName failed for luid=%v", luid) } return syscall.UTF16ToString(buf), nil }
c12791
!= nil { return nil, errors.Wrapf(err, "LookupPrivilegeValue failed on '%v'", name) } privNames[name] = p } privileges = append(privileges, p) } return privileges, nil }
c12792
:= _AdjustTokenPrivileges(token, false, &b.Bytes()[0], uint32(b.Len()), nil, nil) if !success { return err } if err == ERROR_NOT_ALL_ASSIGNED { return errors.Wrap(err, "error not all privileges were assigned") } return nil }
c12793
user.Account, user.Domain, user.Type, err = tokenUser.User.Sid.LookupAccount("") if err != nil { return user, errors.Wrap(err, "LookupAccountSid failed") } return user, nil }
c12794
!= nil { return nil, err } return &DebugInfo{ User: user, ProcessPrivs: privs, OSVersion: GetWindowsVersion(), Arch: runtime.GOARCH, NumCPU: runtime.NumCPU(), }, nil }
c12795
:= syscall.Kqueue() listener.kq = kq return listener, err }
c12796
&listener.buf[0] syscall.SetKevent(event, pid, syscall.EVFILT_PROC, flags) event.Fflags = fflags _, err := syscall.Kevent(listener.kq, listener.buf[:], nil, nil) return err }
c12797
w.kevent(pid, 0, syscall.EV_DELETE) }
c12798
w.kevent(pid, flags, syscall.EV_ADD|syscall.EV_ENABLE) }
c12799
case syscall.NOTE_FORK: w.Fork <- &ProcEventFork{ParentPid: pid} case syscall.NOTE_EXEC: w.Exec <- &ProcEventExec{Pid: pid} case syscall.NOTE_EXIT: w.RemoveWatch(pid) w.Exit <- &ProcEventExit{Pid: pid} } } } }