當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。