//Cut out sprites from spritesheet and put them in a list //Виокремлення спрайтів із загального полотна і поміщення їх у контейнер list public void MakeSprites() { int SpriteWhite = 268; //8 int SpriteWhite2 = 270; //9 int SpriteFrightened = 272; //10 int SpriteFrightened2 = 274; //11 int SpriteEyesRight = 592; //12 int SpriteEyesRight2 = 594; //13 int SpriteEyesDown = 596; //14 int SpriteEyesDown2 = 598; //15 int SpriteEyesLeft = 600; //16 int SpriteEyesLeft2 = 602; //17 int SpriteEyesUp = 604; //18 int SpriteEyesUp2 = 606; //19 int SpriteScore200 = 400; //20 int SpriteScore400 = 402; //21 int SpriteScore800 = 404; //22 int SpriteScore1600 = 406; //23 Sprites.Add(PacForm.CutSprite(SpriteUp, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteUp2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteLeft, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteLeft2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteDown, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteDown2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteRight, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteRight2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteWhite, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteWhite2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteFrightened, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteFrightened2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteEyesUp, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteEyesUp2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteEyesLeft, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteEyesLeft2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteEyesDown, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteEyesDown2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteEyesRight, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteEyesRight2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteScore200, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteScore400, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteScore800, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(SpriteScore1600, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); }
void MakeSprites() { int dotSprite = 16; //0 int powerPelletSprite = 20; //1 int cherriesSprite = 320; //2 int strawberrySprite = 322; //3 int peachSprite = 324; //4 int appleSprite = 328; //5 int grapesSprite = 330; //6 int galaxianSprite = 332; //7 int bellSprite = 326; //8 int keySprite = 334; //9 int score_100_1_Sprite = 129; //10 int score_300_1_Sprite = 130; //11 int score_500_1_Sprite = 131; //12 int score_700_1_Sprite = 132; //13 int score_00_Sprite = 133; //14 int score_1000_1_Sprite = 134; //15 int score_2000_1_1Sprite = 135; //16 int score_2000_2_Sprite = 136; //17 int score_3000_1_Sprite = 137; //18 int score_3000_2_Sprite = 138; //19 int score_5000_1_Sprite = 139; //20 int score_5000_2_Sprite = 140; //21 int score_5000_3_Sprite = 141; //22 int score_5000_4_Sprite = 142; //23 Sprites.Add(PacForm.CutSprite(dotSprite, PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(powerPelletSprite, PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(cherriesSprite, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(strawberrySprite, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(peachSprite, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(appleSprite, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(grapesSprite, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(galaxianSprite, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(bellSprite, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(keySprite, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(score_100_1_Sprite, PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(score_300_1_Sprite, PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(score_500_1_Sprite, PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(score_700_1_Sprite, PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(score_00_Sprite, PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(score_1000_1_Sprite, PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(score_2000_1_1Sprite, PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(score_2000_2_Sprite, PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(score_3000_1_Sprite, PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(score_3000_2_Sprite, PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(score_5000_1_Sprite, PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(score_5000_2_Sprite, PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(score_5000_3_Sprite, PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale)); Sprites.Add(PacForm.CutSprite(score_5000_4_Sprite, PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale)); }
//Cutting sprites from spritesheet. Вирізання спрайтів з полотна private void MakeSprites() { int SpriteLeft = 192; int SpriteLeft2 = 196; int SpriteUp = 194; int SpriteUp2 = 198; int SpriteRight = 200; int SpriteRight2 = 204; int SpriteDown = 202; int SpriteDown2 = 206; int SpriteFull = 448; int SpriteDead = 456; pacmanSprites.Add(PacForm.CutSprite(SpriteUp, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); pacmanSprites.Add(PacForm.CutSprite(SpriteUp2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); pacmanSprites.Add(PacForm.CutSprite(SpriteFull, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); pacmanSprites.Add(PacForm.CutSprite(SpriteUp2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); pacmanSprites.Add(PacForm.CutSprite(SpriteLeft, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); pacmanSprites.Add(PacForm.CutSprite(SpriteLeft2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); pacmanSprites.Add(PacForm.CutSprite(SpriteFull, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); pacmanSprites.Add(PacForm.CutSprite(SpriteLeft2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); pacmanSprites.Add(PacForm.CutSprite(SpriteDown, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); pacmanSprites.Add(PacForm.CutSprite(SpriteDown2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); pacmanSprites.Add(PacForm.CutSprite(SpriteFull, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); pacmanSprites.Add(PacForm.CutSprite(SpriteDown2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); pacmanSprites.Add(PacForm.CutSprite(SpriteRight, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); pacmanSprites.Add(PacForm.CutSprite(SpriteRight2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); pacmanSprites.Add(PacForm.CutSprite(SpriteFull, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); pacmanSprites.Add(PacForm.CutSprite(SpriteRight2, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); for (int i = 0; i < 24; i += 2) { pacmanSprites.Add(PacForm.CutSprite(SpriteDead + i, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale)); } }
public Ghost(PacForm frm) { int SpriteEmpty = 478; travellingGhosts = 0; emptySprite = PacForm.CutSprite(SpriteEmpty, PacForm.SpriteSize, PacForm.SpriteSize * PacForm.SpriteScale); form = frm; directions[0] = new Point(0, -1); directions[1] = new Point(-1, 0); directions[2] = new Point(0, 1); directions[3] = new Point(1, 0); speed = 1F; blinkTimer = new Timer(); blinkTimer.Interval = form.levels.blinkTimerInterval; blinkTimer.Tick += new EventHandler(BlinkingAnimation); showScoreTimer = new Timer(); showScoreTimer.Interval = 1000; showScoreTimer.Tick += new EventHandler(showEatenScore); scatterTimer = new Timer(); scatterTimer.Tick += new EventHandler(ScatterOffEvent); chaseTimer = new Timer(); chaseTimer.Tick += new EventHandler(ChaseOffEvent); scatterStopwatch = new Stopwatch(); chaseStopwatch = new Stopwatch(); //Used in blinking animation. Використовується у анімації блимання frightenedSpriteNumber = 10; AboveHome = new Point(14, 14); waypointsCounter = 0; spriteLoop = 0; //Exit conditions. Умови иходу привидів з домівки canExit = new bool[4]; ghostItemCounter = new int[4]; InitializeSound(); }
public Board(PacForm form) { size = new Size(28, 36);//224 x 288 boardPBSize = new Size(size.Width * PacForm.BoardTileSize * PacForm.SpriteScale, size.Height * PacForm.BoardTileSize * PacForm.SpriteScale); board = new int[size.Width, size.Height]; map = new Bitmap(size.Width * PacForm.BoardTileSize * PacForm.SpriteScale, size.Height * PacForm.BoardTileSize * PacForm.SpriteScale); boardPB = new PictureBox(); mapChanged = new Bitmap(map.Width, map.Height); //Board layout. Numbers represent sprites on the spritesheet. 022 and 023 are empty sprites //Розташування об'єктів на ігровому полі. Номера відповідають номерам спрайтів. 022 та 023 є пустими зображеннями board = new int[, ] { { 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023 }, { 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023 }, { 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023 }, { 145, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 187, 186, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 154, 144 }, { 147, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 121, 120, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 146 }, { 147, 022, 119, 158, 158, 118, 022, 119, 158, 158, 158, 118, 022, 121, 120, 022, 119, 158, 158, 158, 118, 022, 119, 158, 158, 118, 022, 146 }, { 147, 022, 121, 023, 023, 120, 022, 121, 023, 023, 023, 120, 022, 121, 120, 022, 121, 023, 023, 023, 120, 022, 121, 023, 023, 120, 022, 146 }, { 147, 022, 185, 116, 116, 184, 022, 185, 116, 116, 116, 184, 022, 123, 295, 022, 185, 116, 116, 116, 184, 022, 185, 116, 116, 184, 022, 146 }, { 147, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 146 }, { 147, 022, 119, 158, 158, 118, 022, 119, 118, 022, 119, 158, 158, 158, 158, 158, 158, 118, 022, 119, 118, 022, 119, 158, 158, 118, 022, 146 }, { 147, 022, 185, 116, 116, 184, 022, 121, 120, 022, 185, 116, 116, 179, 178, 116, 116, 184, 022, 121, 120, 022, 185, 116, 116, 184, 022, 146 }, { 147, 022, 022, 022, 022, 022, 022, 121, 120, 022, 022, 022, 022, 121, 120, 022, 022, 022, 022, 121, 120, 022, 022, 022, 022, 022, 022, 146 }, { 149, 156, 156, 156, 156, 118, 022, 121, 180, 158, 158, 118, 022, 121, 120, 022, 119, 158, 158, 181, 120, 022, 119, 156, 156, 156, 156, 148 }, { 023, 023, 023, 023, 023, 147, 022, 121, 178, 116, 116, 184, 022, 185, 184, 022, 185, 116, 116, 179, 120, 022, 146, 023, 023, 023, 023, 023 }, { 023, 023, 023, 023, 023, 147, 022, 121, 120, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 121, 120, 022, 146, 023, 023, 023, 023, 023 }, { 023, 023, 023, 023, 023, 147, 022, 121, 120, 022, 125, 156, 177, 023, 023, 176, 156, 124, 022, 121, 120, 022, 146, 023, 023, 023, 023, 023 }, { 155, 155, 155, 155, 155, 184, 022, 185, 184, 022, 146, 022, 022, 022, 022, 022, 022, 147, 022, 185, 184, 022, 185, 155, 155, 155, 155, 155 }, { 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 146, 022, 022, 022, 022, 022, 022, 147, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022 }, { 156, 156, 156, 156, 156, 118, 022, 119, 118, 022, 146, 022, 022, 022, 022, 022, 022, 147, 022, 119, 118, 022, 119, 156, 156, 156, 156, 156 }, { 023, 023, 023, 023, 023, 147, 022, 121, 120, 022, 127, 155, 155, 155, 155, 155, 155, 126, 022, 121, 120, 022, 146, 023, 023, 023, 023, 023 }, { 023, 023, 023, 023, 023, 147, 022, 121, 120, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 121, 120, 022, 146, 023, 023, 023, 023, 023 }, { 023, 023, 023, 023, 023, 147, 022, 121, 120, 022, 119, 158, 158, 158, 158, 158, 158, 118, 022, 121, 120, 022, 146, 023, 023, 023, 023, 023 }, { 145, 155, 155, 155, 155, 184, 022, 185, 184, 022, 185, 116, 116, 179, 178, 116, 116, 184, 022, 185, 184, 022, 185, 155, 155, 155, 155, 144 }, { 147, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 121, 120, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 146 }, { 147, 022, 119, 158, 158, 118, 022, 119, 158, 158, 158, 118, 022, 121, 120, 022, 119, 158, 158, 158, 118, 022, 119, 158, 158, 118, 022, 146 }, { 147, 022, 185, 116, 179, 120, 022, 185, 116, 116, 116, 184, 022, 185, 184, 022, 185, 116, 116, 116, 184, 022, 121, 178, 116, 184, 022, 146 }, { 147, 022, 022, 022, 121, 120, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 121, 120, 022, 022, 022, 146 }, { 151, 158, 118, 022, 121, 120, 022, 119, 118, 022, 119, 158, 158, 158, 158, 158, 158, 118, 022, 119, 118, 022, 121, 120, 022, 119, 158, 150 }, { 153, 116, 184, 022, 185, 184, 022, 121, 120, 022, 185, 116, 116, 179, 178, 116, 116, 184, 022, 121, 120, 022, 185, 184, 022, 185, 116, 152 }, { 147, 022, 022, 022, 022, 022, 022, 121, 120, 022, 022, 022, 022, 121, 120, 022, 022, 022, 022, 121, 120, 022, 022, 022, 022, 022, 022, 146 }, { 147, 022, 119, 158, 158, 158, 158, 181, 180, 158, 158, 118, 022, 121, 120, 022, 119, 158, 158, 181, 180, 158, 158, 158, 158, 118, 022, 146 }, { 147, 022, 185, 116, 116, 116, 116, 116, 116, 116, 116, 184, 022, 185, 184, 022, 185, 116, 116, 116, 116, 116, 116, 116, 116, 184, 022, 146 }, { 147, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 022, 146 }, { 149, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 148 }, { 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023 }, { 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023, 023 }, }; //Creating board background image //Створення фонового малюнку ігрового поля using (Graphics g = Graphics.FromImage(map)) { //Draw walls. Малювання стін for (int i = 0; i < size.Width; i++) { for (int j = 0; j < size.Height; j++) { Bitmap chunk = PacForm.CutSprite(board[j, i], PacForm.BoardTileSize, PacForm.BoardTileSize * PacForm.SpriteScale); g.DrawImage(chunk, i * PacForm.BoardTileSize * PacForm.SpriteScale, j * PacForm.BoardTileSize * PacForm.SpriteScale); } } //Draw ghost house door. Малювання дверей до будинку привидів using (Brush brush = new SolidBrush(Color.FromArgb(255, 255, 181, 255))) { g.FillRectangle(brush, 156 * PacForm.SpriteScale, 188 * PacForm.SpriteScale, 24 * PacForm.SpriteScale, 2 * PacForm.SpriteScale); } } boardPB.Name = "Map"; boardPB.SizeMode = PictureBoxSizeMode.Normal; boardPB.Location = new Point(3, 32); boardPB.Size = boardPBSize; //boardPB.Image = map; mapChanged = AdjustColor(); boardPB.BackgroundImage = map; boardPB.BackColor = Color.Black; form.Controls.Add(boardPB); }