Ejemplo n.º 1
0
        public override void dichuyen()
        {
            GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
            GIAOTHUC.gotoxy(m / 2, n + 20); /*toa do xuat ra DIEM*/
            Console.Write("DIEM:{0} ", diem);
            GIAOTHUC.gotoxy(x, y + 16);     //dua con tro console ve vi tri con tro * tren man hinh
            do
            {
                a = GIAOTHUC.getch();
                if (a == 32)
                {
                    if (notemty())
                    {
                        continue;
                    }
                    if (BANDO.kt(x, y) == -1)
                    {
                        endgame(0); win(); break;
                    }                                                      //khi sai thao tac
                    s[x, y] = (char)BANDO.kt(x, y); luamau(); Console.Write("{0}", s[x, y]);
                    GIAOTHUC.textcolor(ConsoleColor.White); GIAOTHUC.gotoxy(x, y + 16);
                }

                if (a == 13)//enter
                {
                    if (notemty())
                    {
                        continue;
                    }
                    if (BANDO.kt(x, y) != -1)
                    {
                        endgame(0); win(); break;
                    }                                                       //khi sai thao tac
                    diem = diem + 100; s[x, y] = c; dem--;
                    luamau(); Console.Write("{0}", s[x, y]);
                    GIAOTHUC.textcolor(ConsoleColor.White);
                    GIAOTHUC.gotoxy(m / 2, n + 20); /*toa do xuat ra DIEM*/
                    Console.Write("DIEM:{0} ", diem);
                    GIAOTHUC.gotoxy(x, y + 16);     //dua con tro console ve vi tri con tro * tren man hinh
                    if (dem == 0)
                    {
                        endgame(1); win(); break;
                    }
                }

                if (a == 'w' || a == 'W')
                {
                    luamau(); Console.Write("{0}", s[x, y]); GIAOTHUC.textcolor(ConsoleColor.White);
                    if (x == 1)
                    {
                        x = m - 2;
                    }
                    else
                    {
                        x = x - 2;
                    } GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
                    GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
                    Console.WriteLine("\t\t                     ");
                    GIAOTHUC.gotoxy(x, y + 16);
                }

                if (a == 'a' || a == 'A')
                {
                    luamau(); Console.Write("{0}", s[x, y]); GIAOTHUC.textcolor(ConsoleColor.White);
                    if (y == 1)
                    {
                        y = n - 2;
                    }
                    else
                    {
                        y = y - 2;
                    } GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
                    GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
                    Console.WriteLine("\t\t                     "); GIAOTHUC.gotoxy(x, y + 16);
                }

                if (a == 's' || a == 'S')
                {
                    luamau(); Console.Write("{0}", s[x, y]); GIAOTHUC.textcolor(ConsoleColor.White);
                    if (x == m - 2)
                    {
                        x = 1;
                    }
                    else
                    {
                        x = x + 2;
                    } GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
                    GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
                    Console.WriteLine("\t\t                     "); GIAOTHUC.gotoxy(x, y + 16);
                }

                if (a == 'd' || a == 'D')
                {
                    luamau(); Console.Write("{0}", s[x, y]); GIAOTHUC.textcolor(ConsoleColor.White);
                    if (y == n - 2)
                    {
                        y = 1;
                    }
                    else
                    {
                        y = y + 2;
                    } GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
                    GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
                    Console.WriteLine("\t\t                     "); GIAOTHUC.gotoxy(x, y + 16);
                }
            } while (a != 27);
        }
Ejemplo n.º 2
0
        virtual public void dichuyen()
        {
            GIAOTHUC.gotoxy(x, y + 16); Console.Write("*"); GIAOTHUC.gotoxy(x, y + 16);

            do
            {
                a = GIAOTHUC.getch();
                if (a == 32)//khoang trang
                {
                    if (notemty())
                    {
                        continue;
                    }
                    if (BANDO.kt(x, y) == -1)
                    {
                        endgame(0); win(); break;
                    }                                                      //khi sai thao tac
                    s[x, y] = (char)BANDO.kt(x, y); luamau(); Console.Write("{0}", s[x, y]);
                    GIAOTHUC.textcolor(ConsoleColor.White); GIAOTHUC.gotoxy(x, y + 16);
                }

                if (a == 13)//enter
                {
                    if (notemty())
                    {
                        continue;
                    }
                    if (BANDO.kt(x, y) != -1)
                    {
                        endgame(0); win(); break;
                    }                                                      //khi sai thao tac
                    s[x, y] = c; luamau(); Console.Write("{0}", s[x, y]); dem--;
                    GIAOTHUC.textcolor(ConsoleColor.White);
                    GIAOTHUC.gotoxy(x, y + 16);
                    if (dem == 0)
                    {
                        endgame(1); win(); break;
                    }
                }

                if (a == 'w' || a == 'W')
                {
                    luamau(); Console.Write("{0}", s[x, y]); GIAOTHUC.textcolor(ConsoleColor.White);
                    if (x == 1)
                    {
                        x = m - 2;
                    }
                    else
                    {
                        x = x - 2;
                    } GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
                    GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
                    Console.WriteLine("\t\t                     ");
                    GIAOTHUC.gotoxy(x, y + 16);
                }

                if (a == 'a' || a == 'A')
                {
                    luamau(); Console.Write("{0}", s[x, y]); GIAOTHUC.textcolor(ConsoleColor.White);
                    if (y == 1)
                    {
                        y = n - 2;
                    }
                    else
                    {
                        y = y - 2;
                    } GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
                    GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
                    Console.WriteLine("\t\t                     "); GIAOTHUC.gotoxy(x, y + 16);
                }

                if (a == 's' || a == 'S')
                {
                    luamau(); Console.Write("{0}", s[x, y]); GIAOTHUC.textcolor(ConsoleColor.White);
                    if (x == m - 2)
                    {
                        x = 1;
                    }
                    else
                    {
                        x = x + 2;
                    } GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
                    GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
                    Console.WriteLine("\t\t                     "); GIAOTHUC.gotoxy(x, y + 16);
                }

                if (a == 'd' || a == 'D')
                {
                    luamau(); Console.Write("{0}", s[x, y]); GIAOTHUC.textcolor(ConsoleColor.White);
                    if (y == n - 2)
                    {
                        y = 1;
                    }
                    else
                    {
                        y = y + 2;
                    } GIAOTHUC.gotoxy(x, y + 16); Console.Write("*");
                    GIAOTHUC.gotoxy(m + 2, n / 2 + 16);
                    Console.WriteLine("\t\t                     "); GIAOTHUC.gotoxy(x, y + 16);
                }
            } while (a != 27);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            int x = 2; char chon;

            OPEN.gioithieu();
            BANDO    map;
            GAMEPLAY game;

            do
            {
                Console.Clear();
                Console.Write("\t\t\t     MENU");
                Console.Write("\n\n\t\t\tChe do Classic");
                Console.Write("\n\t\t\tChe do Survivor");
                Console.Write("\n\t\t\tLuyen tap");
                Console.Write("\n\t\t\tHuong dan");
                Console.Write("\n\t\t\tBang xep hang");
                Console.Write("\n\t\t\tThoat");
                Console.Write("\n\nBam W,S,Enter de thuc hien su lua chon");
                GIAOTHUC.gotoxy(x, 22);
                Console.Write("→");
                DSCD1 ds1 = new DSCD1();
                DSCD2 ds2 = new DSCD2();
                chon = GIAOTHUC.getch();
                if (chon == 'w' || chon == 'W')
                {
                    if (x > 2)
                    {
                        x--;
                    }
                }
                if (chon == 's' || chon == 'S')
                {
                    if (x < 7)
                    {
                        x++;
                    }
                }
                if (chon == 13) //enter
                {
                    if (x == 2) //Classic
                    {
                        int m = 3, n = 3, r;
                        game = new CLASSIC();
                        do
                        {
                            r    = (m * n) / 3 - 2;
                            map  = new BANDO(m, n, r);
                            game = new CLASSIC(CLASSIC.Diem);
                            map.taobando();
                            game.vekhung(); game.xuatkhung(); //map.xuat();
                            game.dichuyen();
                            if (game.win() == false)          //khi thua
                            {
                                ds1.docfile(); if (ds1.sosanh(CLASSIC.Diem) && CLASSIC.Diem > 0)
                                {
                                    ds1.them();
                                }
                                ds1.sapxep(); ds1.ghifile(); break;
                            }
                            m = m + 1; n = n + 2;
                        } while (game.win() == true);
                    }
                    if (x == 3)//Survive
                    {
                        int m = 3, n = 3, r;
                        game = new SURVIVE();
                        do
                        {
                            r    = (m * n) / 3 - 2;
                            map  = new BANDO(m, n, r);
                            game = new SURVIVE(SURVIVE.Diem);
                            map.taobando();
                            game.vekhung(); game.xuatkhung(); //map.xuat();
                            game.dichuyen();
                            if (game.win() == false)
                            {
                                ds2.docfile(); if (ds2.sosanh(SURVIVE.Level) && SURVIVE.Level > 1)
                                {
                                    ds2.them();
                                }
                                ds2.sapxep(); ds2.ghifile(); break;
                            }
                            m = m + 1; n = n + 2;
                        } while (game.win() == true);
                    }
                    if (x == 4) //Luyen tap
                    {
                        Console.Clear();
                        int a, b, c;
                        Console.Write("Nhap chieu cao:"); a = int.Parse(Console.ReadLine());
                        while (a > 25)
                        {
                            Console.Write("Chieu cao khong the lon hon 25.\nHay nhap lai chieu cao : ");
                            a = int.Parse(Console.ReadLine());
                        }
                        Console.Write("\nNhap chieu dai: "); b = int.Parse(Console.ReadLine());
                        while (b > 25)
                        {
                            Console.Write("Chieu dai khong the lon hon 25\nHay nhap lai chieu dai : ");
                            b = int.Parse(Console.ReadLine());
                        }
                        Console.Write("\nNhap so luong kho bau:"); c = int.Parse(Console.ReadLine());
                        while (c > a * b - (a + b - 1))
                        {
                            Console.Write("So luong kho bau chi co the <={0}.Hay nhap lai sl:", a * b - (a + b - 1));
                            c = int.Parse(Console.ReadLine());
                        }
                        map = new BANDO(a, b, c); map.taobando(); game = new GAMEPLAY(); game.vekhung(); game.xuatkhung(); //map.xuat();
                        game.dichuyen();
                    }
                    if (x == 5)
                    {
                        OPEN.menu();
                    }
                    if (x == 6)
                    {
                        Console.Clear();
                        ds1.docfile(); ds1.sapxep(); ds1.xuat();
                        ds2.docfile(); ds2.sapxep(); ds2.xuat();
                        Console.ReadKey(true);
                    }
                    if (x == 7)
                    {
                        break;
                    }
                }
            } while (chon != 27);
        }