• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang gin.In函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/runningwild/glop/gin.In函数的典型用法代码示例。如果您正苦于以下问题:Golang In函数的具体用法?Golang In怎么用?Golang In使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了In函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: MakeKeyMap

func (kb KeyBinds) MakeKeyMap() KeyMap {
	key_map := make(KeyMap)
	for key, val := range kb {
		fmt.Printf("Keymapping %v -> %v\n", key, val)
		parts := strings.Split(val, ",")
		var binds []gin.Key
		for i, part := range parts {
			kids := getKeysFromString(part)

			if len(kids) == 1 {
				binds = append(binds, gin.In().GetKey(kids[0]))
			} else {
				// The last kid is the main kid and the rest are modifiers
				main := kids[len(kids)-1]
				kids = kids[0 : len(kids)-1]
				var down []bool
				for _ = range kids {
					down = append(down, true)
				}
				binds = append(binds, gin.In().BindDerivedKey(fmt.Sprintf("%s:%d", key, i), gin.In().MakeBinding(main, kids, down)))
			}
		}
		if len(binds) == 1 {
			key_map[key] = binds[0]
		} else {
			var actual_binds []gin.Binding
			for i := range binds {
				actual_binds = append(actual_binds, gin.In().MakeBinding(binds[i].Id(), nil, nil))
			}
			key_map[key] = gin.In().BindDerivedKey("name", actual_binds...)
		}
	}
	return key_map
}
开发者ID:runningwild,项目名称:magnus,代码行数:34,代码来源:bindings.go


示例2: handleEventGroupInvaders

func (l *LocalData) handleEventGroupInvaders(group gin.EventGroup) {
	if l.mode != LocalModeMoba {
		panic("Need to implement controls for multiple players on a single screen")
	}
	k0 := gin.In().GetKeyFlat(gin.Key6, gin.DeviceTypeKeyboard, gin.DeviceIndexAny)
	k1 := gin.In().GetKeyFlat(gin.Key7, gin.DeviceTypeKeyboard, gin.DeviceIndexAny)
	k2 := gin.In().GetKeyFlat(gin.Key8, gin.DeviceTypeKeyboard, gin.DeviceIndexAny)
	k3 := gin.In().GetKeyFlat(gin.Key9, gin.DeviceTypeKeyboard, gin.DeviceIndexAny)
	if found, event := group.FindEvent(k0.Id()); found {
		l.activateAbility(&l.moba.currentPlayer.abs, l.moba.currentPlayer.gid, 0, event.Type == gin.Press)
		return
	}
	if found, event := group.FindEvent(k1.Id()); found {
		l.activateAbility(&l.moba.currentPlayer.abs, l.moba.currentPlayer.gid, 1, event.Type == gin.Press)
		return
	}
	if found, event := group.FindEvent(k2.Id()); found {
		l.activateAbility(&l.moba.currentPlayer.abs, l.moba.currentPlayer.gid, 2, event.Type == gin.Press)
		return
	}
	if found, event := group.FindEvent(k3.Id()); found {
		l.activateAbility(&l.moba.currentPlayer.abs, l.moba.currentPlayer.gid, 3, event.Type == gin.Press)
		return
	}
	if l.moba.currentPlayer.abs.activeAbility != nil {
		if l.moba.currentPlayer.abs.activeAbility.Respond(l.moba.currentPlayer.gid, group) {
			return
		}
	}
}
开发者ID:runningwild,项目名称:magnus,代码行数:30,代码来源:local.go


示例3: doArchitectFocusRegion

func (camera *cameraInfo) doArchitectFocusRegion(g *Game, sys system.System) {
	if camera.limit.mid.X == 0 && camera.limit.mid.Y == 0 {
		// On the very first frame the limit midpoint will be (0,0), which should
		// never happen after the game begins.  We use this as an opportunity to
		// init the data now that we know the region we're working with.
		rdx := float64(g.Levels[GidInvadersStart].Room.Dx)
		rdy := float64(g.Levels[GidInvadersStart].Room.Dy)
		if camera.regionDims.X/camera.regionDims.Y > rdx/rdy {
			camera.limit.dims.Y = rdy
			camera.limit.dims.X = rdy * camera.regionDims.X / camera.regionDims.Y
		} else {
			camera.limit.dims.X = rdx
			camera.limit.dims.Y = rdx * camera.regionDims.Y / camera.regionDims.X
		}
		camera.limit.mid.X = rdx / 2
		camera.limit.mid.Y = rdy / 2
		camera.current = camera.limit
		camera.zoom = 0
		base.Log().Printf("Region Dims: %2.2v", camera.regionDims)
		base.Log().Printf("Room Dims: %2.2v %2.2v", rdx, rdy)
		base.Log().Printf("Limit Dims: %2.2v", camera.limit.dims)
	}
	wheel := gin.In().GetKeyFlat(gin.MouseWheelVertical, gin.DeviceTypeAny, gin.DeviceIndexAny)
	camera.zoom += wheel.FramePressAmt() / 500
	if camera.zoom < 0 {
		camera.zoom = 0
	}
	if camera.zoom > 2 {
		camera.zoom = 2
	}
	zoom := 1 / math.Exp(camera.zoom)
	camera.current.dims = camera.limit.dims.Scale(zoom)
	if gin.In().GetKey(gin.AnySpace).CurPressAmt() > 0 {
		if !camera.cursorHidden {
			sys.HideCursor(true)
			camera.cursorHidden = true
		}
		x := gin.In().GetKey(gin.AnyMouseXAxis).FramePressAmt()
		y := gin.In().GetKey(gin.AnyMouseYAxis).FramePressAmt()
		camera.current.mid.X -= float64(x) * 2
		camera.current.mid.Y -= float64(y) * 2
	} else {
		if camera.cursorHidden {
			sys.HideCursor(false)
			camera.cursorHidden = false
		}
	}
}
开发者ID:runningwild,项目名称:magnus,代码行数:48,代码来源:local.go


示例4: Prep

func (a *Move) Prep(ent *game.Entity, g *game.Game) bool {
	a.ent = ent
	fx, fy := g.GetViewer().WindowToBoard(gin.In().GetCursor("Mouse").Point())
	a.findPath(ent, int(fx), int(fy))
	a.threshold = a.ent.Stats.ApCur()
	return true
}
开发者ID:hilerchyn,项目名称:haunts,代码行数:7,代码来源:move.go


示例5: main

func main() {
	runtime.GOMAXPROCS(2)
	sys := system.Make(gos.GetSystemInterface())
	sys.Startup()

	game := Game{}
	var lb LevelBlueprint
	loadJson(filepath.Join(base.DataDir(), "1p_basic_level.json"), &lb)
	if len(lb.Players) == 0 || len(lb.Walls) == 0 {
		panic(fmt.Sprintf("Invalid level config: %d players and %d walls.",
			len(lb.Players), len(lb.Walls)))
	}
	engine, _ := cgf.NewLocalEngine(&game, int(Config.FrameTime*1000), nil)
	engine.ApplyEvent(&NewLevelEvent{&lb})

	render.Init()
	render.Queue(func() {
		initWindow(sys, Config.WindowWidth, Config.WindowHeight)
	})
	render.Purge()

	ticker := time.Tick(time.Millisecond * time.Duration(Config.FrameTime*1000))
	for true {
		<-ticker
		LocalThink(sys, engine, &game)
		if gin.In().GetKey(gin.AnyEscape).FramePressCount() > 0 {
			break
		}
	}
}
开发者ID:runningwild,项目名称:arkanoid,代码行数:30,代码来源:main.go


示例6: Think

func (hdt *houseDataTab) Think(ui *gui.Gui, t int64) {
	if hdt.temp_room != nil {
		mx, my := gin.In().GetCursor("Mouse").Point()
		bx, by := hdt.viewer.WindowToBoard(mx, my)
		cx, cy := hdt.temp_room.Pos()
		hdt.temp_room.X = int(bx - hdt.drag_anchor.x)
		hdt.temp_room.Y = int(by - hdt.drag_anchor.y)
		dx := hdt.temp_room.X - cx
		dy := hdt.temp_room.Y - cy
		for i := range hdt.temp_spawns {
			hdt.temp_spawns[i].X += dx
			hdt.temp_spawns[i].Y += dy
		}
		hdt.temp_room.invalid = !hdt.house.Floors[0].canAddRoom(hdt.temp_room)
	}
	hdt.VerticalTable.Think(ui, t)
	num_floors := hdt.num_floors.GetComboedIndex() + 1
	if len(hdt.house.Floors) != num_floors {
		for len(hdt.house.Floors) < num_floors {
			hdt.house.Floors = append(hdt.house.Floors, &Floor{})
		}
		if len(hdt.house.Floors) > num_floors {
			hdt.house.Floors = hdt.house.Floors[0:num_floors]
		}
	}
	hdt.house.Name = hdt.name.GetText()
	hdt.house.Icon.Path = base.Path(hdt.icon.GetPath())
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:28,代码来源:house.go


示例7: getKeysFromString

func getKeysFromString(str string) []gin.KeyId {
	parts := strings.Split(str, "+")
	var kids []gin.KeyId
	for _, part := range parts {
		part = osSpecifyKey(part)
		var kid gin.KeyId
		switch {
		case len(part) == 1: // Single character - should be ascii
			kid = gin.KeyId(part[0])

		case part == "ctrl":
			kid = gin.EitherControl

		case part == "shift":
			kid = gin.EitherShift

		case part == "alt":
			kid = gin.EitherAlt

		case part == "gui":
			kid = gin.EitherGui

		default:
			key := gin.In().GetKeyByName(part)
			if key == nil {
				panic(fmt.Sprintf("Unknown key '%s'", part))
			}
			kid = key.Id()
		}
		kids = append(kids, kid)
	}
	return kids
}
开发者ID:runningwild,项目名称:tester,代码行数:33,代码来源:bindings.go


示例8: main

func main() {
	sys := system.Make(gos.GetSystemInterface())
	sys.Startup()

	render.Init()
	render.Queue(func() {
		initWindow(sys, 800, 600)
	})

	font := loadDictionary("skia.dict")
	fmt.Fprintf(log, "Font: %v", font)
	for true {
		sys.Think()
		render.Queue(func() {
			// gl.Color4ub(0, 255, 255, 255)
			// gl.Begin(gl.QUADS)
			// gl.Vertex2d(100, 100)
			// gl.Vertex2d(500, 100)
			// gl.Vertex2d(500, 150)
			// gl.Vertex2d(100, 150)
			// gl.End()
			font.SetFontColor(1, 1, 1)
			font.RenderString("TEST", 100, 100, 100)
			sys.SwapBuffers()
		})
		render.Purge()
		if gin.In().GetKey(gin.AnyEscape).FramePressCount() > 0 {
			break
		}
	}
}
开发者ID:runningwild,项目名称:glomple,代码行数:31,代码来源:main.go


示例9: Think

func (ep *EntityPlacer) Think(g *gui.Gui, t int64) {
	if ep.last_t == 0 {
		ep.last_t = t
		return
	}
	dt := t - ep.last_t
	ep.last_t = t
	if ep.mx == 0 && ep.my == 0 {
		ep.mx, ep.my = gin.In().GetCursor("Mouse").Point()
	}
	for _, button := range ep.buttons {
		button.Think(ep.region.X, ep.region.Y, ep.mx, ep.my, dt)
	}

	hovered := false
	for i, button := range ep.ent_buttons {
		if button.Over(ep.mx, ep.my) {
			hovered = true
			if ep.hovered == nil || ep.roster_names[i] != ep.hovered.Name {
				ep.hovered = MakeEntity(ep.roster_names[i], ep.game)
			}
		}
	}
	if hovered == false {
		ep.hovered = nil
	}
	if ep.hovered != nil {
		ep.hovered.Think(dt)
	}
}
开发者ID:ThalwegIII,项目名称:haunts,代码行数:30,代码来源:ui_entity_placer.go


示例10: HandleInput

func (a *Interact) HandleInput(group gui.EventGroup, g *game.Game) (bool, game.ActionExec) {
	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		bx, by := g.GetViewer().WindowToBoard(gin.In().GetCursor("Mouse").Point())
		room_num := a.ent.CurrentRoom()
		room := g.House.Floors[0].Rooms[room_num]
		for door_num, door := range room.Doors {
			rect := makeRectForDoor(room, door)
			if rect.Contains(float64(bx), float64(by)) {
				var exec interactExec
				exec.Toggle_door = true
				exec.SetBasicData(a.ent, a)
				exec.Room = room_num
				exec.Door = door_num
				return true, &exec
			}
		}
	}
	target := g.HoveredEnt()
	if target == nil {
		return false, nil
	}
	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		for i := range a.targets {
			if a.targets[i] == target && distBetweenEnts(a.ent, target) <= a.Range {
				var exec interactExec
				exec.SetBasicData(a.ent, a)
				exec.Target = target.Id
				return true, &exec
			}
		}
		return true, nil
	}
	return false, nil
}
开发者ID:RickDakan,项目名称:haunts,代码行数:34,代码来源:interact.go


示例11: Think

func (te *TextEntry) Think(x, y, mx, my int, dt int64) {
	if te.Entry.Default != "" {
		te.Entry.text = te.Entry.Default
		te.Entry.Default = ""
	}
	te.Button.Think(x, y, mx, my, dt)
	te.setCursor(gin.In().GetCursor("Mouse").Point())
}
开发者ID:RickDakan,项目名称:haunts,代码行数:8,代码来源:ui_text_entry.go


示例12: getPlayers

func getPlayers(console *base.Console) []gin.DeviceId {
	var ct controllerTracker
	gin.In().RegisterEventListener(&ct)
	defer gin.In().UnregisterEventListener(&ct)
	ticker := time.Tick(time.Millisecond * 17)
	start := time.Time{}
	readyDuration := time.Second * 2
	for start.IsZero() || time.Now().Sub(start) < readyDuration {
		<-ticker
		sys.Think()
		if ct.Ready() && start.IsZero() {
			start = time.Now()
		}
		if !ct.Ready() {
			start = time.Time{}
		}
		render.Queue(func() {
			defer console.Draw(0, 0, wdx, wdy)
			gl.Clear(gl.COLOR_BUFFER_BIT)
			gl.Disable(gl.DEPTH_TEST)
			gui.SetFontColor(1, 1, 1, 1)
			gl.Disable(gl.TEXTURE_2D)
			gl.MatrixMode(gl.PROJECTION)
			gl.LoadIdentity()
			gl.Ortho(gl.Double(0), gl.Double(wdx), gl.Double(wdy), gl.Double(0), 1000, -1000)
			gl.ClearColor(0, 0, 0, 1)
			gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
			gl.MatrixMode(gl.MODELVIEW)
			gl.LoadIdentity()
			base.GetDictionary("crackin").RenderString(fmt.Sprintf("Num players: %d", len(ct.ids)), float64(wdx)/2, 300, 0, 100, gui.Center)
			base.GetDictionary("crackin").RenderString(fmt.Sprintf("Num ready: %d", ct.NumReady()), float64(wdx)/2, 400, 0, 100, gui.Center)
			if !start.IsZero() {
				base.GetDictionary("crackin").RenderString(fmt.Sprintf("Starting in %2.2f", (readyDuration-time.Now().Sub(start)).Seconds()), float64(wdx)/2, 500, 0, 100, gui.Center)
			}
		})
		render.Queue(func() {
			sys.SwapBuffers()
		})
		render.Purge()
	}
	var devices []gin.DeviceId
	for id := range ct.ids {
		devices = append(devices, id)
	}
	return devices
}
开发者ID:runningwild,项目名称:jbot,代码行数:46,代码来源:main.go


示例13: thinkInternal

func (sys *sysObj) thinkInternal() {
	sys.os.Think()
	events, horizon := sys.os.GetInputEvents()
	for i := range events {
		events[i].Timestamp -= sys.start_ms
	}
	sys.events = gin.In().Think(horizon-sys.start_ms, sys.os.HasFocus(), events)
}
开发者ID:jctaylor1,项目名称:haunts,代码行数:8,代码来源:system.go


示例14: Make

func Make(x, y, dx, dy int) *Gui {
	var g Gui
	g.region = Region{Pos{x, y}, Dims{dx, dy}}
	g.root = &RootWidget{region: g.region}
	g.sys = system.Make(gos.GetSystemInterface())
	gin.In().RegisterEventListener(&g)
	return &g
}
开发者ID:runningwild,项目名称:jota,代码行数:8,代码来源:gui.go


示例15: Think

func (rv *RoomViewer) Think(*gui.Gui, int64) {
	if rv.size != rv.room.Size {
		rv.size = rv.room.Size
		rv.makeMat()
	}
	mx, my := rv.WindowToBoard(gin.In().GetCursor("Mouse").Point())
	rv.mx = int(mx)
	rv.my = int(my)
}
开发者ID:hilerchyn,项目名称:haunts,代码行数:9,代码来源:room_viewer.go


示例16: Prep

func (a *AoeAttack) Prep(ent *game.Entity, g *game.Game) bool {
	if !a.Preppable(ent, g) {
		return false
	}
	a.ent = ent
	bx, by := g.GetViewer().WindowToBoard(gin.In().GetCursor("Mouse").Point())
	a.tx = int(bx)
	a.ty = int(by)
	return true
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:10,代码来源:aoe_attack.go


示例17: MakeKeyMap

func (kb KeyBinds) MakeKeyMap() KeyMap {
	key_map := make(KeyMap)
	for key, val := range kb {
		kids := getKeysFromString(val)

		if len(kids) == 1 {
			key_map[key] = gin.In().GetKey(kids[0])
		} else {
			// The last kid is the main kid and the rest are modifiers
			main := kids[len(kids)-1]
			kids = kids[0 : len(kids)-1]
			var down []bool
			for _ = range kids {
				down = append(down, true)
			}
			key_map[key] = gin.In().BindDerivedKey(key, gin.In().MakeBinding(main, kids, down))
		}
	}
	return key_map
}
开发者ID:runningwild,项目名称:tester,代码行数:20,代码来源:bindings.go


示例18: Think

func (w *WallPanel) Think(ui *gui.Gui, t int64) {
	if w.wall_texture != nil {
		px, py := gin.In().GetCursor("Mouse").Point()
		tx := float32(px) - w.drag_anchor.X
		ty := float32(py) - w.drag_anchor.Y
		bx, by := w.viewer.WindowToBoardf(tx, ty)
		w.wall_texture.X = bx
		w.wall_texture.Y = by
	}
	w.VerticalTable.Think(ui, t)
}
开发者ID:RickDakan,项目名称:haunts,代码行数:11,代码来源:wall_tab.go


示例19: HandleEventGroupGame

func (g *Game) HandleEventGroupGame(group gin.EventGroup) {
	g.local.RLock()
	defer g.local.RUnlock()

	if found, event := group.FindEvent(control.editor.Id()); found && event.Type == gin.Press {
		g.editor.Toggle()
		return
	}

	if found, _ := group.FindEvent(control.any.Id()); found {
		dir := getControllerDirection(gin.DeviceId{gin.DeviceTypeController, gin.DeviceIndexAny})
		g.local.Engine.ApplyEvent(&Move{
			Gid:       g.local.Gid,
			Angle:     dir.Angle(),
			Magnitude: dir.Mag(),
		})
	}

	// ability0Key := gin.In().GetKeyFlat(gin.ControllerButton0+2, gin.DeviceTypeController, gin.DeviceIndexAny)
	// abilityTrigger := gin.In().GetKeyFlat(gin.ControllerButton0+1, gin.DeviceTypeController, gin.DeviceIndexAny)
	buttons := []gin.Key{
		gin.In().GetKeyFlat(gin.ControllerButton0+2, gin.DeviceTypeController, gin.DeviceIndexAny),
		gin.In().GetKeyFlat(gin.ControllerButton0+3, gin.DeviceTypeController, gin.DeviceIndexAny),
		gin.In().GetKeyFlat(gin.ControllerButton0+4, gin.DeviceTypeController, gin.DeviceIndexAny),
		gin.In().GetKeyFlat(gin.ControllerButton0+5, gin.DeviceTypeController, gin.DeviceIndexAny),
	}
	abilityTrigger := gin.In().GetKeyFlat(gin.ControllerButton0+6, gin.DeviceTypeController, gin.DeviceIndexAny)
	for i, button := range buttons {
		foundButton, _ := group.FindEvent(button.Id())
		foundTrigger, triggerEvent := group.FindEvent(abilityTrigger.Id())
		// TODO: Check if any abilities are Active before sending events to other abilities.
		if foundButton || foundTrigger {
			g.local.Engine.ApplyEvent(UseAbility{
				Gid:     g.local.Gid,
				Index:   i,
				Button:  button.CurPressAmt(),
				Trigger: foundTrigger && triggerEvent.Type == gin.Press,
			})
		}
	}
}
开发者ID:runningwild,项目名称:jota,代码行数:41,代码来源:game_graphics.go


示例20: Respond

func (te *TextEntry) Respond(group gui.EventGroup, data interface{}) bool {
	if te.Button.Respond(group, data) {
		return true
	}
	if !te.Entry.entering {
		return false
	}
	for _, event := range group.Events {
		if event.Type == gin.Press {
			id := event.Key.Id()
			if id <= 255 && valid_keys[byte(id)] {
				b := byte(id)
				if gin.In().GetKey(gin.EitherShift).CurPressAmt() > 0 {
					b = shift_keys[b]
				}
				t := te.Entry.text
				index := te.Entry.cursor.index
				t = t[0:index] + string([]byte{b}) + t[index:]
				te.Entry.text = t
				te.Entry.cursor.index++
			} else if event.Key.Id() == gin.DeleteOrBackspace {
				if te.Entry.cursor.index > 0 {
					index := te.Entry.cursor.index
					t := te.Entry.text
					te.Entry.text = t[0:index-1] + t[index:]
					te.Entry.cursor.index--
				}
			} else if event.Key.Id() == gin.Left {
				if te.Entry.cursor.index > 0 {
					te.Entry.cursor.index--
				}
			} else if event.Key.Id() == gin.Right {
				if te.Entry.cursor.index < len(te.Entry.text) {
					te.Entry.cursor.index++
				}
			} else if event.Key.Id() == gin.Return {
				te.Entry.entering = false
				if te.Button.f != nil {
					te.Button.f(nil)
				}
			} else if event.Key.Id() == gin.Escape {
				te.Entry.entering = false
				te.Entry.text = te.Entry.prev
				te.Entry.prev = ""
				te.Entry.cursor.index = 0
			}
			d := base.GetDictionary(te.Button.Text.Size)
			te.Entry.cursor.offset = int(d.StringWidth(te.Entry.text[0:te.Entry.cursor.index]))
		}
	}
	return false
}
开发者ID:RickDakan,项目名称:haunts,代码行数:52,代码来源:ui_text_entry.go



注:本文中的github.com/runningwild/glop/gin.In函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang gin.EventGroup类代码示例发布时间:2022-05-28
下一篇:
Golang cgf.Engine类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap