示例#1
0
    public AI()
    {
        CarBitmap = SplashKit.BitmapNamed("AICar1"); //Load bitmap resources in LoadResource()
        Y         = -CarBitmap.Height;

        double r = SplashKit.Rnd();

        if (r < 0.2)
        {
            X = Map.LANE_LEFT;
        }
        if (r >= 0.2 && r < 0.4)
        {
            X = Map.LANE_LEFT + Map.LANE_WIDTH;
        }
        if (r >= 0.4 && r < 0.6)
        {
            X = Map.LANE_LEFT + Map.LANE_WIDTH * 2;
        }
        if (r >= 0.6 && r < 0.8)
        {
            X = Map.LANE_LEFT + Map.LANE_WIDTH * 3;
        }
        if (r >= 0.8)
        {
            X = Map.LANE_LEFT + Map.LANE_WIDTH * 4;
        }
    }
示例#2
0
 public Player(Window window)
 {
     CarBitmap   = SplashKit.BitmapNamed("Player1");
     _gameWindow = window;
     X           = Map.LANE_LEFT + Map.LANE_WIDTH * 2;
     Y           = _gameWindow.Height - CarBitmap.Height;
 }
示例#3
0
 // constructor of Bullet
 public Bullet(double x, double y)
 {
     _bulletBitmap = SplashKit.BitmapNamed("MetalBullet");
     _x            = x - (Width / 2);
     _y            = y - Height;
     Velocity      = new Vector2D();
 }
示例#4
0
 public void InvincibleBitmap(Bitmap player, GetBitmapName getname)
 {
     if (_reward2)
     {
         if (getname(player) == "Player1")
         {
             _player.CarBitmap = SplashKit.BitmapNamed("Player1S");
         }
         if (getname(player) == "Player2")
         {
             _player.CarBitmap = SplashKit.BitmapNamed("Player2S");
         }
     }
     else
     {
         if (getname(player) == "Player1S")
         {
             _player.CarBitmap = SplashKit.BitmapNamed("Player1");
         }
         if (getname(player) == "Player2S")
         {
             _player.CarBitmap = SplashKit.BitmapNamed("Player2");
         }
     }
 }
示例#5
0
    public Bullet(Player _Player, Vector2D _ClickCordinates)
    {
        SplashKit.LoadBitmap("Bullet", "Bullet.png");
        _PlayerBullet = SplashKit.BitmapNamed("Bullet");


        const int SPEED = 10;

        X = _Player.X;
        Y = _Player.Y;

        //point for robot
        Point2D fromPt = new Point2D()
        {
            X = _Player.X, Y = _Player.Y
        };
        //point for player
        Point2D toPt = new Point2D()
        {
            X = _ClickCordinates.X, Y = _ClickCordinates.Y
        };

        Vector2D dir = SplashKit.UnitVector(SplashKit.VectorPointToPoint(fromPt, toPt));

        Velocity = SplashKit.VectorMultiply(dir, SPEED);
    }
示例#6
0
        // Public Methods
        public override void loadCardImages()
        {
            switch (base._group)
            {
            case CityGroup.blue:
                SplashKit.LoadBitmap("BluePlayerFront" + city, "BluePlayerCardFront.png");
                _frontOfCard = SplashKit.BitmapNamed("BluePlayerFront" + city);
                break;

            case CityGroup.red:
                SplashKit.LoadBitmap("RedPlayerFront" + city, "RedPlayerCardFront.png");
                _frontOfCard = SplashKit.BitmapNamed("RedPlayerFront" + city);
                break;

            case CityGroup.yellow:
                SplashKit.LoadBitmap("YellowPlayerFront" + city, "YellowPlayerCardFront.png");
                _frontOfCard = SplashKit.BitmapNamed("YellowPlayerFront" + city);
                break;
            }

            Rectangle rect       = _frontOfCard.BoundingRectangle();
            int       textWidth  = Text.Width(city, "roboto", FONT_SIZE);
            int       textHeight = Text.Height(city, "roboto", FONT_SIZE);
            double    textX      = (rect.Width - textWidth) / 2;
            double    textY      = (rect.Height - textHeight) / 2;

            _frontOfCard.DrawText(this.city, Color.Black, "roboto", FONT_SIZE, textX, textY);
            _backOfCard = SplashKit.BitmapNamed("PlayerBack");
        }
示例#7
0
    public void DrawUI()
    {
        _window.DrawBitmap(SplashKit.BitmapNamed("Reward1"), 600, 150);


        _window.DrawBitmap(SplashKit.BitmapNamed("Reward2"), 600, 300);
    }
示例#8
0
 public Bullet(double x, double y, double angle)
 {
     _bulletBitmap = SplashKit.BitmapNamed("Bullet");
     _x            = x - _bulletBitmap.Width / 2;
     _y            = y - _bulletBitmap.Height / 2;
     _angle        = angle;
     _active       = true;
 }
示例#9
0
        public override void DrawEntity(CDraw toDraw) //draws regular entities (not players)
        {
            float absX = toDraw.X * Settings.CellWidth;
            float absY = toDraw.Y * Settings.CellHeight;

            SplashKit.DrawBitmap(SplashKit.BitmapNamed("Air"), absX, absY);
            SplashKit.DrawBitmap(SplashKit.BitmapNamed(toDraw.Type.ToString()), absX, absY);
        }
示例#10
0
 public MovingObject(string bitmap, double x, int velocity)
 {
     _bitmap        = SplashKit.BitmapNamed(bitmap);
     _position.X    = x;
     _position.Y    = 0;
     _velocity      = velocity;
     _width         = SplashKit.BitmapWidth(_bitmap);
     _floatingState = new AboveWaterState();
 }
示例#11
0
        public Player()
        {
            Angle       = 270;
            _shipBitmap = SplashKit.BitmapNamed("Gliese");

            _life  = 5;
            _lifeX = 10;
            _lifeY = 10;
        }
示例#12
0
 public Map(Window window)
 {
     _cactusBitmap = SplashKit.BitmapNamed("Cactus");
     _gameWindow   = window;
     _myTimer      = new Timer("timer");
     _myTimer.Start();
     _cactus1X = LANE_LEFT - _cactusBitmap.Width - 5;
     _cactus1Y = 0;
     _cactus2X = LANE_LEFT + LANE_WIDTH * 5 + 5;
     _cactus2Y = -_gameWindow.Height / 2;
 }
示例#13
0
 public override void CollisionCheck(Frog frog)
 {
     foreach (MovingObject movingObj in GetList)
     {
         // kills frog if hit by a vehicle
         if (SplashKit.BitmapCollision(movingObj.Bitmap, movingObj.Position, SplashKit.BitmapNamed("frog"), frog.Position))
         {
             frog.Splat();
         }
     }
 }
示例#14
0
    //Constuctor of Player
    //with gameWindow and Bullet pass as parameter
    public Player(Window gameWindow, List <Bullet> Bullets)
    {
        _playerBitmap = SplashKit.BitmapNamed("Pegasi");
        X             = (gameWindow.Width - Width) / 2;
        Y             = (gameWindow.Height - Height);
        Bullet bullet = new Bullet(X + (Width / 2), Y + (Height / 2));

        Bullets.Add(bullet);
        _angle = 0;

        Quit = false;
    }
示例#15
0
    public void SpaceMove()
    {
        if (_myTimer.Ticks < 200)
        {
            _spaceBitmap = SplashKit.BitmapNamed("Space");
        }

        if (_myTimer.Ticks >= 600)
        {
            _myTimer.Start();
        }
    }
示例#16
0
        // Public Methods
        public override void loadCardImages()
        {
            SplashKit.LoadBitmap("InfectionFront" + city, "InfectionCardFront.png");
            _frontOfCard = SplashKit.BitmapNamed("InfectionFront" + city);
            Rectangle rect       = _frontOfCard.BoundingRectangle();
            int       textWidth  = Text.Width(city, "roboto", FONT_SIZE);
            int       textHeight = Text.Height(city, "roboto", FONT_SIZE);
            double    textX      = (rect.Width - textWidth) / 2;
            double    textY      = (rect.Height - textHeight) / 2;

            _frontOfCard.DrawText(this.city, Color.Black, "roboto", FONT_SIZE, textX, textY);
            _backOfCard = SplashKit.BitmapNamed("InfectionBack");
        }
示例#17
0
        public void Menu()
        {
            string        filePath = @"Resources/txtfiles/menu.txt";
            List <string> menu     = File.ReadAllLines(filePath).ToList();

            foreach (string line in menu)
            {
                string[] entries = line.Split(',');
                string   name    = entries[0];
                int      x       = int.Parse(entries[1]);
                int      y       = int.Parse(entries[2]);
                SplashKit.DrawBitmap(SplashKit.BitmapNamed(name), x, y);
            }
        }
示例#18
0
        public LightStrip(int num)
        {
            const int LIGHT_Y = 50;

            _bulbs = new List <LightBulb>();
            int bulbWidth = SplashKit.BitmapNamed("On").Width;
            int bulbGap   = bulbWidth + 5;

            for (int i = 0; i < num; i++)
            {
                LightBulb tmp = new LightBulb(bulbGap * i, LIGHT_Y);
                _bulbs.Add(tmp);
            }
        }
示例#19
0
    public RaceGame(Window w)
    {
        _window = w;
        LoadResource();
        _player  = SplashKit.BitmapNamed("Player1");
        _myTimer = new Timer("timer");
        _myTimer.Start();

        _cactusBitmap = SplashKit.BitmapNamed("Cactus");
        _cactus1X     = LANE_LEFT - _cactusBitmap.Width - 5;
        _cactus1Y     = 0;
        _cactus2X     = LANE_LEFT + LANE_WIDTH * 5 + 5;
        _cactus2Y     = -_window.Height / 2;
    }
示例#20
0
    public void DrawBackground()
    {
        SplashKit.LoadBitmap("background", "42.jpg");
        //Bitmap background = new Bitmap("background",0,0);
        Bitmap background;

        background = SplashKit.BitmapNamed("background");

        SplashKit.DrawBitmap("background", 0, 0);
        SplashKit.DrawBitmap("background", _gameWindow.Width - background.Width, 0);
        SplashKit.DrawBitmap("background", 0, _gameWindow.Height - background.Height);
        SplashKit.DrawBitmap("background", _gameWindow.Width - background.Width, _gameWindow.Height - background.Height);
        SplashKit.DrawBitmap("background", (_gameWindow.Width - background.Width) / 2, (_gameWindow.Height - background.Height) / 2);
    }
示例#21
0
 public Player(Window gameWindow)
 {
     SplashKit.LoadBitmap("Player", "Player.png");
     SplashKit.LoadBitmap("Life", "Life.png");      //Task 62
     _PlayerBitmap = SplashKit.BitmapNamed("Player");
     _PlayerLife   = SplashKit.BitmapNamed("Life"); //Task 62
     X             = (gameWindow.Width - Width) / 2;
     Y             = (gameWindow.Height - Height) / 2;
     _PlayerTimer  = new Timer("Player Timer"); //Task 62
     _PlayerTimer.Start();                      //Task 62
     _angle = 0;
     Quit   = false;
     _Life  = 5;     //Task 62
     _Fired = false; //Task 62
 }
示例#22
0
        // reset button giving player the option to play again with 3 lives
        public void PlayAgain()
        {
            Bitmap reset = SplashKit.BitmapNamed("reset");

            SplashKit.DrawBitmap(reset, 240, 650);

            if (SplashKit.MouseClicked(MouseButton.LeftButton))
            {
                if (SplashKit.MousePosition().X > 240 && SplashKit.MousePosition().X < 460)
                {
                    if (SplashKit.MousePosition().Y > 650 && SplashKit.MousePosition().Y < 750)
                    {
                        _frog = new Frog();
                    }
                }
            }
        }
示例#23
0
        public override bool HasCollided(CPlayer plr, Component comp)
        {
            if (!comp.Self.HasComponent <CDraw>())
            {
                return(false);
            }
            CDraw toCheck = comp.Self.GetComponent <CDraw>();

            return(SplashKit.BitmapCollision(
                       SplashKit.BitmapNamed($"Player{plr.Data.PlayerNum}"),
                       plr.Data.AbsoluteX,
                       plr.Data.AbsoluteY,
                       SplashKit.BitmapNamed(toCheck.Type.ToString()),
                       toCheck.X * Settings.CellWidth,
                       toCheck.Y * Settings.CellHeight
                       ));
        }
示例#24
0
        // tracks game according to frogs life state
        public void FrogState()
        {
            // frog icons representing lives in bottom left corner
            for (int i = 0, x = 30; i < _frog.Lives; i++, x += 60)
            {
                SplashKit.DrawBitmap(SplashKit.BitmapNamed("frogicon"), x, 755);
            }

            // frog will be drawn as long as it has lives otherwise game will be over
            if (_frog.Lives > 0)
            {
                _frog.Draw();
            }
            else
            {
                Loses();
            }
        }
示例#25
0
 public void RoadMove()
 {
     if (_myTimer.Ticks < 200)
     {
         _road = SplashKit.BitmapNamed("Road1");
     }
     if (_myTimer.Ticks >= 200 && _myTimer.Ticks < 400)
     {
         _road = SplashKit.BitmapNamed("Road2");
     }
     if (_myTimer.Ticks >= 400 && _myTimer.Ticks < 600)
     {
         _road = SplashKit.BitmapNamed("Road3");
     }
     if (_myTimer.Ticks >= 600)
     {
         _myTimer.Start();
     }
 }
示例#26
0
 public void SwapPlayer(Bitmap p, GetBitmapName getname)
 {
     if (getname(p) == "Player1")
     {
         SpaceShipBitmap = SplashKit.BitmapNamed("Player2");
     }
     if (getname(p) == "Player2")
     {
         SpaceShipBitmap = SplashKit.BitmapNamed("Player1");
     }
     if (getname(p) == "Player1S")
     {
         SpaceShipBitmap = SplashKit.BitmapNamed("Player2S");
     }
     if (getname(p) == "Player2S")
     {
         SpaceShipBitmap = SplashKit.BitmapNamed("Player1S");
     }
 }
示例#27
0
        public void Environment()
        {
            SplashKit.FillRectangle(Color.Black, 25, 750, 650, 50);
            SplashKit.FillRectangle(Color.Black, 25, 450, 650, 250);
            SplashKit.FillRectangle(SplashKit.RGBColor(4, 0, 66), 25, 0, 650, 400);

            string        filePath    = @"Resources/txtfiles/environment.txt";
            List <string> environment = File.ReadAllLines(filePath).ToList();

            for (int i = 25; i < 675; i += 50)
            {
                foreach (string line in environment)
                {
                    string[] entries = line.Split(',');
                    string   name    = entries[0];
                    int      x       = int.Parse(entries[1]);
                    SplashKit.DrawBitmap(SplashKit.BitmapNamed(name), i, x);
                }
            }
        }
示例#28
0
    public void DrawUI()
    {
        _window.DrawText($"Your Score: {_score} M", Color.Black, SplashKit.FontNamed("FontU"), 20, 20, 20);
        _window.DrawText($"Level {_level}", Color.Black, SplashKit.FontNamed("FontJ"), 40, 20, 250);
        _window.DrawBitmap(SplashKit.BitmapNamed("Key"), 0, 400);

        _window.DrawBitmap(SplashKit.BitmapNamed("Reward1"), 600, 150);
        _window.DrawText("SpeedUp", Color.Black, SplashKit.FontNamed("FontJ"), 20, 660, 210);
        if (_reward1)
        {
            _window.DrawText($"Time left: {(_doubleSpeedTime - _timer.Ticks) / 1000} s", Color.Red, SplashKit.FontNamed("FontU"), 20, 660, 250);
        }

        _window.DrawBitmap(SplashKit.BitmapNamed("Reward2"), 600, 300);
        _window.DrawText("Invinciable", Color.Black, SplashKit.FontNamed("FontJ"), 20, 660, 360);
        if (_reward2)
        {
            _window.DrawText($"Time left: {(_invincibleTime - _timer.Ticks) / 1000} s", Color.Red, SplashKit.FontNamed("FontU"), 20, 660, 400);
        }
    }
示例#29
0
    public void DrawLife()
    {
        //makes sure that this is only run once since it is part of a while loop
        //go through for loop if Success is false
        //after execution Success is not true to it will never do this agian


        for (int k = 0; k < 3 && Success == false; k++)
        {
            DisplayLife remaining = new DisplayLife(_gameWindow);

            _livesRemaining.Add(remaining);

            System.Console.WriteLine(_livesRemaining.Count);



            if (_livesRemaining.Count > 3)
            {
                _livesRemaining.Remove(remaining);
                Success = true;
            }
        }

        string livesCount = Convert.ToString(_livesRemaining.Count);


        SplashKit.LoadBitmap("heart", "heart.png");

        Bitmap heart = SplashKit.BitmapNamed("heart");



        _gameWindow.DrawBitmap(heart, 0, 0, SplashKit.OptionScaleBmp(.1, .1));


        _gameWindow.DrawText(livesCount, Color.MistyRose, "StencilStd.otf", 25, 700, 570);
    }
示例#30
0
        public void Surface(MovingObject movingObj, string lastChar)
        {
            GameTimer timer = GameTimer.Instance;

            switch (lastChar)
            {
            case "2":
                movingObj.Bitmap = SplashKit.BitmapNamed("turtle2");
                if (timer.TimerEquals(0))
                {
                    movingObj.SetState(new BelowWaterState());
                }
                break;

            case "3":
                movingObj.Bitmap = SplashKit.BitmapNamed("turtle3");
                if (timer.TimerEquals(3000))
                {
                    movingObj.SetState(new BelowWaterState());
                }
                break;
            }
        }