示例#1
0
文件: sdl.go 项目: remogatto/gospeccy
func initSDLSubSystems(app *spectrum.Application) error {
	if sdl.Init(sdl.INIT_VIDEO|sdl.INIT_AUDIO|sdl.INIT_JOYSTICK) != 0 {
		return errors.New(sdl.GetError())
	}
	if ttf.Init() != 0 {
		return errors.New(sdl.GetError())
	}
	if sdl.NumJoysticks() > 0 {
		// Open joystick
		joystick = sdl.JoystickOpen(DEFAULT_JOYSTICK_ID)
		if joystick != nil {
			if app.Verbose {
				app.PrintfMsg("Opened Joystick %d", DEFAULT_JOYSTICK_ID)
				app.PrintfMsg("Name: %s", sdl.JoystickName(DEFAULT_JOYSTICK_ID))
				app.PrintfMsg("Number of Axes: %d", joystick.NumAxes())
				app.PrintfMsg("Number of Buttons: %d", joystick.NumButtons())
				app.PrintfMsg("Number of Balls: %d", joystick.NumBalls())
			}
		} else {
			return errors.New("Couldn't open Joystick!")
		}
	}
	sdl.WM_SetCaption("GoSpeccy - ZX Spectrum Emulator", "")
	sdl.EnableUNICODE(1)
	return nil
}
示例#2
0
func (this *RenderManager) Init() {
	this.tmx.Load("./test_cute.tmx")
	if sdl.Init(sdl.INIT_EVERYTHING) != 0 {
		log.Fatal(sdl.GetError())
	}
	this.screen = sdl.SetVideoMode(707, 600, 32, sdl.RESIZABLE)
	if this.screen == nil {
		log.Fatal(sdl.GetError())
	}
	var video_info = sdl.GetVideoInfo()
	println("HW_available = ", video_info.HW_available)
	println("WM_available = ", video_info.WM_available)
	println("Video_mem = ", video_info.Video_mem, "kb")
	sdl.EnableUNICODE(1)
	sdl.WM_SetCaption("Go-SDL SDL Test", "")
	if sdl.GetKeyName(270) != "[+]" {
		log.Fatal("GetKeyName broken")
	}
	this.ressourceManager = NewSpriteLoader()
	this.ressourceManager.Load("test_tileset.gspr")
	// this.animMap = ressourceManager.GetAnimMap()
}