当前位置: 首页>>代码示例>>Golang>>正文


Golang ecs.NewSystem函数代码示例

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


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

示例1: New

func (m *Maze) New(w *ecs.World) {
	ActiveMazeSystem = m
	m.System = ecs.NewSystem()
	m.World = w

	tilePlayer = helpers.GenerateSquareComonent(tilePlayerColor, tilePlayerColor, tileWidth, tileHeight, engi.MiddleGround)
	tileWall = helpers.GenerateSquareComonent(tileWallColor, tileWallColor, tileWidth, tileHeight, engi.ScenicGround+1)
	tileBlank = helpers.GenerateSquareComonent(tileBlankColor, tileBlankColor, tileWidth, tileHeight, engi.ScenicGround+2)
	tileGoal = helpers.GenerateSquareComonent(tileGoalColor, tileGoalColor, tileWidth, tileHeight, engi.ScenicGround+3)
	tileRoute = helpers.GenerateSquareComonent(tileRouteColor, tileRouteColor, tileWidth, tileHeight, engi.ScenicGround+4)

	m.levels = LoadLevels(m.LevelDirectory)

	engi.Mailbox.Listen("MazeMessage", func(msg engi.Message) {
		mazeMsg, ok := msg.(MazeMessage)
		if !ok {
			return
		}
		m.cleanup()

		if mazeMsg.Sequence == SequenceDescending {
			m.sequenceIndex = len(m.levels) - 1
		}

		m.sequence = mazeMsg.Sequence
		m.initialize(mazeMsg.LevelName)
	})
}
开发者ID:EtienneBruines,项目名称:bcigame,代码行数:28,代码来源:maze.go

示例2: New

func (ds *DeathSystem) New(*ecs.World) {
	ds.System = ecs.NewSystem()
	// Subscribe to ScoreMessage
	engi.Mailbox.Listen("ScoreMessage", func(message engi.Message) {
		collision, isCollision := message.(engi.CollisionMessage)
		if isCollision {
			log.Println(collision, message)
			log.Println("DEAD")
		}
	})

}
开发者ID:EtienneBruines,项目名称:engi,代码行数:12,代码来源:falling.go

示例3: New

func (ms *SpeedSystem) New(*ecs.World) {
	ms.System = ecs.NewSystem()
	engi.Mailbox.Listen("CollisionMessage", func(message engi.Message) {
		log.Println("collision")
		collision, isCollision := message.(engi.CollisionMessage)
		if isCollision {
			var speed *SpeedComponent
			if !collision.Entity.Component(&speed) {
				return
			}

			speed.X *= -1
		}
	})
}
开发者ID:EtienneBruines,项目名称:engi,代码行数:15,代码来源:headless.go

示例4: New

func (as *AudioSystem) New(*ecs.World) {
	as.System = ecs.NewSystem()

	if as.HeightModifier == 0 {
		as.HeightModifier = defaultHeightModifier
	}

	if err := al.OpenDevice(); err != nil {
		log.Println("Error initializing AudioSystem:", err)
		return
	}

	Mailbox.Listen("CameraMessage", func(msg Message) {
		_, ok := msg.(CameraMessage)
		if !ok {
			return
		}

		// Hopefully not that much of an issue, when we receive it before the CameraSystem does
		// TODO: but it is when the CameraMessage is not Incremental (i.e. the changes are big)
		al.SetListenerPosition(al.Vector{cam.X() / Width(), cam.Y() / Height(), cam.Z() * as.HeightModifier})
	})
}
开发者ID:EtienneBruines,项目名称:engi,代码行数:23,代码来源:audio.go

示例5: New

func (c *Calibrate) New(w *ecs.World) {
	ActiveCalibrateSystem = c
	c.System = ecs.NewSystem()
	c.World = w

	var err error

	c.Connection, err = gobci.Connect("")
	if err != nil {
		log.Fatal(err)
	}

	err = c.Connection.FlushData()
	if err != nil {
		log.Fatal("FlushData error: ", err)
	}

	// Get latest header info
	c.Header, err = c.Connection.GetHeader()
	if err != nil {
		log.Fatal("GetHeader error: ", err)
	}

	for i := uint32(0); i < c.Header.NChannels; i++ {
		e := ecs.NewEntity([]string{c.Type(), "RenderSystem"})
		espace := &engi.SpaceComponent{engi.Point{0, float32(i * (3*dpi + 10))}, 0, 0}
		e.AddComponent(espace)

		if c.Visualize {
			e.AddComponent(&CalibrateComponent{i})
		}

		c.AddEntity(e)
		c.World.AddEntity(e)
	}
}
开发者ID:EtienneBruines,项目名称:bcigame,代码行数:36,代码来源:calibrate.go

示例6: New

func (rs *RenderSystem) New(w *ecs.World) {
	rs.renders = make(map[PriorityLevel][]*ecs.Entity)
	rs.System = ecs.NewSystem()
	rs.world = w
	rs.ShouldSkipOnHeadless = true

	if !headless {
		if !Shaders.setup {
			Shaders.def.Initialize(Width(), Height())

			hud := &HUDShader{}
			hud.Initialize(Width(), Height())
			for i := HUDGround; i <= HighestGround; i++ {
				Shaders.Register(i, hud)
			}

			Shaders.setup = true
		}
	}

	Mailbox.Listen("renderChangeMessage", func(m Message) {
		rs.changed = true
	})
}
开发者ID:EtienneBruines,项目名称:engi,代码行数:24,代码来源:render.go

示例7: New

func (f *FPS) New(w *ecs.World) {
	f.System = ecs.NewSystem()
	f.World = w

	f.AddEntity(ecs.NewEntity([]string{f.Type()}))
}
开发者ID:EtienneBruines,项目名称:bcigame,代码行数:6,代码来源:fps.go

示例8: New

func (a *MovementSystem) New(*ecs.World) {
	a.System = ecs.NewSystem()
}
开发者ID:EtienneBruines,项目名称:bcigame,代码行数:3,代码来源:move.go

示例9: New

func (as *AudioSystem) New(*ecs.World) {
	as.System = ecs.NewSystem()

	log.Println("Warning: audio is not yet implemented on Windows")
}
开发者ID:EtienneBruines,项目名称:engi,代码行数:5,代码来源:audio_windows.go

示例10: New

func (cs *CollisionSystem) New(*ecs.World) {
	cs.System = ecs.NewSystem()
}
开发者ID:EtienneBruines,项目名称:engi,代码行数:3,代码来源:collision.go

示例11: New

func (h *Hud) New(*ecs.World) {
	h.System = ecs.NewSystem()
}
开发者ID:EtienneBruines,项目名称:bcigame,代码行数:3,代码来源:hud.go

示例12: New

func (ns *NilSystem) New() {
	ns.System = ecs.NewSystem()
}
开发者ID:EtienneBruines,项目名称:engi,代码行数:3,代码来源:benchmarks_test.go

示例13: New

func (s *HideSystem) New(*ecs.World) {
	s.System = ecs.NewSystem()
}
开发者ID:EtienneBruines,项目名称:engi,代码行数:3,代码来源:hide.go

示例14: New

func (m *MenuListener) New(w *ecs.World) {
	m.System = ecs.NewSystem()
	m.AddEntity(ecs.NewEntity([]string{m.Type()}))
}
开发者ID:EtienneBruines,项目名称:bcigame,代码行数:4,代码来源:menu.go

示例15: New

func (s *ScaleSystem) New(*ecs.World) {
	s.System = ecs.NewSystem()
}
开发者ID:EtienneBruines,项目名称:engi,代码行数:3,代码来源:scenes.go


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