//---------------------------------------------------------------- //Method to handle when a coin object is hit //---------------------------------------------------------------- public static void HitCoin(int X, int Y, bool ThrowUp) { int MapX, MapY; MapX = X / Buffers.W; MapY = Y / Buffers.H; if (Buffers.WorldMap[MapX, MapY] == ' ') { return; } if (ThrowUp) { NewTempObj(tpCoin, X, Y - Buffers.H, 0, CoinSpeed, Buffers.W, Buffers.H); } else { Buffers.WorldMap[MapX, MapY] = ' '; Remove(X, Y, Buffers.W, Buffers.H, 0); Glitter.CoinGlitter(X, Y); } Buffers.data.coins[Buffers.Player]++; Buffers.AddScore(50); if (Buffers.data.coins[Buffers.Player] % 100 == 0) { AddLife(); Buffers.data.coins[Buffers.Player] = 0; } }
//------------------------------------------------- // Check the player for actions //------------------------------------------------- private static void Check() { bool Small; NewCh1 = ' '; NewCh2 = ' '; NewCh3 = ' '; Side = System.Convert.ToByte(XVel > 0) * (Buffers.W - 1); NewX1 = (X + Side) / Buffers.W; NewX2 = (X + Side + XVel) / Buffers.W; Small = Buffers.data.mode[Buffers.Player] == Buffers.mdSmall; if (NewX1 != NewX2) { Y1 = (Y + HSafe + (4)) / Buffers.H - Safe; Y2 = (Y + HSafe + Buffers.H) / Buffers.H - Safe; Y3 = (Y + HSafe + 2 * Buffers.H - 1) / Buffers.H - Safe; // Hack to fix negative Y Y1 = Y1 < 0 ? 1 : Y1; Y2 = Y2 < 0 ? 1 : Y2; Y3 = Y3 < 0 ? 1 : Y3; NewCh1 = (char)Buffers.WorldMap[NewX2, Y1]; NewCh2 = (char)Buffers.WorldMap[NewX2, Y2]; NewCh3 = (char)Buffers.WorldMap[NewX2, Y3]; if (NewCh3 == '*') { TmpObj.HitCoin(NewX2 * Buffers.W, Y3 * Buffers.H, false); } if (NewCh2 == '*') { TmpObj.HitCoin(NewX2 * Buffers.W, Y2 * Buffers.H, false); } else if (NewCh2 == 'z') { Enemies.Turbo = true; } if (!Small && NewCh1 == '*') { TmpObj.HitCoin(NewX2 * Buffers.W, Y1 * Buffers.H, false); } Hold1 = (Buffers.CanHoldYou(NewCh1)) && (!Small); Hold2 = (Buffers.CanHoldYou(NewCh2)); Hold3 = (Buffers.CanHoldYou(NewCh3)); if (Hold1 || Hold2 || Hold3) { XVel = 0; Walkingmode = 0; } } NewX1 = (X + XVel) / Buffers.W; NewX2 = (X + XVel + Buffers.W - 1) / Buffers.W; if (Enemies.cdEnemy != 0) { CheckJump(); } if ((Status == stJumping)) { NewY = (Y + 1 + (4) + (Buffers.H - 1 - (4)) * Convert.ToByte(Small) + YVel + HSafe) / Buffers.H - Safe; } else { NewY = (Y + 1 + 2 * Buffers.H + YVel + HSafe) / Buffers.H - Safe; } if (NewY < 0) { NewY = 12; Y = 12; } NewCh1 = (char)Buffers.WorldMap[NewX1, NewY]; NewCh2 = (char)Buffers.WorldMap[NewX2, NewY]; NewCh3 = (char)Buffers.WorldMap[(X + XVel + Buffers.W / 2) / Buffers.W, NewY]; Hold1 = (Buffers.CanHoldYou(NewCh1) || Buffers.CanStandOn(NewCh1)); Hold2 = (Buffers.CanHoldYou(NewCh2) || Buffers.CanStandOn(NewCh2)); Hold3 = (Buffers.CanHoldYou(NewCh3) || Buffers.CanStandOn(NewCh3)); switch (Status) { case stFalling: { CheckFall(); break; } case stOnTheGround: { if ((Enemies.cdLift == 0)) { if (!(Hold1 || Hold2)) { Status = stFalling; if (Math.Abs(XVel) < 2) { Y++; } } else { if ((NewCh1 == 'K') || (NewCh2 == 'K')) { CheckFall(); } else { if (XVel == 0) { Below1 = NewCh1; Below2 = NewCh2; MapX = NewX1; //Codes for pipes MapY = NewY - 1; AtCh1 = (char)Buffers.WorldMap[MapX, MapY]; AtCh2 = (char)Buffers.WorldMap[MapX + 1, MapY]; Mo = (X + XVel) % Buffers.W; if (!Hold1 && (Mo >= 1 && Mo <= 5)) { XVel--; } if (!Hold2 && (Mo >= Buffers.W - 5 && Mo <= Buffers.W - 1)) { XVel++; } } } CheckJump(); } } else { YVel = Enemies.PlayerYVel; CheckJump(); } break; } case stJumping: { Hold1 = (Buffers.CanHoldYou(NewCh1) || Buffers.CanStandOn(NewCh1)); Hold2 = (Buffers.CanHoldYou(NewCh2) || Buffers.CanStandOn(NewCh2)); Hold3 = (Buffers.CanHoldYou(NewCh3) || Buffers.CanStandOn(NewCh3)); Hit = (Hold1 || Hold2); if (Hit) { Mo = (X + XVel) % Buffers.W; if ((Mo >= 1 && Mo <= 4 && Mo >= Buffers.W - 4 && Mo <= Buffers.W - 1) && (!Hold3)) { if (!((NewCh1 == Buffers.Hidden) && (NewCh2 == Buffers.Hidden))) { Hit = false; } if ((Mo < Buffers.W / 2) && (!(NewCh2 == Buffers.Hidden))) { X -= Mo; } else if ((Mo >= Buffers.W / 2) && (!(NewCh1 == Buffers.Hidden))) { X += Buffers.W - Mo; } } } if (!Hit) { if (NewCh1 == '*') { TmpObj.HitCoin(NewX1 * Buffers.W, NewY * Buffers.H, false); } if (NewCh1 == '*') { TmpObj.HitCoin(NewX2 * Buffers.W, NewY * Buffers.H, false); } if ((Counter % (JumpDelay + Convert.ToByte(HighJump)) == 0) || ((!keyAlt) && (!HitEnemy))) { YVel++; } if (YVel >= 0) { YVel = 0; Status = stFalling; } } else { char Ch = (char)0; if (Mo >= 0 && Mo <= (Buffers.W / 2 - 1)) { if (Buffers.CanHoldYou(NewCh1) || Buffers.CanStandOn(NewCh1)) { Ch = NewCh1; NewX2 = NewX1; } else { Ch = NewCh2; } } else if (Mo >= (Buffers.W / 2) && Mo <= Buffers.W - 1) { Ch = NewCh2; if (!(Buffers.CanHoldYou(Ch) || Ch == Buffers.Hidden)) { Ch = NewCh1; NewX2 = NewX1; } } switch (Ch) { case '=': Enemies.cdHit = 1; break; case '0': case '1': if (keyUp) { CheckPipeAbove(NewCh1, NewCh2); } break; case '?': case '$': case 'J': case 'K': { Mo = 0; if (Buffers.WorldMap[NewX2, NewY - 1] >= 'à' && Buffers.WorldMap[NewX2, NewY - 1] <= 'â') { Buffers.WorldMap[NewX2, NewY] = '?'; Ch = '?'; } else if (Buffers.WorldMap[NewX2, NewY - 1] == 'ï') { Buffers.WorldMap[NewX2, NewY] = 'K'; Ch = 'K'; } else { if (!Small && (Ch == 'J')) { TmpObj.BreakBlock(NewX2, NewY); Buffers.AddScore(10); Mo = 1; } } if (Mo == 0) { Blocks.BumpBlock(NewX2 * Buffers.W, NewY * Buffers.H); //Beep (110 ); } if (Buffers.WorldMap[NewX2, NewY - 1] >= 'ã' && Buffers.WorldMap[NewX2, NewY - 1] <= 'ì') { if (!(Ch == 'J' || Ch == 'K')) { TmpObj.HitCoin(NewX2 * Buffers.W, NewY * Buffers.H, true); if (Buffers.WorldMap[NewX2, NewY - 1] != ' ') { Buffers.WorldMap[NewX2, NewY - 1] = (char)(Buffers.WorldMap[NewX2, NewY - 1] + 1); if (Buffers.WorldMap[NewX2, NewY] == '$') { TmpObj.Remove(NewX2 * Buffers.W, NewY * Buffers.H, Buffers.W, Buffers.H, 2); Buffers.WorldMap[NewX2, NewY] = '?'; } } } } else if (Buffers.WorldMap[NewX2, NewY - 1] == 'à') { if (Buffers.data.mode[Buffers.Player] == Buffers.mdSmall) { Enemies.NewEnemy(EnemyType.tpRisingChamp, 0, NewX2, NewY, 0, -1, 2); } else { Enemies.NewEnemy(EnemyType.tpRisingFlower, 0, NewX2, NewY, 0, -1, 2); } } else if (Buffers.WorldMap[NewX2, NewY - 1] == 'á') { Enemies.NewEnemy(EnemyType.tpRisingLife, 0, NewX2, NewY, 0, -1, 2); } else if (Buffers.WorldMap[NewX2, NewY - 1] == 'â') { Enemies.NewEnemy(EnemyType.tpRisingStar, 0, NewX2, NewY, 0, -1, 1); } else if (Buffers.WorldMap[NewX2, NewY - 1] == '*') { TmpObj.HitCoin(NewX2 * Buffers.W, (NewY - 1) * Buffers.H, false); } else if (Buffers.WorldMap[NewX2, NewY - 1] == 'í') { Enemies.NewEnemy(EnemyType.tpRisingChamp, 1, NewX2, NewY, 0, -1, 2); } Enemies.HitAbove(NewX2, NewY - 1); if (Ch == 'K') { TmpObj.Remove(NewX2 * Buffers.W, NewY * Buffers.H, Buffers.W, Buffers.H, TmpObj.tpNote); Buffers.WorldMap[NewX2, NewY] = 'K'; } else { if (Ch != 'J') { if (!(Buffers.WorldMap[NewX2, NewY - 1] >= 'ã' && Buffers.WorldMap[NewX2, NewY - 1] <= 'ì')) { TmpObj.Remove(NewX2 * Buffers.W, NewY * Buffers.H, Buffers.W, Buffers.H, 1); Buffers.WorldMap[NewX2, NewY] = '@'; } } } break; } default: //Beep (30); break; } if ((Ch != 'J') || (Buffers.data.mode[Buffers.Player] == Buffers.mdSmall)) { YVel = 0; Status = stFalling; } if (Ch == 'K') { YVel = 3; } } break; } } }