ListEditorWidget::ListEditorWidget(QStringList list)
{
    QHBoxLayout *hlayout = new QHBoxLayout;
    QVBoxLayout *vlayout = new QVBoxLayout;
    QPushButton *badd = new QPushButton(tr("Add"));
    QPushButton *bremove = new QPushButton(tr("Remove"));
//    QPushButton *bup = new QPushButton(style()->standardIcon(QStyle::SP_ArrowUp),tr("Move Up"));
//    QPushButton *bdown = new QPushButton(style()->standardIcon(QStyle::SP_ArrowDown),tr("Move Down"));
    QPushButton *bup = new QPushButton(style()->standardIcon(QStyle::SP_ArrowUp),"");
    QPushButton *bdown = new QPushButton(style()->standardIcon(QStyle::SP_ArrowDown),"");

    this->list = list;
    listWidget = new QListWidget;
    listWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    listWidget->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::SelectedClicked|QAbstractItemView::EditKeyPressed);
    hlayout->addWidget(listWidget);

    vlayout->addWidget(badd);
    vlayout->addWidget(bremove);
    vlayout->addWidget(bup);
    vlayout->addWidget(bdown);

    connect(badd,SIGNAL(clicked()),this,SLOT(add()));
    connect(bremove,SIGNAL(clicked()),this,SLOT(remove()));
    connect(bup,SIGNAL(clicked()),this,SLOT(moveup()));
    connect(bdown,SIGNAL(clicked()),this,SLOT(movedown()));

    connect(listWidget,SIGNAL(itemChanged( QListWidgetItem *)), this, SLOT(saveNamesFromListWidget()) );

    refresh();

    hlayout->addLayout(vlayout);
    this->setLayout(hlayout);
}
Example #2
0
void Water::Dpipebehaviour(SDL_Renderer* ren,vector<DPipe> a)
{
	int num=whereiamDpipe(a);
	if(right==true && (a[num].getuse()==1 || a[num].getuse()==3) && num!=-1)
	{

		moveright();
		default_create(ren,"start.jpg");
		
	}
	else if(left==true && (a[num].getuse()==1 || a[num].getuse()==3) && num!=-1)
	{

		moveleft();
		default_create(ren,"start.jpg");
	}
	else if(up==true  && (a[num].getuse()==2 || a[num].getuse()==4) && num!=-1)
	{

		moveup();
		default_create(ren,"start.jpg");
	}
	else if(down==true && (a[num].getuse()==2 || a[num].getuse()==4) && num!=-1)
	{

		movedown();
		default_create(ren,"start.jpg");
	}
}
Example #3
0
/*
 * check_char()
 *
 * Handle processing of the input
 *
 * Precondition: Parameter is not void
 * Postcondition: The input is processed
 *
 * @param char* input The input
 */
void    check_char(char* input)
{
    int count;

    if(input != NULL)
    {
        if(!my_strcmp(input, KU))
        {
            moveup();
        }
        else if(!my_strcmp(input, KD))
        {
            movedown();
        }
        else if(!my_strcmp(input, KL))
        {
            moveleft();
        }
        else if(!my_strcmp(input, KR))
        {
            moveright();
        }
        else if(!my_strcmp(input, " "))
        {
            doselect();
        }
        else
        {
            getout(input);
        }
    }
}
Example #4
0
void Water::Crosspipebehaviour(SDL_Renderer *ren, vector<CrossPipe> a)
{
	int num=whereiamCrosspipe(a);
	if(right==true && isCrosspipe(a) &&num!=-1)
	{
		
		moveright();
		default_create(ren,"start.jpg");
		
	}
	else if(left==true && isCrosspipe(a) && num!=-1)
	{
		
		moveleft();
		default_create(ren,"start.jpg");
	}
	else if(up==true  && isCrosspipe(a) && num!=-1)
	{
		
		moveup();
		default_create(ren,"start.jpg");
	}
	else if(down==true && isCrosspipe(a) &&num!=-1)
	{
		
		movedown();
		default_create(ren,"start.jpg");
	}
}
Example #5
0
/*
 * Shuffle the image by swapping pieces of size maskdim.
 */
static void
shuffle(Image *img, Image *tmp, int axis, int imgdim, Image *mask, int maskdim)
{
	int slop;

	if(maskdim == 0)
		return;

	/*
	 * Figure out how much will be left over that needs to be
	 * shifted specially to the bottom.
	 */
	slop = imgdim % maskdim;

	/*
	 * Swap adjacent grating lines as per mask.
	 */
	swapadjacent(img, tmp, axis, imgdim - slop, mask, maskdim);

	/*
	 * Calculate the mask with gratings half as wide and recur.
	 */
	halvemaskdim(mask, maskdim, axis);
	writefile("mask", mask, maskdim/2);

	shuffle(img, tmp, axis, imgdim, mask, maskdim/2);

	/*
	 * Move the slop down to the bottom of the image.
	 */
	swapranges(img, tmp, 0, imgdim-slop, imgdim, axis);
	moveup(im, tmp, lastnn, nn, n, axis);
}
Example #6
0
Menu::Menu()
{
    fprintf(stderr, "Menu constructing\n");
	std::vector<std::string> entries;
	entries.push_back("Play game");
	entries.push_back("Options");
	entries.push_back("Help");
	entries.push_back("Quit");

	// Size of screen
    int width = manager.getOpengl()->getScreenX()/2;
	int height = manager.getOpengl()->getScreenY()/2-50;		// Leave 50 pixels of border
	
	// Size of text
	int sizex = 0;
	int sizey = 0;
	
	for (int i = 0; i < entries.size(); i++)
	{
		sizex = entries[i].length()*7;
		sizey = 12;
		TextPtr tempTextPtr(new Text(sizex, sizey, entries[i].c_str(), "data/fonts/ArcadeClassic.ttf", 50));
		items.push_back(tempTextPtr);
        fprintf(stderr, "Item %s added to the list\n", entries[i].c_str());
	}
	
	fprintf(stderr, "Creating logo\n");
	TextPtr tempTextPtr2(new Text(280, 80, "CAPTAIN", "data/fonts/BulwarkNF.ttf", 80));
    tempTextPtr2->x = 300;
    tempTextPtr2->y = 450;
	additionalTexts.push_back(tempTextPtr2);
	TextPtr tempTextPtr(new Text(10, 10, "O", "data/fonts/ArcadeClassic.ttf", 15));
	cursor = tempTextPtr;
	
	assert(items.size() != 0);
	step = height/items.size();
	if (step > 40)
		step = 40;
	
	int posy = height;
	int i = 0;
	
	cursor->x = width-120;
	cursor->y = height-step;
	
	for (std::vector<TextPtr>::iterator iter = items.begin(); iter != items.end(); iter++)
	{
		(*iter)->x = width;		// Draw to center
		(*iter)->y = height - i*step;	// Draw with a good spacing
		i++;
	}
	
	// Meh, let's just add this hack here
	currentSelection = 1;
	moveup();
    fprintf(stderr, "Menu constructed\n");
}
Example #7
0
static void ins_block(BLOCK *pb, ENTRY *pe, int off)
{
    int size;
    update_root(pb);
    size = ENT_SIZE(pe);
    moveup(pb,off,size);
    copy_entry(ENT_ADR(pb,off),pe);
    pb->bend += size;
} 
Example #8
0
void Blank::operator |(Blank *b){
    int tmp_Num=b->number;
    b->number=number;
    number=tmp_Num;
    connect(time,SIGNAL(timeout()),this,SLOT(moveup()));
    connect(b->time,SIGNAL(timeout()),b,SLOT(movedown()));
    time->start(100);
    b->time->start(100);

}
Example #9
0
void Blank::moveup()
{       buttom->setGeometry(colum *50,row*50+shift*10,50,50);
        shift++;
        if(shift==5){
            shift=1;
            disconnect(time,SIGNAL(timeout()),this,SLOT(moveup()));
            buttom->setGeometry(colum*50,row*50,50,50);
            setButtonPicture();
        }
    emit movedone();
}
Example #10
0
void keydown(int key){
    printf("Key: %i\n", key);

    if(key == left)
        moveleft();
    if(key == right)
        moveright();
    if(key == up)
        moveup();
    if(key == down)
        movedown();


}
Example #11
0
char check_char(char* input){

	if(input != NULL){
		if(my_strcmp(input, KU) == 0){
			moveup();
		}else if(my_strcmp(input, KD) == 0){
			movedown();
		}else if(my_strcmp(input, KL) == 0){
			moveleft();
		}else if(my_strcmp(input, KR) == 0){
			moveright();
		}else if(my_strcmp(input, " ") == 0){
			doselect();
		}else{
			getout(input);
		}
	}
	return *input;
}
Example #12
0
int main(int argc, const char * argv[])
{
    char c;
    int pos;
    int pre[FRAME_SIZE][FRAME_SIZE] = {0};
    
    /* initial data */
    //srand((int)timer(0));
    pos = rand() % FRAME_ALL;
    pre[pos/FRAME_SIZE][pos%FRAME_SIZE] = generateNum();
    
    do
    {
        printFrame(pre);
        c = getchar();
        if (c == 'w' ) {
	    printf("%c\r\n", c);
            moveup(pre);
            update(pre, UP);
        }
        else if (c == 'a') {
            moveleft(pre);
            update(pre, LEFT);
        }
        else if (c == 's') {
            movedown(pre);
            update(pre, DOWN);
        }else if (c == 'd') {
            moveright(pre);
            update(pre, RIGHT);
        }else if (c == '\n'){
	    /* do nothing */
	}else {
	    printf("%c\r\n", c);
            printf("error character\r\n");
        }
    } while (c != 'q');
        
    // insert code here...
    printf("Hello, World!\n");
    return 0;
}
Example #13
0
/* check_char.c
pre: Takes a char* c
post: Takes action based upon what key is pressed
*/
char check_char(char* str){
  if(str){
    if(!(my_strcmp(str, "\n\0")))
      return 2;
    else if(!(my_strcmp(str, ESC)))
      return 1;
    else if (!(my_strcmp(str, KU)))
      moveup();
    else if (!(my_strcmp(str, KD)))
      movedown();
    else if (!(my_strcmp(str, KL)))
      moveleft();
    else if (!(my_strcmp(str, KR)))
      moveright();
    else if (!(my_strcmp(str, " \0")))
      doselect();
    return 0;
  }
  return -1;
}
Example #14
0
void check_char(char *c)
{
  if(!my_strcmp(c, (char *) SPACE))
    doselect();
  else if(!my_strcmp(c, gl_env.left))
    moveleft();
  else if(!my_strcmp(c, gl_env.right))
    moveright();
  else if(!my_strcmp(c, gl_env.up))
    moveup();
  else if(!my_strcmp(c, gl_env.down))
    movedown();
  else if(!my_strcmp(c, gl_env.esc) || !my_strcmp(c, (char *)ESC))
    {
      restore_terminal();
      getout(0);
      exit(1);
    }
  else if(!my_strcmp(c, (char *) ENTER))
    {
      restore_terminal();
      getout(1);
    }
}
Example #15
0
void Water::Doubpipebehavior(SDL_Renderer* ren,vector<DoublePipe> a)
{
	int num=whereiamDoubpipe(a);

	if(right==true && a[num].getuse()==2)
	{
		if((Voda.x+Voda.w<a[num].HorPart2().x+a[num].HorPart2().w) &&(Voda.y+Voda.h!=a[num].VertPart1().y+a[num].VertPart1().h) )
		{
	
			moveright();
			default_create(ren,"start.jpg");
		}
		else if((Voda.x+Voda.w==a[num].HorPart2().x+a[num].HorPart2().w) &&(Voda.y+Voda.h!=a[num].VertPart1().y+a[num].VertPart1().h))
		{

			Voda.y+=1;
			default_create(ren,"start.jpg");
		}

		if(Voda.y+Voda.h==a[num].VertPart1().y+a[num].VertPart1().h)
		{
			up=true; down=false; right=false; left=false;
		}

	}
	/* ================================================== */

	else if(right==true && a[num].getuse()==3)
	{
		if((Voda.x+Voda.w<a[num].HorPart2().x+a[num].HorPart2().w) &&(Voda.y!=a[num].VertPart2().y))
		{
			
			moveright();
			default_create(ren,"start.jpg");
		}
		else if((Voda.x+Voda.w==a[num].HorPart2().x+a[num].HorPart2().w) &&(Voda.y!=a[num].VertPart2().y))
		{
			;
			Voda.y-=1;
			default_create(ren,"start.jpg");
		}

		if(Voda.y==a[num].VertPart2().y)
		{
			up=false; down=true; right=false; left=false;
		}
		
	}
	
	/* ================================================== */
	else if(left==true && a[num].getuse()==1)
	{
		if(Voda.x>a[num].HorPart1().x)
		{
		
			moveleft();
			default_create(ren,"start.jpg");
		}
		else if(Voda.x==a[num].HorPart1().x)
		{

			default_create(ren,"start.jpg");
			Voda.y+=1;
		}
		if(Voda.y+Voda.h==a[num].VertPart1().y+a[num].VertPart1().h)
		{
			up=true; down=false; right=false; left=false;
		}
	
	}

	/* ================================================== */
	else if(left==true && a[num].getuse()==4)
	{
		if(Voda.x>a[num].HorPart1().x)
		{

			moveleft();
			default_create(ren,"start.jpg");
		}
		else if(Voda.x==a[num].HorPart1().x)
		{

			default_create(ren,"start.jpg");
			Voda.y-=1;
		}
		if(Voda.y==a[num].VertPart2().y)
		{
			up=false; down=true; right=false; left=false;
		}
		
	}

	/* ================================================== */
	else if(up==true && a[num].getuse()==3)
	{
		if((Voda.y+Voda.h<a[num].VertPart2().y+a[num].VertPart2().h) && (Voda.x!=a[num].HorPart2().x) )
		{
			
			moveup();
			default_create(ren,"start.jpg");
		}
		else if((Voda.y+Voda.h==a[num].VertPart2().y+a[num].VertPart2().h) && (Voda.x!=a[num].HorPart2().x))
		{
			
			default_create(ren,"start.jpg");
			Voda.x-=1;
		}
		if(Voda.x==a[num].HorPart2().x)
		{
			right=false; left=true; down=false; up=false;
		}
	
	}
	
	/* ================================================== */
	else if(up==true && a[num].getuse()==4)
	{
		if((Voda.y+Voda.h<a[num].VertPart2().y+a[num].VertPart2().h) )
		{
			
			moveup();
			default_create(ren,"start.jpg");
		}
		else if((Voda.y+Voda.h==a[num].VertPart2().y+a[num].VertPart2().h))
		{
			default_create(ren,"start.jpg");
			Voda.x+=1;
		}
		if(Voda.x+Voda.w==a[num].HorPart1().x+a[num].HorPart1().w)
		{
			right=true; left=false; down=false; up=false;
		}
		
	}
	else if(down==true && a[num].getuse()==1)
	{
		if(Voda.y>a[num].VertPart1().y)
		{
			
			movedown();
			default_create(ren,"start.jpg");
		}
		else if(Voda.y==a[num].VertPart1().y)
		{
			
			Voda.x+=1;
			default_create(ren,"start.jpg");
		}
		if(Voda.x+Voda.w==a[num].HorPart1().x+a[num].HorPart1().w)
		{
			right=true; left=false; up=false; down=false;
		}
		
	}
	/* ================================================== */
	else if(down==true && a[num].getuse()==2)
	{
		if(Voda.y>a[num].VertPart1().y)
		{
			
			movedown();
			default_create(ren,"start.jpg");
		}
		else if(Voda.y==a[num].VertPart1().y)
		{
			
			Voda.x-=1;
			default_create(ren,"start.jpg");
		}
		if(Voda.x==a[num].HorPart2().x)
		{
			right=false; left=true; up=false; down=false;
		}
		
	} 

	/* ================================================== */
}
Example #16
0
void TrackThread::run()
{
	VideoCapture caputure;
//	string WindowNameOutput="window";
	Mat frame;
	Mat output;
	//emit Mess(QString("test"),QString("camera open filed"));
	//return ;
	caputure.open(0);
	if(!caputure.isOpened())
	{
		emit Messquit(QString("warning"),QString("you don't have a camera, please connect one"));
		//md->mess("warning","camera open failed");
		return;
	}

//	namedWindow(WindowNameOutput);
//	cvWaitKey(1000);
	Sleep(1000);
	while(nRunFlag){
		if(!caputure.read(frame))
		{
			emit Messquit(QString("warning"),QString("please connect camera"));
			//md->mess("warning","camera read failed");
			break;
		}
		flip(frame,frame,1);
		int re=process (frame,output);

		//控制
		//if(md->ready){
			if(re==1){
				emit moveup();
			}
				//md->moveUp();
			else if(re==2){
				emit movedown();
			}
				//md->moveDown();
			else if(re==3){
				emit moveleft();
			}
				//md->moveLeft();
			else if (re==4){
				emit moveright();
			}
				//md->moveRight();
		//}
	//	imshow(WindowNameOutput,output);
	//	显示
		cvtColor(output, output, CV_BGR2RGB);
		QImage qq((unsigned char*)output.data,output.cols, output.rows,output.step,  QImage::Format_RGB888);
	//	md->setimg(QPixmap::fromImage(qq));
		emit setImg(QPixmap::fromImage(qq));
	//	if(md->exitt)
	//		break;
		Sleep(50);
//		cvWaitKey(1000);
	}
	caputure.release();
//	destroyWindow (WindowNameOutput);
}
Example #17
0
void MainWindow::createActions()    /*菜单选项*/
{
    /*文件菜单*/
    openAction = new QAction(tr("打开"),this);
    openAction->setStatusTip(tr("打开新文件"));
    connect(openAction,SIGNAL(triggered()),this,SLOT(openFile()));

    importAction = new QAction(tr("导入"),this);
    importAction->setStatusTip(tr("导入数据"));
    connect(importAction,SIGNAL(triggered()),this,SLOT(importFile()));
    importAction->setDisabled(true);

    sortAction = new QAction(tr("分类数据"),this);
    sortAction->setStatusTip(tr("处理分类数据"));
    connect(sortAction,SIGNAL(triggered()),this,SLOT(sortFile()));
    sortAction->setDisabled(true);

    exitAction = new QAction(tr("退出"),this);
    exitAction->setStatusTip(tr("退出程序"));
    connect(exitAction,SIGNAL(triggered()),this,SLOT(close()));

    /*导入菜单*/
    ebdicAction = new QAction(tr("显示EBDIC码"),this);
    ebdicAction->setStatusTip(tr("显示EBDIC码"));
    connect(ebdicAction,SIGNAL(triggered()),this,SLOT(loadEBDIC()));
    ebdicAction->setDisabled(true);

    reelAction = new QAction(tr("显示卷头"),this);
    reelAction->setStatusTip(tr("显示卷头信息"));
    connect(reelAction,SIGNAL(triggered()),this,SLOT(loadReel()));
    reelAction->setDisabled(true);

    traceAction = new QAction(tr("显示道头"),this);
    traceAction->setStatusTip(tr("显示选定位置道头信息"));
    connect(traceAction,SIGNAL(triggered()),this,SLOT(loadTrace()));
    traceAction->setDisabled(true);

    dataAction = new QAction(tr("地震数据"),this);
    dataAction->setStatusTip(tr("显示选定位置的地震记录"));
    connect(dataAction,SIGNAL(triggered()),this,SLOT(loadData()));
    dataAction->setDisabled(true);

    /*画图菜单*/
    waveAction = new QAction(tr("波形显示"),this);
    waveAction->setStatusTip(tr("波形显示剖面"));
    connect(waveAction,SIGNAL(triggered()),this,SLOT(drawWave()));
    waveAction->setDisabled(true);


    grayAction = new QAction(tr("灰度显示"),this);
    grayAction->setStatusTip(tr("显示灰度图像"));
    connect(grayAction,SIGNAL(triggered()),this,SLOT(drawGray()));
    grayAction->setDisabled(true);

    colorAction = new QAction(tr("彩色显示"),this);
    colorAction->setStatusTip(tr("显示彩色图像"));
    connect(colorAction,SIGNAL(triggered()),this,SLOT(drawColor()));
    colorAction->setDisabled(true);

    //操作openGL图像
    bigAction = new QAction(tr("放大"),this);
    bigAction->setStatusTip(tr("放大图像"));
    connect(bigAction,SIGNAL(triggered()),this,SLOT(bigger()));
    bigAction->setDisabled(true);

    littleAction = new QAction(tr("缩小"),this);
    littleAction->setStatusTip(tr("缩小图像"));
    connect(littleAction,SIGNAL(triggered()),this,SLOT(little()));
    littleAction->setDisabled(true);

    moveleftAction = new QAction(tr("左移"),this);
    moveleftAction->setStatusTip(tr("左移图像"));
    connect(moveleftAction,SIGNAL(triggered()),this,SLOT(moveleft()));
    moveleftAction->setDisabled(true);

    moverightAction = new QAction(tr("右移"),this);
    moverightAction->setStatusTip(tr("图像右移"));
    connect(moverightAction,SIGNAL(triggered()),this,SLOT(moveright()));
    moverightAction->setDisabled(true);

    moveupAction = new QAction(tr("上移"),this);
    moveupAction->setStatusTip(tr("上移图像"));
    connect(moveupAction,SIGNAL(triggered()),this,SLOT(moveup()));
    moveupAction->setDisabled(true);

    movedownAction = new QAction(tr("下移"),this);
    movedownAction->setStatusTip(tr("下移图像"));
    connect(movedownAction,SIGNAL(triggered()),this,SLOT(movedown()));
    movedownAction->setDisabled(true);

    moveMouseAction = new QAction(tr("移动"),this);
    moveMouseAction->setStatusTip(tr("使用鼠标移动图像"));
    connect(moveMouseAction,SIGNAL(triggered()),this,SLOT(moveMouse()));
    moveMouseAction->setDisabled(true);

    rotateMouseAction = new QAction(tr("旋转"),this);
    rotateMouseAction->setStatusTip(tr("旋转图像"));
    connect(rotateMouseAction,SIGNAL(triggered()),this,SLOT(rotateMouse()));
    rotateMouseAction->setDisabled(true);

    nextSliceAction = new QAction(tr("下一条剖面"),this);
    nextSliceAction->setStatusTip(tr("选择下一条剖面"));
    connect(nextSliceAction,SIGNAL(triggered()),this,SLOT(nextSlice()));
    nextSliceAction->setDisabled(true);

    preSliceAction = new QAction(tr("上一条剖面"),this);
    preSliceAction->setStatusTip(tr("选择上一条剖面"));
    connect(preSliceAction,SIGNAL(triggered()),this,SLOT(preSlice()));
    preSliceAction->setDisabled(true);

    drawGridAction = new QAction(tr("关闭网格"),this);
    drawGridAction->setStatusTip(tr("打开/关闭剖面图像上的网格"));
    connect(drawGridAction,SIGNAL(triggered()),this,SLOT(drawGrid()));
    drawGridAction->setDisabled(true);
}
Example #18
0
/** Default constructor */
MainWindow::MainWindow() : QWidget()
{
	/** constructor() that has in input file for scores */
	ifstream fin;
	fin.open("scores.txt");
	if(fin.fail())
	{
		cout << "Could not find the scores file" << endl;
	}
	else
	{
	  string temp;
	  int temp2;
	  getline(fin,temp,'|');
	  fin >> temp2;
		while(fin.good())
		{
			scorenames.push_back(temp);
			scores.push_back(temp2);
			getline(fin,temp,'|');
			fin >> temp2;
		}
	}
	  
	/** Set the Pixmaps */
	ez=new QPixmap("ezreal.png");
		*ez=ez->scaled(75,75,Qt::KeepAspectRatioByExpanding);
	melee=new QPixmap("meleeminion.png");
		*melee=melee->scaled(50,50,Qt::KeepAspectRatioByExpanding);
	caster=new QPixmap("casterminion.png");
		*caster=caster->scaled(45,45,Qt::KeepAspectRatioByExpanding);
	siege=new QPixmap("siegeminion.png");
		*siege=siege->scaled(65,65,Qt::KeepAspectRatioByExpanding);
	basic=new QPixmap("basicattack.gif");
		*basic=basic->scaled(10,10,Qt::KeepAspectRatioByExpanding);
	mystic=new QPixmap("basicattack.gif");
		*mystic=mystic->scaled(30,30,Qt::KeepAspectRatioByExpanding);
	trueshot=new QPixmap("trueshot.png");
		*trueshot=trueshot->scaled(75,75,Qt::KeepAspectRatioByExpanding);
	heal=new QPixmap("heal.png");
		*heal=heal->scaled(50,50,Qt::KeepAspectRatioByExpanding);
	clarity=new QPixmap("clarity.png");
		*clarity=clarity->scaled(50,50,Qt::KeepAspectRatioByExpanding);
	ignite=new QPixmap("ignite.png");
		*ignite=ignite->scaled(50,50,Qt::KeepAspectRatioByExpanding);
	energy=new QPixmap("energybolt.gif");
		*energy=energy->scaled(50,50,Qt::KeepAspectRatioByExpanding);
	cannon=new QPixmap("cannonshot.png");
		*cannon=cannon->scaled(55,55,Qt::KeepAspectRatioByExpanding);
	/** color is the default color set for spacers and background of widgets*/
	color.setRgb(240,240,240,255);
	/** MainWidget which holds everything */
	mainwidget= new QWidget;
	mainwidget->setFixedSize(1200,800);
	/** Main Layout for MainWindow */
	mainLayout = new QVBoxLayout;
	mainwidget->setLayout(mainLayout);
	  /** TITLE above row1*/
	  row0 = new QHBoxLayout;
	  	/** IconObject used to display QPixmap */
	    	hold_spacer0 = new IconObject;
	  	/** Used to hold a space */
	  	spacer0 = new QPixmap(100,64);
	  	spacer0->fill(color);
	  	/** IconObject used to display QPixmap */
	    	hold_title = new IconObject;
	    	/** Ability display icon */
	  	title = new QPixmap("title.png");
	  	/** IconObject used to display QPixmap */
	    	hold_spacer01 = new IconObject;
	  	/** Used to hold a space */
	  	spacer01 = new QPixmap(100,64);
	  	spacer01->fill(color);
	  	// set pixmaps
	  	hold_spacer0->setPixmap(*spacer0);
	  	hold_title->setPixmap(title->scaled(700,40,Qt::KeepAspectRatioByExpanding));
	  	hold_spacer0->setPixmap(*spacer01);
	  	//add to layout row0
	  	row0->addWidget(hold_spacer0);
	  	row0->addWidget(hold_title);
	  	row0->addWidget(hold_spacer01);
	  	mainLayout->addLayout(row0);
	  /** Horizontal box for row 1*/
	  row1= new QHBoxLayout;
	  	/** Button which initiates/restarts game*/
		start= new QPushButton("Start");
		/** Button which pauses/continues game*/
		pause = new QPushButton("Pause");
		/** quits the game*/
		quit = new QPushButton("Quit");
		/** Score display*/
		name = new QTextEdit("Name");
		name->setMaximumHeight(30);
		name->setMaximumWidth(200);
		/** level display*/
		level = new QLabel("LEVEL: 00");
		/** score display*/
		score = new QLabel("SCORE: 00");
	    row1->addWidget(start);
	    row1->addWidget(pause);
	    row1->addWidget(quit);
	    row1->addWidget(name);
	    row1->addWidget(level);
	    row1->addWidget(score);
	    mainLayout->addLayout(row1);
	  /** Horizontal box for row 2*/
	  row2 = new QHBoxLayout;
	  	/** Scene which holds monsters, player and powerups*/
	  	scene = new QGraphicsScene;
	  	/** View which holds gameplay*/
	  	view = new GameWindow(scene);
	    row2->addWidget(view);
	    mainLayout->addLayout(row2);
	  /** Horizontal box for row 3*/
	  row3 = new QHBoxLayout;
	    //left
	    	/** IconObject used to display QPixmap */
	    	hold_basicattackicon = new IconObject;
	    	/** Ability display icon */
	  	basicattackicon = new QPixmap("basicattack.gif");
	  	/** IconObject used to display QPixmap */
	    	hold_mysticshoticon = new IconObject;
	  	/** Ability display icon */
	  	mysticshoticon = new QPixmap("basicattack.gif");
	  	//mysticshoticon->scaledToHeight(64,Qt::FastTransformation);
	  	/** IconObject used to display QPixmap */
	    	hold_trueshoticon = new IconObject;
	  	/** Ability display icon */
	  	trueshoticon = new QPixmap("trueshot.png");
	  	/** IconObject used to display QPixmap */
	    	hold_spacer1 = new IconObject;
	  	/** Used to hold a space */
	  	spacer1 = new QPixmap(400,64);
	  	spacer1->fill(color);
	    //midleft
	    	/** IconObject used to display QPixmap */
	    	hold_heart = new IconObject;
	    	/** Heart Icon */
	    	heart = new QPixmap("heart.gif");
	    	/** Health display */
	    	health = new QLabel("200");
	    	health->setMaximumHeight(25);
	    	/** IconObject used to display QPixmap */
	    	hold_spacer2 = new IconObject;
	    	/** Used to hold a space */
	  	spacer2 = new QPixmap(64,64);
	  	spacer2->fill(color);
	    //midright
	    	/** IconObject used to display QPixmap */
	    	hold_potion = new IconObject;
	    	/** Mana Icon */
	    	potion = new QPixmap("mana.gif");
	    	/** Mana display */
	    	mana= new QLabel("50");
	    	mana->setMaximumHeight(25);
	    	
	    /*Add the Pixmaps to the IconObjects*/
	    hold_basicattackicon->setPixmap(basicattackicon->scaledToHeight(10));
	    hold_mysticshoticon->setPixmap(mysticshoticon->scaledToHeight(20));
	    hold_trueshoticon->setPixmap(trueshoticon->scaled(40,60,Qt::KeepAspectRatioByExpanding));
	    hold_spacer1->setPixmap(*spacer1);
	    hold_heart->setPixmap(*heart);
	    hold_spacer2->setPixmap(*spacer2);
	    hold_potion->setPixmap(*potion);
	    /* Add IconObjects to row3 */
	    row3->addWidget(hold_basicattackicon);
	    row3->addWidget(hold_mysticshoticon);
	    row3->addWidget(hold_trueshoticon);
	    row3->addWidget(hold_spacer1);
	    row3->addWidget(hold_heart);
	    row3->addWidget(health);
	    row3->addWidget(hold_spacer2);
	    row3->addWidget(hold_potion);
	    row3->addWidget(mana);
	    /* Add layout to main widget*/
	    mainLayout->addLayout(row3);
	    
	// set player
	  //objects.push_back(
	//set bool variables
	trueshotfiring = false;
	inGame = false;
	gamePaused = false;
	playerAlive = false;
	up = false;
	down = false;
	left = false;
	right = false;
	grabbedignite=false;
	lostgame=false;
	//set counters
	/** Level identifies which level the game is at */
	levelff=1;
	/** Leftclickcounter determines how many times left click is pressed */
	leftclickcounter=0;
	/** Leftclickholdcounter determines how long left click is pressed */
	leftclickholdcounter=0;
	/** Spawn counter for a meleeminoin */
	spawnmelee=0;
	/** Spawn counter for a Siegeminion*/
	spawnsiege=0;	
	/** Spawn counter for a Casterminion*/
	spawncaster=0;
	/** Ez can not be hurt immediately at next clock 
	  *giving the player time to move out of the way*/
	ezhurt=0;
	/** Points scored*/
	points=0;
	/** Icon spawning at 200*/
	iconspawn=0;
	
	// set timer
	timer = new QTimer(this);// timer->start(val) later on in show()
	//connections
	connect(start,SIGNAL(clicked()),this,SLOT(clickedStart()));
	connect(pause,SIGNAL(clicked()),this,SLOT(clickedPause()));
	connect(view,SIGNAL(leftButtonClicked()),this,SLOT(leftClick()));
	connect(view,SIGNAL(rightButtonClicked()),this,SLOT(rightClick()));
	connect(view,SIGNAL(leftButtonHoldStart()),this,SLOT(leftHoldstart()));
	connect(view,SIGNAL(leftButtonHoldCancel()),this,SLOT(leftHoldcancel()));
	connect(view,SIGNAL(uparrow()),this,SLOT(moveup()));
	connect(view,SIGNAL(downarrow()),this,SLOT(movedown()));
	connect(view,SIGNAL(leftarrow()),this,SLOT(moveleft()));
	connect(view,SIGNAL(rightarrow()),this,SLOT(moveright()));
	connect(timer,SIGNAL(timeout()),this,SLOT(handleTimer()));
	connect(quit,SIGNAL(clicked()),this,SLOT(clickedQuit()));
}
Example #19
0
void up(struct Block**grid){
    moveup(grid[0]);
    moveup(grid[1]);
    moveup(grid[2]);
    moveup(grid[3]);
}