func NewImage(_file string) *PU_Image { image := &PU_Image{blendmode: sdl.BLENDMODE_BLEND} image.surface = sdl.LoadImage(GetPath() + _file) image.Reload() return image }
//Load image from file func NewImage(_file string) *Image { image := &Image{blendmode: sdl.BLENDMODE_BLEND} addResource(image) image.surface = sdl.LoadImage(GetPath() + _file) image.reload() return image }
func (g *PU_Game) LoadPokeImage(_id int, _type int) *PU_Image { var imagemap map[uint16]*PU_Image var location string switch _type { case POKEIMAGE_FRONT: imagemap = g.pokeImageMap_Front location = "data/pokemon/front/" case POKEIMAGE_BACK: imagemap = g.pokeImageMap_Back location = "data/pokemon/back/" case POKEIMAGE_ICON: imagemap = g.pokeImageMap_Icon location = "data/pokemon/icon/" } if imagemap != nil { idfile := fmt.Sprintf("%d.png", _id) if _id < 10 { idfile = "00" + idfile } else if _id < 100 { idfile = "0" + idfile } surface := sdl.LoadImage(location + idfile) if surface == nil { surface = sdl.LoadImage(fmt.Sprintf("%s%d.png", location, _id)) if surface == nil { return nil } } image := NewImageFromSurface(surface) g_engine.AddResource(image) imagemap[uint16(_id)] = image return image } return nil }
func (g *PU_Game) LoadGameImage(_file string, _dir string) (*PU_Image, int) { name := strings.Replace(_file, ".png", "", -1) id, err := strconv.Atoi(name) if err != nil { return nil, 0 } surface := sdl.LoadImage(_dir + _file) if surface == nil { return nil, 0 } image := NewImageFromSurface(surface) g_engine.AddResource(image) return image, id }
func (g *PU_Game) LoadCreatureImages() { dir := GetPath() + "data/creatures/" files, err := ioutil.ReadDir(dir) if err != nil { fmt.Printf("Couldn't open directory: %v. Error: %v\n", dir, err.Error()) return } for i := 0; i < len(files); i++ { surface := sdl.LoadImage(dir + files[i].Name) if surface == nil { continue } image := NewImageFromSurface(surface) g_engine.AddResource(image) if image != nil { file := strings.Replace(files[i].Name, ".png", "", -1) parts := strings.Split(file, "_") bodypart, err := strconv.Atoi(parts[0]) if err != nil { continue } id, err := strconv.Atoi(parts[1]) if err != nil { continue } dir, err := strconv.Atoi(parts[2]) if err != nil { continue } frame, err := strconv.Atoi(parts[3]) if err != nil { continue } key := (uint32(bodypart) | (uint32(id) << 8) | (uint32(dir) << 16) | (uint32(frame) << 24)) g.creatureImageMap[key] = image } } }