當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Game.GetEnt方法代碼示例

本文整理匯總了Golang中github.com/runningwild/magnus/game.Game.GetEnt方法的典型用法代碼示例。如果您正苦於以下問題:Golang Game.GetEnt方法的具體用法?Golang Game.GetEnt怎麽用?Golang Game.GetEnt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/runningwild/magnus/game.Game的用法示例。


在下文中一共展示了Game.GetEnt方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Think

func (p *burstProcess) Think(g *game.Game) {
	_player := g.GetEnt(p.Player_id)
	player := _player.(*game.Player)
	if p.Remaining_initial.Magnitude() == 0 {
		if p.count > 0 {
			p.count = -1
		}
		p.Frames--
		if p.Frames <= 0 {
			p.The_phase = game.PhaseComplete
		}
		for i := range g.Ents {
			other := g.Ents[i]
			if other == player {
				continue
			}
			dist := other.Pos().Sub(player.Pos()).Mag()
			if dist < 1 {
				dist = 1
			}
			force := p.Force / dist
			other.ApplyForce(other.Pos().Sub(player.Pos()).Norm().Scale(force))
		}
	}
}
開發者ID:dgthunder,項目名稱:magnus,代碼行數:25,代碼來源:burst.go

示例2: Think

func (p *pullProcess) Think(g *game.Game) {
	_player := g.GetEnt(p.Player_id)
	player := _player.(*game.Player)

	base_force := p.Force * p.supplied / p.required
	for _, _target := range g.Ents {
		target, ok := _target.(*game.Player)
		if !ok || target == player {
			continue
		}
		target_pos := linear.Vec2{target.X, target.Y}
		ray := target_pos.Sub(player.Pos())
		target_angle := ray.Angle() - player.Angle
		for target_angle < 0 {
			target_angle += math.Pi * 2
		}
		for target_angle > math.Pi*2 {
			target_angle -= math.Pi * 2
		}
		if target_angle > p.Angle/2 && target_angle < math.Pi*2-p.Angle/2 {
			continue
		}
		ray = player.Pos().Sub(target.Pos())
		// dist := ray.Mag()
		ray = ray.Norm()
		force := base_force // / math.Pow(dist, p.Angle/(2*math.Pi))
		target.ApplyForce(ray.Scale(-force))
		player.ApplyForce(ray.Scale(force))
	}
}
開發者ID:dgthunder,項目名稱:magnus,代碼行數:30,代碼來源:pull.go

示例3: Draw

func (p *burstProcess) Draw(player_id int, g *game.Game) {
	player := g.GetEnt(player_id).(*game.Player)
	base.EnableShader("circle")
	prog := p.Remaining_initial.Magnitude() / p.Initial.Magnitude()
	base.SetUniformF("circle", "progress", 1-float32(prog))
	gl.Color4ub(255, 255, 255, 255)
	radius := 40.0
	texture.Render(
		player.X-radius,
		player.Y-radius,
		2*radius,
		2*radius)
	base.EnableShader("")
}
開發者ID:dgthunder,項目名稱:magnus,代碼行數:14,代碼來源:burst.go

示例4: Draw

func (p *pullProcess) Draw(player_id int, g *game.Game) {
	gl.Color4d(1, 1, 1, 1)
	gl.Disable(gl.TEXTURE_2D)
	player := g.GetEnt(player_id).(*game.Player)
	v1 := player.Pos()
	v2 := v1.Add(linear.Vec2{1000, 0})
	v3 := v2.RotateAround(v1, player.Angle-p.Angle/2)
	v4 := v2.RotateAround(v1, player.Angle+p.Angle/2)
	gl.Begin(gl.LINES)
	vs := []linear.Vec2{v3, v4, linear.Vec2{player.X, player.Y}}
	for i := range vs {
		gl.Vertex2d(gl.Double(vs[i].X), gl.Double(vs[i].Y))
		gl.Vertex2d(gl.Double(vs[(i+1)%len(vs)].X), gl.Double(vs[(i+1)%len(vs)].Y))
	}
	gl.End()
	s := fmt.Sprintf("%.2f", p.supplied)
	base.Log().Printf("'%s'", s)
	if true {
		base.GetDictionary("luxisr").RenderString(s, 10, 10, 0, 50, gin.Left)
	}
}
開發者ID:dgthunder,項目名稱:magnus,代碼行數:21,代碼來源:pull.go


注:本文中的github.com/runningwild/magnus/game.Game.GetEnt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。