//---------------------------------------------------- // Redraw the image described by WorldMap[X, Y] //---------------------------------------------------- public static void Redraw(int X, int Y) { char Ch; Bitmap Fig = null; bool L, R, LS, RS; int XPos, YPos; XPos = X * Buffers.W; YPos = Y * Buffers.H; if (X < 0) { return; } Ch = (char)Buffers.WorldMap[X, Y]; if (X >= 0 && Y >= 0 && Y < Buffers.NV * 2) { if (Ch != (char)0) { if (Ch == '%' && Buffers.Options.Design == 4) { DrawSky(XPos, YPos, Buffers.W, Buffers.H / 2); } else { DrawSky(XPos, YPos, Buffers.W, Buffers.H); } } if (Ch == ' ') { return; } if (Buffers.WorldMap[X, Y] == (char)18) { Fig = FigList[1, 5]; FormMarioPort.formRef.PutImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } switch (Ch) { case (char)1: case (char)2: case (char)3: case (char)4: case (char)5: case (char)6: case (char)7: case (char)8: case (char)9: case (char)10: case (char)11: case (char)12: case (char)13: case (char)14: case (char)15: case (char)16: case (char)17: case (char)18: case (char)19: case (char)20: case (char)21: case (char)22: case (char)23: case (char)24: case (char)25: case (char)26: { if (Ch > (char)13) { Ch -= (char)13; } else { if (Buffers.WorldMap[X, Y + 8] >= 65 && Buffers.WorldMap[X, Y + 8] <= 77) { if (Ch == (char)1 || Ch == (char)4 || Ch == (char)7) { Fig = FigList[1, (int)(Buffers.WorldMap[X, Y + 8]) - 64]; FormMarioPort.formRef.PutImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } } else { if (Buffers.WorldMap[X + 2, Y + 8] >= 65 && Buffers.WorldMap[X + 2, Y + 8] <= 77) { if (Ch == (char)3 || Ch == (char)6 || Ch == (char)9) { Fig = FigList[1, (int)(Buffers.WorldMap[X + 2, Y + 8]) - 64]; FormMarioPort.formRef.PutImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } } } } Fig = FigList [1, (int)Ch]; if (!(Ch == (char)1 || Ch == (char)3 || Ch == (char)4 || Ch == (char)6 || Ch == (char)7 || Ch == (char)9)) { FormMarioPort.formRef.PutImage(XPos, YPos, Buffers.W, Buffers.H, Fig); Fig = null; } break; } case '?': Fig = Resources.QUEST_000; break; case '@': Fig = Resources.QUEST_001; break; case 'A': { L = true; Buffers.WorldMap[X, Y] = 'A'; R = true; Buffers.WorldMap[X + 1, Y] = 'A'; if ((X + Y) % 2 == 1) { RS = true; LS = false; } else { LS = true; RS = false; } if (LS && R) { Fig = Bricks[1]; } else { if (RS && L) { Fig = Bricks[2]; } else { Fig = Bricks[0]; } } break; } case 'I': Fig = Resources.BLOCK_000; break; case 'J': Fig = Resources.BLOCK_001; break; case 'K': Fig = Resources.NOTE_000; break; case 'X': Fig = Resources.XBLOCK_000; break; case 'W': Fig = Resources.WOOD_000; break; case '=': { Fig = Resources.PIN_000; if (Buffers.CanHoldYou((char)Buffers.WorldMap[X, Y + 1])) { FormMarioPort.formRef.DrawImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } else { FormMarioPort.formRef.UpSideDown(XPos, YPos, Buffers.W, Buffers.H, Fig); } // Fig = null; break; } case '0': Fig = Resources.PIPE_000; break; case '1': Fig = Resources.PIPE_001; break; case '2': Fig = Resources.PIPE_002; break; case '3': Fig = Resources.PIPE_003; break; case '*': Fig = Resources.COIN_000; break; case 'þ': { if (Buffers.WorldMap[X, Y - 1] == 'þ') { Fig = Resources.EXIT_001; } else { Fig = Resources.EXIT_000; } break; } case '÷': { if ((Buffers.WorldMap[X, Y - 1] == 'ð') && (Buffers.Options.Design == 2)) { Fig = Resources.SMTREE_001; FormMarioPort.formRef.DrawImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } if (Buffers.WorldMap[X, Y - 1] == 'ö') { if (Buffers.Options.Design == 1) { Fig = Resources.WPALM_000; FormMarioPort.formRef.DrawImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } } if ((X == 0) || (Buffers.WorldMap[X - 1, Y] == Ch)) { if (Buffers.WorldMap[X + 1, Y] == (byte)Ch) { Fig = Resources.GRASS2_000; } else { Fig = Resources.GRASS3_000; } } else { if (Buffers.WorldMap[X + 1, Y] == Ch) { Fig = Resources.GRASS1_000; } else { Fig = Resources.GRASS3_000; } } break; } case 'ð': { switch (Buffers.Options.Design) { case 1: { if (Buffers.WorldMap[X, Y - 1] != Ch) { Fig = Resources.FENCE_001; } else { Fig = Resources.FENCE_000; } break; } case 2: { if (Buffers.WorldMap[X, Y - 1] != Ch) { Fig = Resources.SMTREE_000; } else { Fig = Resources.SMTREE_001; } break; } } break; } case 'ö': { switch (Buffers.Options.Design) { case 1: Fig = Resources.WPALM_000; break; } break; } case 'ú': { switch (Buffers.Options.Design) { case 1: { if (Buffers.WorldMap[X - 1, Y] == 'ù') { Fig = Resources.PALM3_000; FormMarioPort.formRef.DrawImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } else { if (Buffers.WorldMap[X + 1, Y] == 'ù') { Fig = Resources.PALM1_000; FormMarioPort.formRef.DrawImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } } Fig = Resources.PALM0_000; break; } } break; } case 'ô': { switch (Buffers.Options.Design) { case 1: { if (Buffers.WorldMap[X, Y + 1] == 'ö') { Fig = Resources.WPALM_000; FormMarioPort.formRef.DrawImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } Fig = Resources.PALM1_000; break; } } break; } case 'ù': { switch (Buffers.Options.Design) { case 1: Fig = Resources.PALM2_000; break; } break; } case 'õ': { switch (Buffers.Options.Design) { case 1: { if (Buffers.WorldMap[X, Y + 1] == 'ö') { Fig = Resources.WPALM_000; FormMarioPort.formRef.DrawImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } Fig = Resources.PALM3_000; break; } } break; } case '#': { switch (Buffers.Options.Design) { case 1: Fig = Resources.FALL_000; break; case 2: { switch ((char)Buffers.WorldMap[X, Y - 1]) { case '#': FormMarioPort.formRef.PutImage(XPos, YPos, Buffers.W, Buffers.H, Resources.TREE_001); break; case '%': { Fig = Resources.TREE_000; FormMarioPort.formRef.PutImage(XPos, YPos, Buffers.W, Buffers.H, Fig); Fig = Resources.TREE_003; break; } default: Fig = Resources.TREE_003; break; } break; } case 3: Fig = Resources.WINDOW_001; break; case 4: Fig = Resources.LAVA_000; break; case 5: FormMarioPort.formRef.Fill(XPos, YPos, Buffers.W, Buffers.H, 5); break; } break; } case '%': { switch (Buffers.Options.Design) { case 1: Fig = Resources.FALL_001; break; case 2: { switch ((char)Buffers.WorldMap[X, Y - 1]) { case '%': FormMarioPort.formRef.PutImage(XPos, YPos, Buffers.W, Buffers.H, Resources.TREE_000); break; case '#': { Fig = Resources.TREE_001; FormMarioPort.formRef.PutImage(XPos, YPos, Buffers.W, Buffers.H, Fig); Fig = Resources.TREE_002; break; } default: Fig = Resources.TREE_002; break; } break; } case 3: Fig = Resources.WINDOW_000; break; case 4: Fig = Resources.LAVA_001; break; case 5: { switch ((X + Buffers.LavaCounter / 8) % 5) { case 0: Fig = Resources.LAVA2_001; break; case 1: Fig = Resources.LAVA2_002; break; case 2: Fig = Resources.LAVA2_003; break; case 3: Fig = Resources.LAVA2_004; break; case 4: Fig = Resources.LAVA2_005; break; } break; } break; } break; } } if (Fig != null) { FormMarioPort.formRef.DrawImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } } }
//------------------------------------------------- // 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; } } }