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


Golang game.Ent類代碼示例

本文整理匯總了Golang中github.com/runningwild/jota/game.Ent的典型用法代碼示例。如果您正苦於以下問題:Golang Ent類的具體用法?Golang Ent怎麽用?Golang Ent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: NearestEnt

func (jm *JotaModule) NearestEnt(vs ...runtime.Val) runtime.Val {
	jm.dieOnTerminated()
	jm.engine.Pause()
	defer jm.engine.Unpause()
	g := jm.engine.GetState().(*game.Game)
	me := g.Ents[jm.myGid]
	if me == nil {
		return runtime.Nil
	}
	var closest game.Ent
	dist := 1e9
	for _, ent := range g.Ents {
		if ent == me {
			continue
		}
		if closest == nil {
			closest = ent
		} else if closest.Pos().Sub(me.Pos()).Mag2() < dist {
			dist = closest.Pos().Sub(me.Pos()).Mag2()
		}
	}
	if closest == nil {
		return runtime.Nil
	}
	return jm.newEnt(closest.Id())
}
開發者ID:runningwild,項目名稱:jota,代碼行數:26,代碼來源:scripts.go

示例2: Input

func (pm *placeMine) Input(ent game.Ent, g *game.Game, pressAmt float64, trigger bool) {
	player := ent.(*game.PlayerEnt)
	if pressAmt == 0 {
		delete(player.Processes, pm.id)
		return
	}
	proc, ok := player.Processes[pm.id].(*multiDrain)
	if !ok {
		player.Processes[pm.id] = &multiDrain{Gid: player.Gid, Unit: game.Mana{300, 0, 0}}
		return
	}
	if trigger && proc.Stored > 1 {
		proc.Stored--
		heading := (linear.Vec2{1, 0}).Rotate(ent.Angle())
		pos := ent.Pos().Add(heading.Scale(100))
		g.MakeMine(pos, linear.Vec2{}, 100, 100, 100, 100)
	}
}
開發者ID:runningwild,項目名稱:jota,代碼行數:18,代碼來源:place_mine.go

示例3: Think

func (p *pull) Think(ent game.Ent, g *game.Game) {
	player := ent.(*game.PlayerEnt)
	proc, ok := player.Processes[p.id].(*multiDrain)
	if !ok {
		return
	}
	if p.trigger && p.draining && proc.Stored > 1 {
		proc.Stored -= 0.1
		if proc.Stored <= 1.0 {
			p.draining = false
		}
		for _, ent := range g.Ents {
			ray := ent.Pos().Sub(player.Pos())
			if ray.Mag2() < 0.1 {
				continue
			}
			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(ent.Pos())
			ray = ray.Norm()
			ent.ApplyForce(ray.Scale(-p.force))
			player.ApplyForce(ray.Scale(p.force).Scale(0.01))
		}
	}
}
開發者ID:runningwild,項目名稱:jota,代碼行數:33,代碼來源:pull.go

示例4: getFrontPos

func (f *fire) getFrontPos(ent game.Ent, g *game.Game) linear.Vec2 {
	r := rand.New(g.Rng)
	theta := r.Float64() * math.Pi * 2
	dist := math.Abs(r.NormFloat64() * f.deviance)
	if dist > f.deviance*4 {
		dist = f.deviance * 4
	}
	dist = dist + dist*math.Cos(theta)
	center := (linear.Vec2{f.distToCenter, 0}).Rotate(ent.Angle()).Add(ent.Pos())
	return (linear.Vec2{0, dist}).Rotate(ent.Angle() - math.Pi/2 + theta).Add(center)
}
開發者ID:runningwild,項目名稱:jota,代碼行數:11,代碼來源:fire.go

示例5: Input

func (a *asplode) Input(ent game.Ent, g *game.Game, pressAmt float64, trigger bool) {
	if trigger && !ent.Dead() {
		// Kill ent and put down explosion
		ent.Suicide()
		g.Processes = append(g.Processes, &asplosionProc{
			StartRadius:    a.startRadius,
			EndRadius:      a.endRadius,
			DurationThinks: a.durationThinks,
			Dps:            a.dps,
			Pos:            ent.Pos(),
		})
	}
}
開發者ID:runningwild,項目名稱:jota,代碼行數:13,代碼來源:red.go

示例6: Draw

func (f *lightning) Draw(ent game.Ent, g *game.Game) {
	if !f.draw {
		return
	}
	gl.Disable(gl.TEXTURE_2D)
	gl.Color4ub(255, 255, 255, 255)
	forward := (linear.Vec2{1, 0}).Rotate(ent.Angle()).Scale(100000.0)
	gl.Begin(gl.LINES)
	v := ent.Pos().Add(forward)
	gl.Vertex2d(gl.Double(v.X), gl.Double(v.Y))
	v = ent.Pos().Sub(forward)
	gl.Vertex2d(gl.Double(v.X), gl.Double(v.Y))
	gl.End()
}
開發者ID:runningwild,項目名稱:jota,代碼行數:14,代碼來源:ability_graphics.go


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