예제 #1
0
    public virtual int PlayMusic(String path, int flags)
    {
        if (!musicEnabled)
        {
            return(-1);
        }

        if (musicState == 1)
        {
            MediaPlayer.Stop();
        }

        Song song = BBXnaGame.XnaGame().LoadSong(path);

        if (song == null)
        {
            musicState = 0;
            return(-1);
        }

        MediaPlayer.IsRepeating = (flags & 1) != 0;

        MediaPlayer.Play(song);
        musicState = 1;

        return(0);
    }
예제 #2
0
    /*
     * public byte[] _data;
     * int _length;
     *
     * public DataBuffer(int length)
     * {
     * _data = new byte[length+4];
     * _length = length;
     * }
     *
     * public DataBuffer(byte[] data)
     * {
     * _data = data;
     * _length = data.Length;
     * }
     *
     * public int Size()
     * {
     * return _length;
     * }
     *
     * public void Discard()
     * {
     * if (_data != null)
     * {
     *  _data = null;
     *  _length = 0;
     * }
     * }
     *
     * public void PokeByte(int addr, int value)
     * {
     * _data[addr] = (byte)value;
     * }
     *
     * public void PokeShort(int addr, int value)
     * {
     * Array.Copy(System.BitConverter.GetBytes((short)value), 0, _data, addr, 2);
     * }
     *
     * public void PokeInt(int addr, int value)
     * {
     * Array.Copy(System.BitConverter.GetBytes(value), 0, _data, addr, 4);
     * }
     *
     * public void PokeFloat(int addr, float value)
     * {
     * Array.Copy(System.BitConverter.GetBytes(value), 0, _data, addr, 4);
     * }
     *
     * public int PeekByte(int addr)
     * {
     * return (int)_data[addr];
     * }
     *
     * public int PeekShort(int addr)
     * {
     * return (int)System.BitConverter.ToInt16(_data, addr);
     * }
     *
     * public int PeekInt(int addr)
     * {
     * return System.BitConverter.ToInt32(_data, addr);
     * }
     *
     * public float PeekFloat(int addr)
     * {
     * return (float)System.BitConverter.ToSingle(_data, addr);
     * }
     *
     * public static DataBuffer Create(int length)
     * {
     * return new DataBuffer(length);
     * }
     */


    public static void LoadImageData(BBDataBuffer buffer, string path, int[] info)
    {
        var texture = BBXnaGame.XnaGame().LoadTexture2D(path);

        if (texture == null)
        {
            info[0] = 0; return;
        }                                                //new BBDataBuffer(0);}

        int bytes = 4;

        Console.WriteLine("textureformat " + texture.Format.ToString() + " " + path);

        if (texture.Format != SurfaceFormat.Color)
        {
            bytes = 3;
        }

        int size = texture.Width * texture.Height * bytes;

        info[0] = texture.Width;
        info[1] = texture.Height;

        //** assume new buffer since it a cast instance
        //buffer = new BBDataBuffer();
        buffer._New(size);
        texture.GetData <byte>(buffer._data, 0, size);
    }
예제 #3
0
    public virtual bool LoadSample__UNSAFE__(gxtkSample sample, String path)
    {
        SoundEffect sound = BBXnaGame.XnaGame().LoadSoundEffect(path);

        if (sound == null)
        {
            return(false);
        }
        sample.SetSound(sound);
        return(true);
    }
예제 #4
0
    public virtual bool LoadSurface__UNSAFE__(gxtkSurface surface, String path)
    {
        Texture2D texture = BBXnaGame.XnaGame().LoadTexture2D(path);

        if (texture == null)
        {
            return(false);
        }
        surface.SetTexture(texture);
        return(true);
    }
예제 #5
0
    public gxtkGraphics()
    {
        device = BBXnaGame.XnaGame().GetXNAGame().GraphicsDevice;

        width  = device.PresentationParameters.BackBufferWidth;
        height = device.PresentationParameters.BackBufferHeight;

        effect = new BasicEffect(device);
        effect.VertexColorEnabled = true;

        vertices = new VertexPositionColorTexture[MAX_VERTS];
        for (int i = 0; i < MAX_VERTS; ++i)
        {
            vertices[i] = new VertexPositionColorTexture();
        }

        quadIndices = new Int16[MAX_QUADS * 6];
        for (int i = 0; i < MAX_QUADS; ++i)
        {
            quadIndices[i * 6]     = (short)(i * 4);
            quadIndices[i * 6 + 1] = (short)(i * 4 + 1);
            quadIndices[i * 6 + 2] = (short)(i * 4 + 2);
            quadIndices[i * 6 + 3] = (short)(i * 4);
            quadIndices[i * 6 + 4] = (short)(i * 4 + 2);
            quadIndices[i * 6 + 5] = (short)(i * 4 + 3);
        }

        fanIndices = new Int16[MAX_VERTS * 3];
        for (int i = 0; i < MAX_VERTS; ++i)
        {
            fanIndices[i * 3]     = (short)(0);
            fanIndices[i * 3 + 1] = (short)(i + 1);
            fanIndices[i * 3 + 2] = (short)(i + 2);
        }

        rstateScissor                   = new RasterizerState();
        rstateScissor.CullMode          = CullMode.None;
        rstateScissor.ScissorTestEnable = true;

        defaultBlend = BlendState.NonPremultiplied;

        //note: ColorSourceBlend must == AlphaSourceBlend in Reach profile!
        additiveBlend = new BlendState();
        additiveBlend.ColorBlendFunction    = BlendFunction.Add;
        additiveBlend.ColorSourceBlend      = Blend.SourceAlpha;
        additiveBlend.AlphaSourceBlend      = Blend.SourceAlpha;
        additiveBlend.ColorDestinationBlend = Blend.One;
        additiveBlend.AlphaDestinationBlend = Blend.One;
    }
예제 #6
0
    public BBXnaGame(Game app)
    {
        _app     = app;
        _xnaGame = this;

        GraphicsDeviceManager devman = new GraphicsDeviceManager(_app);

        devman.PreparingDeviceSettings += new EventHandler <PreparingDeviceSettingsEventArgs>(PreparingDeviceSettings);

#if WINDOWS
        devman.IsFullScreen              = MonkeyConfig.XNA_WINDOW_FULLSCREEN == "1";
        devman.PreferredBackBufferWidth  = int.Parse(MonkeyConfig.XNA_WINDOW_WIDTH);
        devman.PreferredBackBufferHeight = int.Parse(MonkeyConfig.XNA_WINDOW_HEIGHT);
        _app.Window.AllowUserResizing    = MonkeyConfig.XNA_WINDOW_RESIZABLE == "1";
#elif XBOX
        devman.IsFullScreen              = MonkeyConfig.XNA_WINDOW_FULLSCREEN_XBOX == "1";
        devman.PreferredBackBufferWidth  = int.Parse(MonkeyConfig.XNA_WINDOW_WIDTH_XBOX);
        devman.PreferredBackBufferHeight = int.Parse(MonkeyConfig.XNA_WINDOW_HEIGHT_XBOX);
#elif WINDOWS_PHONE
        devman.IsFullScreen              = MonkeyConfig.XNA_WINDOW_FULLSCREEN_PHONE == "1";
        devman.PreferredBackBufferWidth  = int.Parse(MonkeyConfig.XNA_WINDOW_WIDTH_PHONE);
        devman.PreferredBackBufferHeight = int.Parse(MonkeyConfig.XNA_WINDOW_HEIGHT_PHONE);
#endif
    }
예제 #7
0
파일: xnagame.cs 프로젝트: Jaime2/monkey-1
    public BBXnaGame( Game app )
    {
        _app=app;
        _xnaGame=this;

        GraphicsDeviceManager devman=new GraphicsDeviceManager( _app );

        devman.PreparingDeviceSettings+=new EventHandler<PreparingDeviceSettingsEventArgs>( PreparingDeviceSettings );

        #if WINDOWS
        devman.IsFullScreen=MonkeyConfig.XNA_WINDOW_FULLSCREEN=="1";
        devman.PreferredBackBufferWidth=int.Parse( MonkeyConfig.XNA_WINDOW_WIDTH );
        devman.PreferredBackBufferHeight=int.Parse( MonkeyConfig.XNA_WINDOW_HEIGHT );
        _app.Window.AllowUserResizing=MonkeyConfig.XNA_WINDOW_RESIZABLE=="1";
        #elif XBOX
        devman.IsFullScreen=MonkeyConfig.XNA_WINDOW_FULLSCREEN_XBOX=="1";
        devman.PreferredBackBufferWidth=int.Parse( MonkeyConfig.XNA_WINDOW_WIDTH_XBOX );
        devman.PreferredBackBufferHeight=int.Parse( MonkeyConfig.XNA_WINDOW_HEIGHT_XBOX );
        #elif WINDOWS_PHONE
        devman.IsFullScreen=MonkeyConfig.XNA_WINDOW_FULLSCREEN_PHONE=="1";
        devman.PreferredBackBufferWidth=int.Parse( MonkeyConfig.XNA_WINDOW_WIDTH_PHONE );
        devman.PreferredBackBufferHeight=int.Parse( MonkeyConfig.XNA_WINDOW_HEIGHT_PHONE );
        #endif
    }