掃雷 C 窗體

2021-05-25 20:53:06 字數 2402 閱讀 7166

using

system;

using

system.collections.generic;

using

system.text;

using

system.drawing;

using

system.windows;

using

system.windows.forms;

namespace

winmine

public

static

void init()

static

void openunit(blockdata bd)

bd.state = blockstate.open;

blockgraphics.drawblock(bd);

blockopen++;

if (bd.minecount == 0)

} }

}

public

static

void showall()

}}

public

static

void drawblocks()

else

else

if (bd.ismine)

else

}}

}

public

static

bool issuccessful()

}if (i < map.blockdatalist.count)

else

}else

}public

static

void singleclick(int x, int y)

if (bd != null && bd.ismine)

else

if (issuccessful())

} public

static

blockdata getblock(int x, int y)

int index = (y / map.blockwidth) * map.columncount + (x / map.blockwidth) % map.columncount;

if (index < blockdatalist.count)

else

} public

static

int getblockindex(int x, int y)

int index = (y / map.blockwidth) * map.columncount + (x / map.blockwidth) % map.columncount;

if (index < blockdatalist.count)

else

}}

public

enum

blockstate

public

class

blockgraphics

public

static

void drawblock(int x, int y, bitmap b)

} public

static

void drawblock(blockdata bd)

case

blockstate.open:

case

blockstate.usermine:

} drawblock(bd.x, bd.y, b);

if (bd.state == blockstate.open && bd.minecount != 0)

case 2:

case 3:

case 4:

case 5:

case 6:

case 7:

case 8:

}

g.drawstring(bd.minecount.tostring(), drawfont, drawbrush, bd.x, bd.y, drawformat);

gg.drawstring(bd.minecount.tostring(), drawfont, drawbrush, bd.x, bd.y, drawformat);

} }

public blockgraphics()

} public

class

blockdata

public blockdata(int x, int y)

} }

C語言 掃雷

做乙個掃雷的遊戲,首先分析一下掃雷需要實現的功能 1.選擇乙個位置,如果該位置是雷則結束遊戲,並顯示所有雷的位置。如果不是雷則顯示該位置周圍雷的數量。2.如果周圍沒有雷,則該位置顯示空,並且周圍如果也為空則一併展開。3.第一次選擇時必定不是雷 4.當盤上剩餘的位置只有雷了,則遊戲也結束,並且玩家勝利...

C語言掃雷

大家想必都玩過掃雷,無論那個版本都有難度供已選擇,下面來分享乙個自己用c語言編寫的掃雷遊戲吧!編寫語言 c語言 編寫軟體 visual studio 2017 1.首先是將遊戲的測試模組寫好,要有提示玩家進入的選單函式以及選擇函式等各種需要編寫的函式想出乙個整體框架來 測試模組test。c incl...

掃雷(C語言)

1 第一次下子,不炸死。2 座標周圍沒雷,可以實現展開。標頭檔案 mine.h ifndef mine h define mine h include include include include define row 12 define col 12 define mine 20 void me...