Exemple #1
0
func (e *Editor) initSelectSprite() {
	img, _ := assets.DecodeImage(bytes.NewBuffer(util.Base64ToBytes(GeometryIconData)))
	mat := renderer.NewMaterial(renderer.NewTexture("diffuseMap", img, false))
	selectSprite := effects.CreateSprite(1, 1, 1, mat)
	spriteNode := renderer.NewNode()
	spriteNode.RendererParams = &renderer.RendererParams{Unlit: true}
	spriteNode.Add(selectSprite)
	e.selectSprite = selectSprite
	e.gameEngine.AddSpatialTransparent(spriteNode)
}
Exemple #2
0
func NewCharacter() *Character {
	characterImg, _ := assets.ImportImageCached("resources/stickman.png")
	characterMat := renderer.NewMaterial(renderer.NewTexture("diffuseMap", characterImg, false))
	sprite := effects.CreateSprite(4, 4, 1, characterMat)
	sprite.FaceCamera = false
	sprite.SetScale(mgl32.Vec2{characterSize, characterSize}.Vec3(0))
	sprite.SetTranslation(mgl32.Vec2{400, 400}.Vec3(0))

	body := chipmunkPhysics.NewChipmunkBody(1, 1)
	circle := chipmunk.NewCircle(vect.Vector_Zero, float32(characterSize*0.5))
	body.Body.AddShape(circle)

	return &Character{
		body:   body,
		sprite: sprite,
	}
}