Exemplo n.º 1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setFixedSize(ui->graphicsView->width()+10,ui->graphicsView->height()+25);
    m_file = menuBar()->addMenu("Game");
    m_help = menuBar()->addMenu("Help");
    m_newGame = new QAction(tr("&New Game"),this);
    //m_settings = new QAction(tr("&Settings"),this);
    m_exit = new QAction(tr("E&xit"),this);
    m_about = new QAction(tr("About arkanoid"),this);
    m_newGame->setShortcut(QKeySequence::New);
    m_newGame->setShortcut(QKeySequence::Close);

    QPixmap bgPix(":/img/hexagon_pattern.png");
    bgPix = bgPix.scaled(800,600, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    m_scene = new QGraphicsScene(0,0,ui->graphicsView->width(),ui->graphicsView->height());
    ui->graphicsView->setScene(m_scene);

    QPixmap blft(":/img/border_left.png");
    QPixmap btop(":/img/border_top.png");
    QPixmap brght(":/img/border_right.png");
    blft = blft.scaled(800,25, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    btop = btop.scaled(25,600, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    brght = brght.scaled(800,25, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);

    ui->graphicsView->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
    ui->graphicsView->setBackgroundBrush(bgPix);
    ui->graphicsView->setCacheMode(QGraphicsView::CacheBackground);
    ui->graphicsView->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);

    QIcon ico(tr(":/icon.ico"));
    setWindowIcon(ico);

    connect(m_newGame,SIGNAL(triggered()),this,SLOT(startNewGame()));
    //connect(m_settings,SIGNAL(triggered()),this,SLOT(openSettings()));
    connect(m_exit,SIGNAL(triggered()),this,SLOT(close()));
    connect(m_about,SIGNAL(triggered()),this,SLOT(openAbout()));

    m_file->addAction(m_newGame);
    m_file->addSeparator();
    //m_file->addAction(m_settings);
    //m_file->addSeparator();
    m_file->addAction(m_exit);
    m_help->addAction(m_about);

    setCentralWidget(ui->graphicsView);
}
Exemplo n.º 2
0
int main () {
    initMotors();
	open(5);
	unsigned char rx_str[50];
	while (1) {
	    read(rx_str,10,ON);
		if(!(strncmp(rx_str,"fwd",3))) {fwd(rx_str[4]);}
		if(!(strncmp(rx_str,"bwd",3))) {bwd(rx_str[4]);}
		if(!(strncmp(rx_str,"lft",3))) {lft(rx_str[4]);}
		if(!(strncmp(rx_str,"rgh",3))) {rgh(rx_str[4]);}
		if(!(strncmp(rx_str,"slft",4))) {slft(rx_str[4]);}
		if(!(strncmp(rx_str,"srgh",4))) {srgh(rx_str[4]);}
		if(!(strncmp(rx_str,"blft",4))) {blft(rx_str[4]);}
		if(!(strncmp(rx_str,"brgh",4))) {brgh(rx_str[4]);}
		if(!(strncmp(rx_str,"stop",4))) {stop();}
	}
	return 0;
}