本文整理汇总了Golang中github.com/runningwild/magnus/game.Game类的典型用法代码示例。如果您正苦于以下问题:Golang Game类的具体用法?Golang Game怎么用?Golang Game使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Game类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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) {
defer p.reset()
player, ok := g.Ents[p.PlayerGid].(*game.PlayerEnt)
if !ok {
return
}
base_force := p.Force * p.supplied / p.required()
g.DoForEnts(func(gid game.Gid, ent game.Ent) {
if ent == game.Ent(player) {
return
}
target_pos := ent.Pos()
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 {
return
}
ray = player.Pos().Sub(ent.Pos())
// dist := ray.Mag()
ray = ray.Norm()
force := base_force // / math.Pow(dist, p.Angle/(2*math.Pi))
ent.ApplyForce(ray.Scale(-force))
player.ApplyForce(ray.Scale(force).Scale(0.01))
})
}
开发者ID:runningwild,项目名称:magnus,代码行数:32,代码来源:pull.go
示例3: 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
示例4: Think
func (p *burstProcess) Think(g *game.Game) {
player, ok := g.Ents[p.PlayerGid].(*game.PlayerEnt)
if !ok {
return
}
if p.Remaining_initial.Magnitude() == 0 {
if p.count > 0 {
p.count = -1
}
p.Frames--
if p.Frames <= 0 {
p.The_phase = game.PhaseComplete
}
g.DoForEnts(func(gid game.Gid, other game.Ent) {
if other == player {
return
}
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:runningwild,项目名称:magnus,代码行数:26,代码来源:burst.go
示例5: 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
示例6: 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
示例7: Think
func (f *fireProcessExplosion) Think(g *game.Game) {
g.DoForEnts(func(gid game.Gid, ent game.Ent) {
for _, expl := range f.Explosions {
if expl.Size() == 0 {
continue
}
if expl.Pos.Sub(ent.Pos()).Mag() <= expl.Size() {
ent.Stats().ApplyDamage(stats.Damage{stats.DamageFire, 1})
}
}
})
done := true
for i := range f.Explosions {
f.Explosions[i].Think()
if !f.Explosions[i].Done() {
done = false
}
}
if done {
f.The_phase = game.PhaseComplete
}
}
开发者ID:runningwild,项目名称:magnus,代码行数:22,代码来源:fire.go
示例8: main
func main() {
fmt.Printf("%v\n", key_map)
sys.Startup()
err := gl.Init()
if err != nil {
panic(err)
}
render.Init()
render.Queue(func() {
sys.CreateWindow(10, 10, wdx, wdy)
sys.EnableVSync(true)
err := gl.Init()
if err != nil {
panic(err)
}
})
base.InitShaders()
runtime.GOMAXPROCS(2)
ui, err = gui.Make(gin.In(), gui.Dims{wdx, wdy}, filepath.Join(datadir, "fonts", "skia.ttf"))
if err != nil {
panic(err)
}
sys.Think()
for false && len(sys.GetActiveDevices()[gin.DeviceTypeController]) < 2 {
time.Sleep(time.Millisecond * 100)
sys.Think()
}
var ids []int
var engine *cgf.Engine
var room game.Room
err = base.LoadJson(filepath.Join(base.GetDataDir(), "rooms/basic.json"), &room)
if err != nil {
panic(err)
}
if IsHost() {
sys.Think()
var g game.Game
g.Rng = cmwc.MakeGoodCmwc()
g.Rng.SeedWithDevRand()
g.Dx = 900
g.Dy = 600
g.Friction = 0.97
g.Friction_lava = 0.85
g.Room = room
var p game.Player
p.Color.R = 255
err := json.NewDecoder(bytes.NewBuffer([]byte(`
{
"Base": {
"Max_turn": 0.07,
"Max_acc": 0.2,
"Mass": 750,
"Max_rate": 10,
"Influence": 75,
"Health": 1000
},
"Dynamic": {
"Health": 1000
}
}
`))).Decode(&p.Stats)
if err != nil {
panic(err)
}
Nx := 2
Ny := 1
p.X = float64(g.Dx-Nx)/2 - 200
p.Y = float64(g.Dy-Ny)/2 - 200
for x := 0; x < Nx; x++ {
for y := 0; y < Ny; y++ {
p.X += float64(x * 25)
p.Y += float64(y * 25)
p.Gid++
// p.Mass += float64(x+y) * 150
p.Processes = make(map[int]game.Process)
temp := p
ids = append(ids, g.AddEnt(&temp))
// p.Mass -= float64(x+y) * 150
p.X -= float64(x * 25)
p.Y -= float64(y * 25)
}
}
g.Ents[0].(*game.Player).X = 500
g.Ents[0].(*game.Player).Y = 300
g.Ents[1].(*game.Player).X = 550
g.Ents[1].(*game.Player).Y = 300
g.SetLocalData()
d := sys.GetActiveDevices()
base.Log().Printf("%v\n", d)
n := 0
base.Log().Printf("%v\n", d[gin.DeviceTypeController])
for _, index := range d[gin.DeviceTypeController] {
// panic("ASD")
g.SetLocalPlayer(g.Ents[n].(*game.Player), index)
n++
if n > 2 {
break
//.........这里部分代码省略.........
开发者ID:dgthunder,项目名称:magnus,代码行数:101,代码来源:main.go
注:本文中的github.com/runningwild/magnus/game.Game类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论