예제 #1
0
파일: Bird.cs 프로젝트: JohnBenfer/GameJam
        public Bird(Game1 game)
        {
            birdSpeed = 0.5;
            width     = 150;
            height    = 150;
            LoadContent(game.Content);
            this.game = game;
            Random random = new Random();

            Y         = random.Next(100, game.SCREEN_HEIGHT - 100);
            X         = game.SCREEN_WIDTH + width;
            hitbox    = new Hitbox(height - 100, width - 100, (int)X, (int)Y);
            origin    = new Vector2((float)(width / 2), (float)(height / 2));
            offScreen = false;
        }
예제 #2
0
 public Player(Game1 game, double acceleration, double MAX_VELOCITY, int boosterLevel)
 {
     this.boosterLevel = boosterLevel;
     LoadContent(game.Content);
     currentTexture = sprites[boosterLevel];
     velocity       = 0;
     this.game      = game;
     SCREEN_WIDTH   = game.SCREEN_WIDTH;
     SCREEN_HEIGHT  = game.SCREEN_HEIGHT;
     width          = 300;
     height         = 100;
     X                 = 300;
     Y                 = SCREEN_HEIGHT / 2;
     hitbox            = new Hitbox(height - 50, width - 60, (int)X, (int)Y);
     this.acceleration = acceleration;
     this.MAX_VELOCITY = MAX_VELOCITY * -1;
     origin            = new Vector2(currentTexture.Width / 2, currentTexture.Height / 2);
 }
예제 #3
0
파일: Game1.cs 프로젝트: JohnBenfer/GameJam
        public bool Collides(Hitbox h1, Hitbox h2)
        {
            Point l1 = new Point(h1.box.X, h1.box.Y);
            Point l2 = new Point(h2.box.X, h2.box.Y);
            Point r1 = new Point(h1.box.X + h1.box.Width, h1.box.Y + h1.box.Height);
            Point r2 = new Point(h2.box.X + h2.box.Width, h2.box.Y + h2.box.Height);

            // If one rectangle is on left side of other
            if (l1.X > r2.X || l2.X > r1.X)
            {
                return(false);
            }

            // If one rectangle is above other
            if (l1.Y > r2.Y || l2.Y > r1.Y)
            {
                return(false);
            }
            return(true);
        }