Exemple #1
0
// Enter executes when the scene is starting
func (s *DemoScene) Enter() {
	// Show a warm welomce message
	log.Println("Demo // Welcome to Kaori's Demo Scene!")
	log.Println("Demo // Loading Logo as Texture ...")

	// Load the logo as a texture using Kaori's texture module
	err := texture.Load(renderer, "./assets/kaori.png", "kaori")

	if err != nil {
		log.Fatalln("Demo // Oh no, can't load logo :(")
		log.Panic(err)
	}

	log.Println("Demo // Loading Tiled Map ...")

	// Load the map file
	data, err := ioutil.ReadFile("./assets/map.tmx")

	if err != nil {
		log.Fatalln("Demo // Oh no, can't load map :(")
		log.Panic(err)
	}

	// Parse tmx data
	log.Println("Demo // Parsing TMX Data...")

	s.testMap = new(tilemap.Map)
	err = tilemap.Unmarshal(data, s.testMap)

	if err != nil {
		log.Fatalln("Demo // Oh no, can't parse map :(")
		log.Panic(err)
	}

	// Load Tile Map's Tilesets
	log.Println("Demo // Loading Tiled Map's Tilesets ...")

	for _, ts := range s.testMap.Tilesets {
		ts.Load(renderer, "./assets")
	}
}
Exemple #2
0
// Load loads the image needed as an SDL Texture via Kaori's texture package
func (t *Tileset) Load(renderer *sdl.Renderer, folder string) error {
	fileName := t.Image.Source
	path := folder + "/" + fileName

	return texture.Load(renderer, path, t.Name)
}