鱼C论坛

 找回密码
 立即注册
查看: 2288|回复: 0

[争议讨论] 点灯游戏

[复制链接]
发表于 2015-2-12 13:24:00 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    Panel4: TPanel;
    Panel5: TPanel;
    Panel6: TPanel;
    Panel7: TPanel;
    Panel8: TPanel;
    Panel9: TPanel;
    Panel10: TPanel;
    Panel11: TPanel;
    Panel12: TPanel;
    Panel13: TPanel;
    Panel14: TPanel;
    Panel15: TPanel;
    Panel16: TPanel;
    Panel17: TPanel;
    Panel18: TPanel;
    Panel19: TPanel;
    Panel20: TPanel;
    Panel21: TPanel;
    Panel22: TPanel;
    Panel23: TPanel;
    Panel24: TPanel;
    Panel25: TPanel;
    procedure FormCreate(Sender: TObject);
    procedure Change(i:Integer);
    function CheckWin:Boolean;
    procedure Panel1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
    Form1: TForm1;
    p:Array[1..25] of TPanel;
    c:Array[1..25] of Boolean;
implementation
function TForm1.CheckWin:Boolean;
var
    i:Integer;
begin
    result:=True;
    for i:=1 to 25 do
        if not c[i] then
        begin
            Result:=False;
            exit;
        end;
end;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
    i:Integer;
begin
    p[1]:=Panel1;
    p[2]:=Panel2;
    p[3]:=Panel3;
    p[4]:=Panel4;
    p[5]:=Panel5;
    p[6]:=Panel6;
    p[7]:=Panel7;
    p[8]:=Panel8;
    p[9]:=Panel9;
    p[10]:=Panel10;
    p[11]:=Panel11;
    p[12]:=Panel12;
    p[13]:=Panel13;
    p[14]:=Panel14;
    p[15]:=Panel15;
    p[16]:=Panel16;
    p[17]:=Panel17;
    p[18]:=Panel18;
    p[19]:=Panel19;
    p[20]:=Panel20;
    p[21]:=Panel21;
    p[22]:=Panel22;
    p[23]:=Panel23;
    p[24]:=Panel24;
    p[25]:=Panel25;
    for i:=1 to 25 do
    begin
        p[i].Tag:=i;
        c[i]:=False;
    end;
end;

procedure TForm1.Change(i:Integer);
begin
    c[i]:=Not c[i];
    if c[i] then
        p[i].Color:=clBlack
    else
        p[i].Color:=clWhite;
end;



procedure TForm1.Panel1Click(Sender: TObject);
var
    i,j:Integer;
begin
    i:=TPanel(Sender).Tag;
    Change(i);
    if i>5 then Change(i-5);
    if i<21 then Change(i+5);
    if (i Mod 5)<>0 then Change(i+1);
    if (i Mod 5)<>1 then Change(i-1);
    if CheckWin then ShowMessage('<span style="font-family: 宋体; ">你赢了!</span>');
点灯游戏.png
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-11-22 18:44

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表