Exemplo n.º 1
0
        /// <summary>
        /// Instantiate the object
        /// </summary>
        /// <param name="parent">The object this is a child of. Pass null if it has no parent</param>
        /// <param name="image">The image this object should be displayed as</param>
        public GameObject(GameObject parent, rl.Image image)
        {
            //Add this to list in game manager
            GameManager.objects.Add(this);
            //Set local and global to 0
            local.point     = new MthLib.Vector3(0, 0, 0);
            local.rotation  = 0f;
            global.point    = new MthLib.Vector3(0, 0, 0);
            global.rotation = 0f;

            //Set image and relevant drawing values
            this.image = rl.Raylib.LoadTextureFromImage(image);
            imgSize    = new rl.Vector2(this.image.width, this.image.height);
            sourceRec  = new rl.Rectangle(0f, 0f, imgSize.x, imgSize.y);

            //Set the origin to the center by default
            origin = imgSize / 2;

            //If the object has a parent, add this object to its children
            if (parent != null)
            {
                hasParent = true;
                parent.children.Add(this);
            }
            else
            {
                hasParent = false;
                //Add this to list of obj with no parent in game manager
                GameManager.coreObjects.Add(this);
            }
        }
Exemplo n.º 2
0
 public Bullet(ref rl.Texture2D _sprite, string _name) : base(_name)
 {
     sprite        = new SpriteObject(_sprite);
     sprite.origin = new Vector2(sprite.Width / 2, sprite.Height / 2);
     AddChild(sprite);
     localBox = new Box(new Vector2(-5, -5), new Vector2(5, 5));
     timer    = 1;
 }
Exemplo n.º 3
0
 //Load in sprites, including the bullet sprite
 public void Load(string tankPath, string turretPath, string bulletPath)
 {
     sprite.Load(tankPath);
     turretSprite.Load(turretPath);
     turretSprite.origin.y = 40;
     bulletTexture         = LoadTexture(bulletPath);
     CreateCollider();
 }
Exemplo n.º 4
0
 // Loads the texture
 public void Load(string filename)
 {
     rl.Image img = LoadImage(filename);
     texture = LoadTextureFromImage(img);
 }