Exemple #1
0
func main() {
	if len(os.Args) < 2 {
		fmt.Println("Please provide a filepath to open")
		return
	}

	g := tl.NewGame()
	c := tl.BackgroundCanvasFromFile(os.Args[1])
	g.AddEntity(NewImage(c))
	g.Start()
}
Exemple #2
0
func main() {
	g := tl.NewGame()

	level := tl.NewBaseLevel(tl.Cell{
		Bg: tl.ColorBlack,
	})

	background := tl.NewEntityFromCanvas(-50, -50, *tl.BackgroundCanvasFromFile("artwork/background/forest.png"))
	level.AddEntity(background)

	charSelect := "m_mage"
	var playerCanvases []*tl.Canvas
	for i := 0; i < 12; i++ {
		playerCanvases = append(playerCanvases, tl.BackgroundCanvasFromFile(fmt.Sprintf("artwork/sprites/player/%s/%d.png", charSelect, i)))
	}
	playerSprite := NewSprite(playerCanvases, 3, 2, 7, 0, 0, 14, 28, level)
	level.AddEntity(playerSprite)

	var enemyCanvases []*tl.Canvas
	for i := 0; i < 12; i++ {
		enemyCanvases = append(enemyCanvases, tl.BackgroundCanvasFromFile(fmt.Sprintf("artwork/sprites/enemy/flower/%d.png", i)))
	}

	enemySprite := NewSprite(enemyCanvases, 3, 2, 7, 70, 15, 14, 28, level)
	enemySprite.enemy = NewEnemy(5, 10)
	level.AddEntity(enemySprite)

	portrait := tl.BackgroundCanvasFromFile(fmt.Sprintf("artwork/sprites/player/%s/portrait.png", charSelect))
	var spellCanvases []*tl.Canvas
	for i := 0; i < 4; i++ {
		spellCanvases = append(spellCanvases, tl.BackgroundCanvasFromFile(fmt.Sprintf("artwork/spells/fireball/%d.png", i)))
	}
	player := NewPlayer(portrait, spellCanvases, playerSprite)
	playerSprite.player = player
	level.AddEntity(player)

	g.Screen().SetLevel(level)
	g.Start()
}