示例#1
0
func (g *Game) Start(window *sf.RenderWindow) {
	g.window = window

	texture, err := sf.NewTextureFromFile("res/foo.png", nil)
	if err != nil {
		log.Fatal(err)
	}

	sprite, err := sf.NewSprite(texture)
	if err != nil {
		log.Fatal(err)
	}
	g.entity = &Entity{sprite}

	g.mainLoop()
}
示例#2
0
func NewTextures(dirname string) []Texture {
	dir, err := ioutil.ReadDir(dirname)
	if err != nil {
		log.Fatal(err)
	}
	Textures := make([]Texture, 0)
	for _, FileInfo := range dir {
		var Tex Texture
		Tex.Name = FileInfo.Name()
		Tex.Data, err = sf.NewTextureFromFile(dirname+FileInfo.Name(), nil)
		if err != nil {
			log.Fatal(err)
		}
		Textures = append(Textures, Tex)
	}
	return Textures
}
示例#3
0
文件: helper.go 项目: GGalizzi/rogo
package main

import (
	"encoding/json"
	"fmt"
	"os"
	"strconv"
	"strings"

	sf "bitbucket.org/krepa098/gosfml2"
)

var (
	//SpriteSheet is the file data which contains all the sprites that should be used.
	SpriteSheet, _ = sf.NewTextureFromFile("ascii.png", nil)
	Font, _        = sf.NewFontFromFile("font.ttf")
)

//ReadJSON reads the given json file in the given folder, and returns a map of any type, representing the JSON.
func ReadJSON(folder, name string) map[string]interface{} {
	file, err := os.Open(folder + "/" + name + ".json")
	if err != nil {
		panic(err)
	}

	defer file.Close()

	jParser := json.NewDecoder(file)

	var t interface{}