qt实现的一个俄罗斯方块的程序 主窗口c文件
//-----------------------------------------------------------------------------------------------------
//BY:yuyongbao
//QQ:673360056
//-----------------------------------------------------------------------------------------------------
#include "tetris.h"
Tetris::Tetris(QWidget *parent)
: QDialog(parent), ui(new Ui::Tetris)
{
ui->setupUi(this);
gameInit();
this->connect(ui->frame,SIGNAL(scoreChanged(int)),this,SLOT(drawScore(int)));
this->connect(ui->frame,SIGNAL(nextTetrixChanged()),this,SLOT(nextTetrixChangedProc()));
this->connect(ui->frame,SIGNAL(gameOver()),this,SLOT(gameEnd()));
}
Tetris::~Tetris()
{
delete ui;
}
void Tetris::gameInit(void)
{
m_curScore = 0;
//总分数以后由文件读入
m_totalScore = 0;
m_level = 0;
m_line = 0;
m_bStart = FALSE;
m_mute = FALSE;
m_nextTetrisPos = QRect(120,160,4*PIXPERRECT,4*PIXPERRECT);
m_scorePos = QRect(50,200,200,40);
m_levelPos = QRect(50,240,200,40);
m_linePos = QRect(50,280,200,40);
//随机种子
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
skinPath = "skins/";
}
void Tetris::gameStart(void)
{
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(timePro()));
//游戏等级与时间之间的关系
timer->start(1600 - m_level * 300);
//产生当前方块和下一个方块
ui->frame->curShape = (TetrixShape)(qrand()%7);
ui->frame->nextShape = (TetrixShape)(qrand()%7);
&n
相关文档:
曾经碰到过让你迷惑不解、类似于int * (* (*fp1) (int) ) [10];这样的变量声明吗?
本文将由易到难,一步一步教会你如何理解这种复杂的C/C++声明。
我们将从每天都能碰到的较简单的声明入手,然后逐步加入const修饰符和typedef,还有函数指针,最后介绍一个能够让你准确地理解任何C/C++声明的“右左法则&rdquo ......
前段时间刚参加了n多公司的C/C++软件工程师的面试,有国企,外企,私企(moto,飞思卡尔,港湾,中国卫星XXX(这个牛))等等等等。感受感想颇多,近日终于空闲,在此表述一下。
本人基本条件:3年开发经验,2year+ Windows development experence,1year+ Linux experence. 熟悉C,C++,MFC/SDK/API,MiniG ......
1、为了调用宏时能得到正确结果,在宏体中建议对宏的每个参数用括号括起来,并且当宏体是一个表达式时整个宏体也用括号括起来。
/* c1.c:将两个数相乘 */
#define product(x,y) ((x)*(y))
#include <stdio.h>
int main(){
int a=1,b=2,c=3,d=4,x=0;
x=product(a+3,b)+product(c,d); / ......
/* =========================================================================== */
/* Project: mp3 player */
/* File: & ......