コード例 #1
0
ファイル: AI.cs プロジェクト: pecarprimoz/tinr-roids
        public AI(GraphicsDevice graphicsDevice, int t)
        {
            screenHeight = graphicsDevice.Viewport.Height;
            screenWidth  = graphicsDevice.Viewport.Width;
            type         = t;
            _isAlive     = true;
            Vector2 tmpSpawn = setNegativeSpawnPoint(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height);

            //Temporary spawn
            _position.X = tmpSpawn.X;
            _position.Y = tmpSpawn.Y;
            _width      = 28;
            _height     = 28;
            size_amp    = 2;
            aiR         = 28;
            if (aiSheet == null)
            {
                //Poglej tukaj ce je path pravilen, ce ne se atlas ne bo izriseval pravilno.
                //NOTE TO SELF, MORS PREMAKNT VSE V C:\Users\primoz-pc\source\repos\test\test\bin\Windows\x86\Debug\Content, KER SE OD TAM ZAGANJA DEBUGGER
                using (var stream = TitleContainer.OpenStream("Content/AI/Mine/mines_together.png"))
                {
                    aiSheet = Texture2D.FromStream(graphicsDevice, stream);
                }
            }
            //Init collision detection
            _collision = new CollsionDetection(_position, graphicsDevice, _width * size_amp, _height * size_amp, _angle, 2, aiR);
            spin       = new Animation();
            for (int i = 0; i < 3; i++)
            {
                spin.AddFrame(new Rectangle((i * (int)_width), 0, (int)_width, (int)_height), TimeSpan.FromSeconds(.15));
            }
            currentAnimation = spin;
        }
コード例 #2
0
        public bool DoRectangleCircleOverlap(CollsionDetection cir, CollsionDetection rect, int _circSize)
        {
            Vector2 circleDistance;

            circleDistance.X = Math.Abs((cir._position.X - rect._position.X));
            circleDistance.Y = Math.Abs(cir._position.Y - rect._position.Y);

            if (circleDistance.X > (rect._width / 2 + _circSize))
            {
                return(false);
            }
            if (circleDistance.Y > (rect._height / 2 + _circSize))
            {
                return(false);
            }

            if (circleDistance.X <= (rect._width / 2))
            {
                return(true);
            }
            if (circleDistance.Y <= (rect._height / 2))
            {
                return(true);
            }

            double cornerDistance_sq = Math.Pow((circleDistance.X - rect._width / 2), 2) + Math.Pow((circleDistance.Y - rect._height / 2), 2);

            return(cornerDistance_sq <= (_circSize ^ 2));
        }
コード例 #3
0
        public bool DoCircleCircleOverlap(CollsionDetection cirA, CollsionDetection cirB, int _cirSizeA, int _cirSizeB)
        {
            float dx       = cirA._position.X - cirB._position.X;
            float dy       = cirA._position.Y - cirB._position.Y;
            int   radii    = _cirSizeA + _cirSizeB;
            int   sqrradi  = radii * radii;
            float distsqrt = (dx * dx) + (dy * dy);

            return(distsqrt <= sqrradi);
        }
コード例 #4
0
ファイル: Planetoids.cs プロジェクト: pecarprimoz/tinr-roids
        public Planetoids(GraphicsDevice graphicsDevice)
        {
            Random r = new Random(DateTime.Now.Millisecond);

            _isHit     = false;
            _accel.X   = 3;
            _accel.Y   = 3;
            _direction = generateNewDirection();
            //Console.WriteLine(_direction);
            int reduction_for_current_rock = r.Next(1, 5);

            size_reduction = reduction_for_current_rock;
            planetHeight   = 130;
            planetWidth    = 130;
            _angle         = 0f;
            rockR          = 65 / size_reduction;
            _mass          = 5 / size_reduction;
            Vector2 randomSpawn = setNegativeSpawnPoint(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height);

            _actualPos.X = randomSpawn.X;
            _actualPos.Y = randomSpawn.Y;
            //fix collision detection so that R is set by size reduction, DONE
            //Console.WriteLine(_actualPos);
            if (planetoidsSheet == null)
            {
                //Poglej tukaj ce je path pravilen, ce ne se atlas ne bo izriseval pravilno.
                //NOTE TO SELF, MORS PREMAKNT VSE V C:\Users\primoz-pc\source\repos\test\test\bin\Windows\x86\Debug\Content, KER SE OD TAM ZAGANJA DEBUGGER
                using (var stream = TitleContainer.OpenStream("Content/Planetoids/planetoids.png"))
                {
                    planetoidsSheet = Texture2D.FromStream(graphicsDevice, stream);
                }
            }
            _collision = new CollsionDetection(_actualPos, graphicsDevice, planetWidth / size_reduction, planetHeight / size_reduction, _angle, 2, rockR);
            spin       = new Animation();
            Random pick_a_rock = new Random(DateTime.Now.Millisecond);
            int    nice_rock   = pick_a_rock.Next(0, 4);

            for (int i = 0; i < 12; i++)
            {
                spin.AddFrame(new Rectangle((i * (int)planetWidth), (int)nice_rock * 130, (int)planetWidth, (int)planetHeight), TimeSpan.FromSeconds(.15));
            }
            currentAnimation = spin;
        }
コード例 #5
0
        public Projectile(GraphicsDevice graphicsDevice, ContentManager content)
        {
            canShoot = true;
            isFlying = false;
            if (projectileSheet == null)
            {
                //Poglej tukaj ce je path pravilen, ce ne se atlas ne bo izriseval pravilno.
                //NOTE TO SELF, MORS PREMAKNT VSE V C:\Users\primoz-pc\source\repos\test\test\bin\Windows\x86\Debug\Content, KER SE OD TAM ZAGANJA DEBUGGER
                using (var stream = TitleContainer.OpenStream("Content/Projectiles/shotsmall.png"))
                {
                    projectileSheet = Texture2D.FromStream(graphicsDevice, stream);
                    _width          = projectileSheet.Width;
                    _height         = projectileSheet.Height;
                }
            }

            projectileShoot = content.Load <SoundEffect>("Sounds/Laser_Shoot18");
            //Init collision detection
            _collision = new CollsionDetection(_position, graphicsDevice, _width, _height, _angle, 1);
        }
コード例 #6
0
        public PlayerCharacter(GraphicsDevice graphicsDevice)
        {
            _isAlive = true;
            //Temporary spawn
            _position.X = 400;
            _position.Y = 300;

            if (spaceShipsSheet == null)
            {
                //Poglej tukaj ce je path pravilen, ce ne se atlas ne bo izriseval pravilno.
                //NOTE TO SELF, MORS PREMAKNT VSE V C:\Users\primoz-pc\source\repos\test\test\bin\Windows\x86\Debug\Content, KER SE OD TAM ZAGANJA DEBUGGER
                using (var stream = TitleContainer.OpenStream("Content/Ships/main-ship-v1.png"))
                {
                    spaceShipsSheet = Texture2D.FromStream(graphicsDevice, stream);
                    _width          = spaceShipsSheet.Width;
                    _height         = spaceShipsSheet.Height;
                }
            }
            //Init collision detection
            _collision = new CollsionDetection(_position, graphicsDevice, _width, _height, _angle, 1);
        }
コード例 #7
0
ファイル: AIUFO.cs プロジェクト: pecarprimoz/tinr-roids
        public AIUFO(GraphicsDevice graphicsDevice)
        {
            _isAlive = true;
            //Temporary spawn

            screenWidth  = graphicsDevice.Viewport.Width;
            screenHeight = graphicsDevice.Viewport.Height;
            currentDest  = generateRandomPointOnMap();
            _position    = new Vector2(300, 300);

            if (spaceShipsSheet == null)
            {
                //Poglej tukaj ce je path pravilen, ce ne se atlas ne bo izriseval pravilno.
                //NOTE TO SELF, MORS PREMAKNT VSE V C:\Users\primoz-pc\source\repos\test\test\bin\Windows\x86\Debug\Content, KER SE OD TAM ZAGANJA DEBUGGER
                using (var stream = TitleContainer.OpenStream("Content/Ships/main-ship-v1.png"))
                {
                    spaceShipsSheet = Texture2D.FromStream(graphicsDevice, stream);
                    _width          = spaceShipsSheet.Width;
                    _height         = spaceShipsSheet.Height;
                }
            }
            //Init collision detection
            _collision = new CollsionDetection(_position, graphicsDevice, _width, _height, _angle, 1);
        }