⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mini-fooltrs 最简俄罗斯(一百多行).htm

📁 经典小游戏,希望能给大家带来点好处
💻 HTM
📖 第 1 页 / 共 4 页
字号:
        <TR>
          <TD width=20 
          background="MINI-FOOLTRS 最简俄罗斯(一百多行)_files/banbg.gif"> </TD>
          <TD width=530 background="MINI-FOOLTRS 最简俄罗斯(一百多行)_files/banbg.gif" 
          height=20>当前位置:<A class=class 
            href="http://www.cstudyhome.com/wenzhang06/">网站首页</A>&gt;&gt;<A 
            class=class 
            href="http://www.cstudyhome.com/wenzhang06/type.asp?typeid=11">C语言</A>&gt;&gt;<A 
            class=class 
            href="http://www.cstudyhome.com/wenzhang06/BigClass.asp?typeid=11&amp;BigClassid=34">C游戏编程</A>&gt;&gt;<A 
            class=class 
            href="http://www.cstudyhome.com/wenzhang06/SmallClass.asp?typeid=11&amp;BigClassID=34&amp;SmallClassID=61">C语言游戏编程</A></TD>
          <TD width=107 background="MINI-FOOLTRS 最简俄罗斯(一百多行)_files/banbg.gif" 
          height=20>双击自动滚屏</TD>
          <TD width=91 background="MINI-FOOLTRS 最简俄罗斯(一百多行)_files/banbg.gif"><INPUT onclick="window.close();return false;" type=button value=关闭窗口 name=close> 
          </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE style="BORDER-COLLAPSE: collapse" borderColor=#e2ca9f cellSpacing=0 
cellPadding=0 width=750 align=center border=3>
  <TBODY>
  <TR><!--<td width="20%" align="middle" valign="top" background="images/002.jpg" bordercolor="#e2ca9f"> </td> 
<td width="80%">-->
    <TD width="100%">
      <TABLE borderColor=#e2ca9f cellSpacing=0 cellPadding=0 width="100%" 
      border=0>
        <TBODY>
        <TR>
          <TD vAlign=top align=middle width="95%">
            <TABLE borderColor=#e2ca9f cellSpacing=0 cellPadding=0 width="100%" 
            border=1>
              <TBODY>
              <TR>
                <TD vAlign=top borderColor=#e2ca9f align=middle width="69%" 
                background="MINI-FOOLTRS 最简俄罗斯(一百多行)_files/002.jpg">
                  <TABLE cellSpacing=0 cellPadding=0 width="100%" align=center 
                  border=0>
                    <TBODY>
                    <TR>
                      <TD width="100%" height=40></TD></TR>
                    <TR>
                      <TD>
                        <FORM name=form1 
                        action=Readnews.asp?newsid=5493&amp;id2=5493 
method=post>
                        <CENTER><!-- <input type=submit name=aa value="点击关闭浮动图标" width=20 title="点击广告支持本站">--></CENTER></FORM></TD></TR>
                    <TR>
                      <TD style="FONT-SIZE: 18px" vAlign=bottom align=middle 
                      width="85%" bgColor=#dddddd height=20><STRONG><FONT 
                        color=#003399 size=4><B>MINI-FOOLTRS 最简俄罗斯(一百多行) 
                        </B></FONT></STRONG></TD><BR></TR>
                    <TR>
                      <TD align=middle width="100%"><BR></TD></TR>
                    <TR>
                      <TD style="FONT-SIZE: 9pt" align=middle 
                        width="100%">发表日期:2005年5月15日&nbsp;&nbsp;出处:http://www.joynb.net/&nbsp;&nbsp;作者:skywind&nbsp;&nbsp;已经有1985位读者读过此文</TD></TR>
                    <TR>
                      <TD align=middle width="100%"><!--下面的这一句是设置阅读文本区的宽度-->
                        <TABLE style="TABLE-LAYOUT: fixed" cellSpacing=0 
                        cellPadding=0 width="90%" align=center border=0>
                          <TBODY>
                          <TR>
                            <TD align=middle width="100%"></TD></TR>
                          <TR>
                            <TD style="WORD-WRAP: break-word"><FONT 
                              class=news><BR><PRE class=code><SPAN class=comment><FONT color=#008000>/*=====================================================================
// FOOLTRS.C: Fool tetris game v1.0 by skywind
// 最简俄罗斯,游戏设计入门傻瓜版,林伟 1999年8月11日
//
// 游戏并无任何扩展,仅以最简单的方式向人说明俄罗斯方块的基本功能实现
// 程序运行于MS-DOS,虽然现在写游戏的平台早已变化了许多,
// 但是我尽量容入了一些不变理论,希望才入门的游戏设计者能得到一些帮助
// 用方向键/空格游戏,代码不超过两百行,初学C者皆能读懂,请用TC20编译
//
//=====================================================================*/</FONT></SPAN>
<SPAN class=style1><FONT color=#0000ff>#include</FONT></SPAN> &lt;stdio.h&gt;
<SPAN class=style1><FONT color=#0000ff>#include</FONT></SPAN> &lt;stdlib.h&gt;
<SPAN class=style1><FONT color=#0000ff>#include</FONT></SPAN> &lt;time.h&gt;
<SPAN class=style1><FONT color=#0000ff>#include</FONT></SPAN> &lt;conio.h&gt;
<SPAN class=style1><FONT color=#0000ff>#include</FONT></SPAN> &lt;string.h&gt;
<SPAN class=style1><FONT color=#0000ff>#include</FONT></SPAN> &lt;dos.h&gt;

<SPAN class=comment><FONT color=#008000>/*---------------------------------------------------------------------
// 基本定义:地图和砖块
//---------------------------------------------------------------------*/</FONT></SPAN>
<SPAN class=keyword><FONT color=#0000ff>int</FONT></SPAN> map[26][10]; <SPAN class=comment><FONT color=#008000>/* 游戏地图定义: 所有砖块将被描述在地图中 ............*/</FONT></SPAN>

<SPAN class=keyword><FONT color=#0000ff>typedef</FONT></SPAN> <SPAN class=keyword><FONT color=#0000ff>struct</FONT></SPAN> { <SPAN class=keyword><FONT color=#0000ff>int</FONT></SPAN> d[4][4]; } Block;  <SPAN class=comment><FONT color=#008000>/* 砖块结构定义 ...............*/</FONT></SPAN>
<SPAN class=keyword><FONT color=#0000ff>int</FONT></SPAN> BlockList[7][4][4] = {      <SPAN class=comment><FONT color=#008000>/* 七种传统的方块定义 .................*/</FONT></SPAN>
  { { 0, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 1, 0, 0 }, { 0, 1, 1, 0 } },
  { { 0, 0, 0, 0 }, { 0, 0, 2, 0 }, { 0, 0, 2, 0 }, { 0, 2, 2, 0 } },
  { { 0, 3, 0, 0 }, { 0, 3, 0, 0 }, { 0, 3, 0, 0 }, { 0, 3, 0, 0 } },
  { { 0, 4, 0, 0 }, { 0, 4, 4, 0 }, { 0, 0, 4, 0 }, { 0, 0, 0, 0 } },
  { { 0, 0, 5, 0 }, { 0, 5, 5, 0 }, { 0, 5, 0, 0 }, { 0, 0, 0, 0 } },
  { { 0, 6, 6, 6 }, { 0, 0, 6, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } },
  { { 0, 0, 0, 0 }, { 0, 7, 7, 0 }, { 0, 7, 7, 0 }, { 0, 0, 0, 0 } }};
<SPAN class=keyword><FONT color=#0000ff>unsigned</FONT></SPAN> <SPAN class=keyword><FONT color=#0000ff>char</FONT></SPAN> cmap[]={0,<SPAN class=style3><FONT color=#666666>0x72</FONT></SPAN>,<SPAN class=style3><FONT color=#666666>0x30</FONT></SPAN>,<SPAN class=style3><FONT color=#666666>0x47</FONT></SPAN>,<SPAN class=style3><FONT color=#666666>0x57</FONT></SPAN>,<SPAN class=style3><FONT color=#666666>0x27</FONT></SPAN>,<SPAN class=style3><FONT color=#666666>0x60</FONT></SPAN>,<SPAN class=style3><FONT color=#666666>0x74</FONT></SPAN>}; <SPAN class=comment><FONT color=#008000>/* 颜色表 */</FONT></SPAN>
<SPAN class=keyword><FONT color=#0000ff>long</FONT></SPAN> GameMode = 0, GameSpeed = -1, GameScore = 0; <SPAN class=comment><FONT color=#008000>/* 全局定义:各状态 .*/</FONT></SPAN>

<SPAN class=comment><FONT color=#008000>/*---------------------------------------------------------------------
// 视频相关数据定义
//---------------------------------------------------------------------*/</FONT></SPAN>
<SPAN class=keyword><FONT color=#0000ff>char</FONT></SPAN> <SPAN class=style1><FONT color=#0000ff>far</FONT></SPAN>* TextBuf = (<SPAN class=keyword><FONT color=#0000ff>char</FONT></SPAN> <SPAN class=style1><FONT color=#0000ff>far</FONT></SPAN>*)<SPAN class=style3><FONT color=#666666>0xb8000000l</FONT></SPAN>; <SPAN class=comment><FONT color=#008000>/* 文本状态的显存地址 .....*/</FONT></SPAN>
<SPAN class=keyword><FONT color=#0000ff>char</FONT></SPAN> TextBck[20][10];                       <SPAN class=comment><FONT color=#008000>/* 文本状态的二级缓存 .....*/</FONT></SPAN>
#define SCREEN(x,y) (TextBuf[((y) * 160) + ((x) * 2)])   <SPAN class=comment><FONT color=#008000>/* 显存中字符 */</FONT></SPAN>
#define SCOLOR(x,y) (TextBuf[((y) * 160) + ((x) * 2) + 1]) <SPAN class=comment><FONT color=#008000>/* 屏幕颜色 */</FONT></SPAN>

<SPAN class=comment><FONT color=#008000>/*---------------------------------------------------------------------
// 基本砖块操作函数
//---------------------------------------------------------------------*/</FONT></SPAN>
<SPAN class=keyword><FONT color=#0000ff>void</FONT></SPAN> Rotate(<SPAN class=keyword><FONT color=#0000ff>const</FONT></SPAN> Block* src, Block* dest)  <SPAN class=comment><FONT color=#008000>/* 旋转砖块src到dest ......*/</FONT></SPAN>
{
    <SPAN class=keyword><FONT color=#0000ff>int</FONT></SPAN> i, j;
    <SPAN class=keyword><FONT color=#0000ff>for</FONT></SPAN> (j = 0; j &lt; 4; j++) <SPAN class=keyword><FONT color=#0000ff>for</FONT></SPAN> (i = 0; i &lt; 4; i++)
    dest-&gt;d[i][j] = src-&gt;d[j][3 - i];
}

<SPAN class=keyword><FONT color=#0000ff>int</FONT></SPAN> MapCheck(<SPAN class=keyword><FONT color=#0000ff>int</FONT></SPAN> x, <SPAN class=keyword><FONT color=#0000ff>int</FONT></SPAN> y) <SPAN class=comment><FONT color=#008000>/* 检测地图中某坐标是否有砖块 ..............*/</FONT></SPAN>
{
    <SPAN class=keyword><FONT color=#0000ff>if</FONT></SPAN> (x &lt; 0 || x &gt;=10 || y &lt; 0 || y &gt;= 26) <SPAN class=keyword><FONT color=#0000ff>return</FONT></SPAN> -1;
    <SPAN class=keyword><FONT color=#0000ff>return</FONT></SPAN> map[y][x];
}

<SPAN class=keyword><FONT color=#0000ff>int</FONT></SPAN> BlockCheck(<SPAN class=keyword><FONT color=#0000ff>int</FONT></SPAN> x, <SPAN class=keyword><FONT color=#0000ff>int</FONT></SPAN> y, <SPAN class=keyword><FONT color=#0000ff>const</FONT></SPAN> Block* src) <SPAN class=comment><FONT color=#008000>/* 检测砖块位置合法性 ..*/</FONT></SPAN>
{
    <SPAN class=keyword><FONT color=#0000ff>int</FONT></SPAN> i, j;
    <SPAN class=keyword><FONT color=#0000ff>for</FONT></SPAN> (j = 0; j &lt; 4; j++) <SPAN class=keyword><FONT color=#0000ff>for</FONT></SPAN> (i = 0; i &lt; 4; i++)
        <SPAN class=keyword><FONT color=#0000ff>if</FONT></SPAN> (MapCheck(x + j, y - i) &amp;&amp; src-&gt;d[i][j]) <SPAN class=keyword><FONT color=#0000ff>return</FONT></SPAN> 0;
    <SPAN class=keyword><FONT color=#0000ff>return</FONT></SPAN> 1;
}

<SPAN class=keyword><FONT color=#0000ff>void</FONT></SPAN> CreateBlock(Block* src) <SPAN class=comment><FONT color=#008000>/* 随机创建一个砖块,然后保存到src .......*/</FONT></SPAN>
{
    <SPAN class=keyword><FONT color=#0000ff>int</FONT></SPAN> i,j,k = rand() % 7;
    Block t;
    <SPAN class=keyword><FONT color=#0000ff>for</FONT></SPAN> (i = 0; i &lt; 4; i++) <SPAN class=keyword><FONT color=#0000ff>for</FONT></SPAN> (j = 0; j &lt; 4; j++)
        src-&gt;d[i][j] = BlockList[k][i][j];
    <SPAN class=keyword><FONT color=#0000ff>for</FONT></SPAN> (i = rand() % 4; i &gt; 0; i--, *src = t) Rotate(src, &amp;t);
}

<SPAN class=keyword><FONT color=#0000ff>long</FONT></SPAN> TimePass = 0, TimeExit = -1, GameTime = -1, w;
<SPAN class=keyword><FONT color=#0000ff>void</FONT></SPAN> GameMain(<SPAN class=keyword><FONT color=#0000ff>void</FONT></SPAN>);
<SPAN class=comment><FONT color=#008000>/*---------------------------------------------------------------------
// 程序入口函数
//---------------------------------------------------------------------*/</FONT></SPAN>
<SPAN class=keyword><FONT color=#0000ff>void</FONT></SPAN> main(<SPAN class=keyword><FONT color=#0000ff>void</FONT></SPAN>)
{
    clrscr();                               <SPAN class=comment><FONT color=#008000>/* 初始化:清屏 ...........*/</FONT></SPAN>
    randomize();                            <SPAN class=comment><FONT color=#008000>/* 初始化:随机数种子 .....*/</FONT></SPAN>
    <SPAN class=keyword><FONT color=#0000ff>for</FONT></SPAN> (w = 0; w &lt; 26; w++) memset(map[w], 0, <SPAN class=keyword><FONT color=#0000ff>sizeof</FONT></SPAN>(<SPAN class=keyword><FONT color=#0000ff>int</FONT></SPAN>) * 10);
    <SPAN class=keyword><FONT color=#0000ff>for</FONT></SPAN> (w = 0; w &lt; 22; w++)                <SPAN class=comment><FONT color=#008000>/* 初始化:绘制边框 .......*/</FONT></SPAN>
        SCREEN(w,0)=254, SCOLOR(w,0)=8, SCREEN(w,21)=254, SCOLOR(w,21)=8,
        SCREEN(0,w)=254, SCOLOR(0,w)=8, SCREEN(21,w)=254, SCOLOR(21,w)=8;
    GameSpeed = 2;                          <SPAN class=comment><FONT color=#008000>/* 初始化:设置速度 .......*/</FONT></SPAN>

    GameMain();                             <SPAN class=comment><FONT color=#008000>/* 进入游戏主程序 .........*/</FONT></SPAN>
}

<SPAN class=keyword><FONT color=#0000ff>int</FONT></SPAN> readkey(<SPAN class=keyword><FONT color=#0000ff>void</FONT></SPAN>)           <SPAN class=comment><FONT color=#008000>/* 无等待的接收一个键盘消息 ...............*/</FONT></SPAN>
{
    <SPAN class=keyword><FONT color=#0000ff>if</FONT></SPAN> (!kbhit()) <SPAN class=keyword><FONT color=#0000ff>return</FONT></SPAN> 0; <SPAN class=comment><FONT color=#008000>/* 如果当前没有按键消息则直接返回 .........*/</FONT></SPAN>
    <SPAN class=keyword><FONT color=#0000ff>if</FONT></SPAN> ((w = getch()) == 0) <SPAN class=keyword><FONT color=#0000ff>return</FONT></SPAN> getch();   <SPAN class=comment><FONT color=#008000>/* 返回非控制键 .........*/</FONT></SPAN>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -