资源简介
我自己从别人那找到的,挺好的,大家可以看看!
代码片段和文件信息
#include “actions.h“
gint count_bomb (gint i gint j)
{
if (i < 0 || j < 0 || i >= MAX_ROW || j >= MAX_COL) {
return 0;
}
//when we run out of range simply return zero
else {
return bomb[i][j];
}
}
gint count_bomb_near (gint i gint j)
{
//i -> row j -> col
gint numrl;
g_assert (bomb[i][j] != M_YES);
num = 0;
for (r = i-1; r <= i+1; r++)
for (l = j-1; l <= j+1; l++)
num += count_bomb (r l);
return num;
}
void draw_unknow (GtkWidget* widget gint i gint j)
{
/*gdk_draw_rectangle (widget->window widget->style->white_gc
FALSE
j*BLOCK_WIDTH i*BLOCK_HEIGHT
BLOCK_WIDTH BLOCK_HEIGHT);
*/
GdkPixmap* unknow;
unknow = gdk_pixmap_create_from_xpm_d (widget->window
NULL NULL (gchar**) c_xpm);
gdk_draw_pixmap (widget->window widget->style->black_gc
unknow
0 0 j*BLOCK_WIDTH i*BLOCK_HEIGHT -1 -1);
gdk_pixmap_unref (unknow);
}
void draw_one (GtkWidget* widget gint i gint j gint num)
{
gint count;
char countstr[10];
if (num == 0) {
count = count_bomb_near (i j);
number[i][j] = count;
//sorry i really do _not_ want to add this matrix
//i will try to clean it
sprintf (countstr “%d“ count);
}
else {
number[i][j] = num;
sprintf (countstr “%d“ num);
}
draw_unknow (widget i j);
gtk_draw_string (widget->style widget->window
GTK_STATE_NORMAL
j*BLOCK_WIDTH+8 i*BLOCK_HEIGHT+12 countstr);
}
void draw_no (GtkWidget* widget gint i gint j)
{
gdk_draw_rectangle (widget->window widget->style->white_gc
TRUE
j*BLOCK_WIDTH i*BLOCK_HEIGHT
BLOCK_WIDTH BLOCK_HEIGHT);
}
void draw_mark (GtkWidget* widget gint i gint j)
{
GdkPixmap* mark;
mark = gdk_pixmap_create_from_xpm_d (widget->window
NULL NULL (gchar**) f_xpm);
gdk_draw_pixmap (widget->window widget->style->black_gc
mark
0 0 j*BLOCK_WIDTH i*BLOCK_HEIGHT
-1 -1);
gdk_pixmap_unref (mark);
}
void draw_discover (GtkWidget* widget gint i gint j)
{
GdkPixmap* discover;
discover = gdk_pixmap_create_from_xpm_d (widget->window
NULL NULL (gchar**) i_xpm);
gdk_draw_pixmap (widget->window widget->style->black_gc
discover
0 0 j*BLOCK_WIDTH i*BLOCK_HEIGHT
-1 -1);
}
void draw_bomb (GtkWidget* widget gint i gint j)
{
GdkPixmap* bomb;
/*gdk_draw_rectangle (widget->window widget->style->white_gc
TRUE
j*BLOCK_WIDTH i*BLOCK_HEIGHT
BLOCK_WIDTH BLOCK_HEIGHT);
*/
bomb = gdk_pixmap_create_from_xpm_d (widget->window
NULL NULL (gchar**) e_xpm);
gdk_draw_pixmap (widget->window widget->style->white_gc
bomb
0 0 j*BLOCK_WIDTH i*BLOCK_HEIGHT
-1 -1);
gdk_pixmap_unref (bomb);
}
void area_expose (GtkWidget* widget GdkEvent* event)
{
gint i j;
for (i=0; i for (j=0; j switch (block[i][j]) {
case B_UNKNOW:
if (LOST == 0 || bomb[i][j] != M_YES)
draw_unknow (widget i j);
else
draw_bomb (widget i j);
break;
case B_ONE:
draw_one (widget i j
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 928 2004-08-25 09:31 bomb\bomb.h
文件 231 2004-08-24 15:41 bomb\bomb.c
文件 387 2004-08-24 15:42 bomb\Makefile
文件 704 2004-08-24 15:40 bomb\interface.h
文件 3867 2004-08-24 15:40 bomb\interface.c
文件 964 2004-08-24 15:40 bomb\actions.h
文件 15972 2004-08-24 15:40 bomb\actions.c
文件 235160 2004-08-25 09:31 bomb\bomb.o
文件 240824 2004-08-25 09:31 bomb\interface.o
文件 264872 2004-08-25 09:31 bomb\actions.o
目录 0 2008-05-08 20:51 bomb\bomb
文件 11710 2004-08-25 09:33 bomb\trace.c
文件 221944 2004-08-25 09:33 bomb\trace
文件 442 2004-08-24 15:40 bomb\xpm\c.xpm
文件 325 2004-08-24 15:40 bomb\xpm\.xvpics\c.xpm
文件 325 2004-08-24 15:40 bomb\xpm\.xvpics\f.xpm
文件 325 2004-08-24 15:40 bomb\xpm\.xvpics\m.xpm
文件 325 2004-08-24 15:40 bomb\xpm\.xvpics\e.xpm
文件 325 2004-08-24 15:40 bomb\xpm\.xvpics\i.xpm
目录 0 2008-05-08 20:51 bomb\xpm\.xvpics
文件 502 2004-08-24 15:40 bomb\xpm\f.xpm
文件 427 2004-08-24 15:40 bomb\xpm\m.xpm
文件 442 2004-08-24 15:40 bomb\xpm\e.xpm
文件 427 2004-08-24 15:40 bomb\xpm\i.xpm
目录 0 2008-05-08 20:51 bomb\xpm
文件 17992 2004-08-25 09:28 bomb\COPYING
文件 2 2004-08-24 15:40 bomb\succeed
文件 2 2004-08-24 15:40 bomb\all
文件 295 2004-08-24 15:57 bomb\testsuite
目录 0 2008-05-10 20:00 bomb
............此处省略34个文件信息
- 上一篇:利用小波变换对图像进行分解与重构
- 下一篇:BmpButton
评论
共有 条评论