printf画的俄罗斯方块(linux异步I/O,C++)
这个方块游戏是用linux终端的光标控制、颜色设置做的
(添了个功能,字母P暂停、恢复游戏)
用 A S D W 控制移动、转向,空格键下坠到底;
linux的异步aio函数解决了很多麻烦;
用了个简单的模板单例模式,继承它就可以;
对POSIX线程简单封装成java线程接口;
#include <memory>
#include "Tetris.h"
#include "TtyAuto.h"
static void instruction()
{
// 一些说明性文字
printf("\033[2J");
printf("\033[4;34;47m%s\033[0m", "\t\t\tYou can use the key 'A','S','D','W' to control the block.\n\n\t\t\tPress space key make the block down to bottom.\n\n\t\t\t'P' to pause the game.\n\n");
printf("\033[5;34;41m%s\033[0m", "\t\t\tPRESS ANY KEY TO START GAME...\n\n" );
getchar();
}
int main(int ac, char *av[])
{
std::auto_ptr<TtyAuto> autoAdjustTty(TtyAuto::getInstance());
instruction();
// 游戏开始
Tetris game;
game.start();
game.join();
printf("\r\t\t\t\t\t\r");
return 0;
}
#ifndef BERT_THREAD_H
#define BERT_THREAD_H
#include <pthread.h>
/**
* 线程封装,接口模仿JAVA
*/
class Runnable
{
public:
virtual ~Runnable() { }
/**
* 线程逻辑在此实现
*/
virtual void run() = 0;
};
class Thread: public Runnable
{
/**
* 本线程ID
*/
pthread_t m_tid;
/**
* 是否在运行的标志
*/
bool running;
/**
* 线程函数,内部调用run
*/
static void * threadFunc(void * arg);
public:
Thread();
~Thread();
/**
* 睡眠 秒
*/
static unsigned int sleep( unsigned int seconds);
/**
* 睡眠毫秒
*/
static unsigned int msleep( unsigned int mSeconds);
/**
* 启动线程
*/
bool start() ;
/**
* 等待本线程运行完
*/
void join() const;
/**
* 是否在运行
*/
bool isAlive() const
{
return running;
相关文档:
/bin 存放最常用的命令,此目录下的命令所有用户都有执行的权限
/boot Linux系统引导目录,此目录保存系统启动时的内核文件和内核映像文件及启动时所需的其它文件
/dev 设备文件,保存所有的硬件设备文件,如硬盘设备文件,软驱、光驱设备文件等等
/etc ......
VirtualBox官方网站:http://www.virtualbox.org/
以下为ubuntu 为平台的安装、配置、使用,其实在各个发行版中的使用都差不多,只是在下载的时候需要下载相对应主系统平台的安装包即可。
环境需求:
VirtualBox需要ker ......
#include <sys/select.h>
#include <sys/time.h>
#include
<sys/types.h>
#include <unistd.h>
int select(int
nfds,fd_set *readfds,fd_set *writefds, fd_set *except fds,struct timeval
*timeout)
void FD_SET(int fd,fd_set *fdset)
void FD_CLR(int fd,fd_set
*fdset)
void F ......
Ethtool是用于查询及设置网卡参数的命令。
概要:
ethtool ethX //查询ethX网口基本设置
ethtool –h //显示ethtool的命令帮助(help)
ethtool –i ethX //查询ethX网口的相关信息
ethtool –d ethX  ......
下载地址:http://www.fcitx.org/main/?q=node/9
Version-版本 Update─更新日期备注
fcitx-3.4.tar.bz2
2006-09-21
最新稳定版
fcitx-060910.tar.bz2
2006-09-10
测试版
fcitx-3.3.1-bin.tar.bz2
2006-08-30
稳定版(预编译包IA32)
选择最新版。。
源码包的安装;
[root@localhost beinan]# tar jxvf fci ......