All pastes #153525 Raw Edit

Unnamed

public text v1 · immutable
#153525 ·published 2006-08-29 18:09 UTC
rendered paste body
namespace GameName 
{
    public class GameData
    {
        #region reference to engine managers and data
        public GameForm form;
        public InputManager inpMan;
        public SpriteManager sprMan;
        public TextManager textMan;
        public GuiManager guiMan;
        public Camera camera;
        public Cursor cursor;
        public Random random;
        public ShapeManager shaMan;
        public GameName.Screens.ScreenManager screenManager;
        #endregion

        Sprite ship; //The player's ship
        Sprite bullet; //The player's ship's bullet
        Sprite redball;

        SpriteArray BadGuy;

       
        public void Initialize(GameForm form)
        {
            #region initialize engine managers and data
            this.form = form;
            sprMan = GameForm.sprMan;
            inpMan = GameForm.inpMan;
            textMan = GameForm.textMan;
            guiMan = GameForm.guiMan;
            camera = GameForm.camera;
            cursor = GameForm.cursor;
            random = GameForm.random;
            shaMan = GameForm.shaMan;
            screenManager = GameForm.screenManager;
            #endregion
            

            ship = sprMan.AddSprite("Game Ship.bmp");
            //redball = sprMan.AddSprite("redball.bmp");

            BadGuy = new SpriteArray();

           BadGuy.Add(sprMan.AddSprite("redball.bmp"));
                                 
        }

      public void Activity()
        {

                if (cursor.primaryClick)
                {
                    ShootBullet();            
                }
        }

      public void Shot(Sprite sprite, SpriteManager sprMan)
       {        

            if (FRB.Collisions.rectCollisionMove(sprite, redball)) //Here is the problem, I can't use BadGuy array in place of redball
            {
                sprMan.RemoveSprite(bullet);
                BadGuy.Remove(redball);
            }

        } 

        public void ShootBullet()
        {
            bullet = sprMan.AddSprite("Bullet.bmp");
            bullet.z = 1;
            bullet.x = ship.x;
            bullet.y = ship.y;

            bullet.rotZ = (float)Math.Atan2(cursor.YAt(bullet.z) - bullet.y, cursor.XAt(bullet.z) - bullet.x);

            float speed = 50; // change to make bullet faster or slower


            bullet.xVelocity = (float)Math.Cos(bullet.rotZ) * speed;
            bullet.yVelocity = (float)Math.Sin(bullet.rotZ) * speed;

            bullet.velocity += ship.velocity;

            bullet.customFunctions += new customFunction(Shot); // calls the custom function for the collion
            
        }