public BasicSprite(TileSet ts)
 {
     if (ts != null) {
         collisionxExtent = ts.ExtentX;
         collisionyExtent = ts.ExtentY;
         tilePosition = new Rectangle(ts.XOrigin,ts.YOrigin,ts.ExtentX*2,ts.ExtentY*2);
         tiles = ts;
         animationSpeed = 1.0f;
         totalFrames = ts.NumberFrameColumns * ts.NumberFrameRows;
     }
     else
         throw new Exception("Cannot create sprite without valid tile set");
 }
        private void Initialize()
        {
            try {
                //Common DirectX setup calls...
                PresentParameters presentParams = new PresentParameters();
                presentParams.Windowed = true;
                presentParams.SwapEffect = SwapEffect.Discard;
                presentParams.BackBufferFormat = Format.Unknown;
                presentParams.AutoDepthStencilFormat = DepthFormat.D16;
                presentParams.EnableAutoDepthStencil = true;

                // Store the default adapter
                int adapterOrdinal = D3D.Manager.Adapters.Default.Adapter;
                CreateFlags flags = CreateFlags.SoftwareVertexProcessing;

                // Check to see if we can use a pure hardware device
                D3D.Caps caps = D3D.Manager.GetDeviceCaps(adapterOrdinal, D3D.DeviceType.Hardware);

                // Do we support hardware vertex processing?
                if (caps.DeviceCaps.SupportsHardwareTransformAndLight)
                    // Replace the software vertex processing
                    flags = CreateFlags.HardwareVertexProcessing;

                device = new D3D.Device(0, D3D.DeviceType.Hardware, this, flags, presentParams);
                device.DeviceReset += new System.EventHandler(this.OnResetDevice);
                OnResetDevice(device, null);

                //Space Donuts setup
                donutTexture = TextureLoader.FromFile(device, MediaUtilities.FindFile(TileSetFileName), 1024, 1024,
                    1, 0,Format.A8R8G8B8, Pool.Managed, Filter.Point, Filter.Point, (unchecked((int)0xff000000)));

                donutTileSet = new TileSet(donutTexture, 0, 0, 6, 5, 32, 32);
                pyramidTileSet = new TileSet(donutTexture, 0, 384, 4, 10, 16, 16);
                sphereTileSet = new TileSet(donutTexture, 0, 512, 2, 20, 8, 8);
                cubeTileSet = new TileSet(donutTexture, 0, 544, 2, 20, 8, 8);
                shipTileSet = new TileSet(donutTexture, 0, 576, 4, 10, 16, 16);
                nixiesTileSet = new TileSet(donutTexture, 0, 832, 1, 14, 8, 8);
                bulletTileSet = new TileSet(donutTexture, 304, 832, 1, 1, 8, 2);

                //set up DirectInput keyboard device...
                kbd = new DI.Device(SystemGuid.Keyboard);
                kbd.SetCooperativeLevel(this,
                    DI.CooperativeLevelFlags.Background | DI.CooperativeLevelFlags.NonExclusive);
                kbd.Acquire();

                soundHandler = new SoundHandler(this);

                sm.OnCollisionDetected += new SpriteManager.HandleCollision(this.CollisionHandler);

                hrt.Start();
            }
            catch (DirectXException e) {
                Console.WriteLine("Exception is " + e.ErrorString);
                // Catch any errors and return a failure
            }
        }
        private float angleIncrement = 360f/40f; //40 frames in ship

        #endregion Fields

        #region Constructors

        public ShipSprite(TileSet ts)
            : base(ts)
        {
            this.AnimationSpeed = 0f; //ship only moves from user input
            this.Frame = 10; //aligns ship direction to 0 radians
        }
Esempio n. 4
0
 public ShipSprite(TileSet ts) : base(ts)
 {
     this.AnimationSpeed = 0f;    //ship only moves from user input
     this.Frame          = 10;    //aligns ship direction to 0 radians
 }
 public BulletSprite(TileSet ts)
     : base(ts)
 {
     this.VisuallyRotates = true;
 }
Esempio n. 6
0
        private void Initialize()
        {
            try {
                //Common DirectX setup calls...
                PresentParameters presentParams = new PresentParameters();
                presentParams.Windowed = true;
                //				presentParams.BackBufferHeight = screenHeight;
                //				presentParams.BackBufferWidth = screenWidth;
                presentParams.SwapEffect             = SwapEffect.Discard;
                presentParams.BackBufferFormat       = Format.Unknown;
                presentParams.AutoDepthStencilFormat = DepthFormat.D16;
                presentParams.EnableAutoDepthStencil = true;

                // Store the default adapter
                int         adapterOrdinal = D3D.Manager.Adapters.Default.Adapter;
                CreateFlags flags          = CreateFlags.SoftwareVertexProcessing;

                // Check to see if we can use a pure hardware device
                D3D.Caps caps = D3D.Manager.GetDeviceCaps(adapterOrdinal, D3D.DeviceType.Hardware);

                // Do we support hardware vertex processing?
                if (caps.DeviceCaps.SupportsHardwareTransformAndLight)
                {
                    // Replace the software vertex processing
                    flags = CreateFlags.HardwareVertexProcessing;
                }

                // Do we support a pure device?
                if (caps.DeviceCaps.SupportsPureDevice)
                {
                    flags |= CreateFlags.PureDevice;
                }

                device              = new D3D.Device(0, D3D.DeviceType.Hardware, this, flags, presentParams);
                device.DeviceReset += new System.EventHandler(this.OnResetDevice);
                OnResetDevice(device, null);

                //Space Donuts setup
                donutTexture = TextureLoader.FromFile(device, MediaUtilities.FindFile(TileSetFileName), 1024, 1024,
                                                      1, 0, Format.A8R8G8B8, Pool.Managed, Filter.Point, Filter.Point, (unchecked ((int)0xff000000)));

                donutTileSet   = new TileSet(donutTexture, 0, 0, 6, 5, 32, 32);
                pyramidTileSet = new TileSet(donutTexture, 0, 384, 4, 10, 16, 16);
                sphereTileSet  = new TileSet(donutTexture, 0, 512, 2, 20, 8, 8);
                cubeTileSet    = new TileSet(donutTexture, 0, 544, 2, 20, 8, 8);
                shipTileSet    = new TileSet(donutTexture, 0, 576, 4, 10, 16, 16);
                nixiesTileSet  = new TileSet(donutTexture, 0, 832, 1, 14, 8, 8);
                bulletTileSet  = new TileSet(donutTexture, 304, 832, 1, 1, 8, 2);

                //set up DirectInput keyboard device...
                kbd = new DI.Device(SystemGuid.Keyboard);
                kbd.SetCooperativeLevel(this,
                                        DI.CooperativeLevelFlags.Background | DI.CooperativeLevelFlags.NonExclusive);
                kbd.Acquire();

                soundHandler = new SoundHandler(this);

                sm.OnCollisionEventHandler += new SpriteManager.HandleCollision(this.CollisionHandler);

                hrt.Start();
            }
            catch (DirectXException) {
                // Catch any errors and return a failure
            }
        }
Esempio n. 7
0
 public BulletSprite(TileSet ts) : base(ts)
 {
     this.VisuallyRotates = true;
 }
 public NixieSprite(TileSet ts)
     : base(ts)
 {
     nixiePosition = new Rectangle(ts.XOrigin,ts.YOrigin,ts.ExtentX*2,ts.ExtentY*2);
     nixiePosition.Y = ts.YOrigin; //this value never changes
 }