예제 #1
0
void right(struct Block**grid){
    moveright(grid[3]);
    moveright(grid[7]);
    moveright(grid[11]);
    moveright(grid[15]);
}
예제 #2
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;
        }

    }

    /* ================================================== */
}
예제 #3
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()));
}
예제 #4
0
boolean mergehandles (Handle h1, Handle h2, Handle *hmerged) {

    /*
    create a new handle which is the concatenation of two handles.  the first
    four bytes of the new handle store the size of the first handle so the merged
    handle can be easily unpacked.

    6/8/90 DW: modified so it could deal with nil handles.

    10/7/91 dmb: try to merge result into the larger of the original handles, so
    that our memory overhead can be almost cut in half.

    2.1b3 dmb: in the unusual case the we allocated a new handle, go ahead
    and use temporary memory if available. this might not always be ideal, but
    more often than not it will be best -- we're likely Saving, and tossing
    the merged handle soon.
    */

    register Handle h;
    long sizefirsthandle;
    long sizesecondhandle;
    long sizemergedhandle;
    long storesizefirsthandle;
    register ptrbyte p;

    *hmerged = nil; /*default return value*/

    sizefirsthandle = gethandlesize (h1);
    storesizefirsthandle = conditionallongswap (sizefirsthandle);

    sizesecondhandle = gethandlesize (h2);

    sizemergedhandle = sizeof (long) + sizefirsthandle + sizesecondhandle;

    if (sizefirsthandle > sizesecondhandle) { /*try using h1 for result*/

        if (resizehandle (h1, sizemergedhandle)) {

            p = (ptrbyte) *h1;

            moveright (p, p + sizeof (long), sizefirsthandle);

            moveleft (&storesizefirsthandle, p, sizeof (long));

            if (h2 != nil)
                moveleft (*h2, p + sizeof (long) + sizefirsthandle, sizesecondhandle);

            *hmerged = h1;

            disposehandle (h2);

            return (true);
        }
    }

    else if (h2 != nil) { /*try using h2 for result*/

        if (resizehandle (h2, sizemergedhandle)) {

            p = (ptrbyte) *h2;

            moveright (p, p + sizeof (long) + sizefirsthandle, sizesecondhandle);

            moveleft (&storesizefirsthandle, p, sizeof (long));

            if (h1 != nil)
                moveleft (*h1, p + sizeof (long), sizefirsthandle);

            *hmerged = h2;

            disposehandle (h1);

            return (true);
        }
    }

    /*resizing didn't work; try it the old way, using a newly-allocated handle*/

    h = getnewhandle (sizemergedhandle, true);

    if (h == nil) {

        memoryerror ();

        disposehandle (h1);

        disposehandle (h2);

        return (false);
    }

    p = (ptrbyte) *h;

    moveleft (&storesizefirsthandle, p, sizeof (long));

    p += sizeof (long);

    if (h1 != nil)
        moveleft (*h1, p, sizefirsthandle);

    if (h2 != nil)
        moveleft (*h2, p + sizefirsthandle, sizesecondhandle);

    *hmerged = h;

    disposehandle (h1);

    disposehandle (h2);

    return (true);
} /*mergehandles*/
예제 #5
0
파일: find.c 프로젝트: 8l/FUZIX
char * PROC makepat(char *string, char delim)
/* make up the pattern string for find	-- ripped from 'Software Tools' */
{
    register char *cp;
    register char *oldcp;
    char *start = string;
    int inarg = FALSE;

    for(arg=0;arg<9;++arg)
	RE_start[arg] = RE_size[arg] = (-1);
    arg = 0;
    p = pattern;
    
    while ((*string != delim) && (*string != 0)) {
	oldcp = cp;
	cp = p;
	
	if (!magic)		/* kludge for nonmagical patterns */
	    goto normal;
	if (*string == ANY)
	    concatch(ANY);
	else if ((*string == LSTART) && (string == start))
	    concatch(LSTART);
	else if ((*string == LEND) && (string[1] == delim || string[1] == 0))
	    concatch(LEND);
	else if (*string == CCL)
	    string = badccl(1+string);
	else if ((*string == CLOSURE) && (p > pattern)) {
	    cp = oldcp;
	    if (strchr(badclose, *cp) || p >= &pattern[MAXPAT-1])
		return NULL;
	    moveright(cp,1+cp,(int)(p-cp));
	    *cp = CLOSURE;
	    p++;
	}
	else if (*string == ESCAPE) {
	    if (string[1] == ARGSTART || string[1] == ARGEND) {
		if (string[1] == ARGEND)
		    if (!inarg)
			goto normal;
		if (string[1] == ARGSTART) {
		    if (inarg)
			goto normal;
		    if (++arg > 9)
			return NULL;
		}
		inarg = !inarg;
	    }
	    else if (string[1] != TOKENB && string[1] != TOKENE)
		goto normal;
	    ++string;
	    concatch(*string);
	}
	else {
     normal:concatch(LITCHAR);
	    concatch(esc(&string));
	}
	if (*string)
	    string++;
    }
    if (inarg)
	concatch(ARGEND);
    if (p > pattern) {		/* new pattern was created */
	strncpy(lastpatt,start,(int)(string-start));
	lastpatt[string-start] = 0;
	concatch(0);
	if (p-pattern >= MAXPAT)
	    return NULL;
    }
    return (*string == delim)?(string+1):(string);
}
예제 #6
0
파일: input.c 프로젝트: gsrr/Python
int processkey_ingame(int key, int flags)
{
	static int discard_count;
	struct player *plr;
	int i = TWOPLAYER_MODE && key & PLAYER_2;
	int safe;
	switch (key & 0x7F) {
	case ESC:
	case '\b':
		game->state = 0;
		return -2;
	case 'q':
		exit(0);
	case STARTBTN:
	case 'p':
		if (flags & NO_PAUSE || !game_running || TWOPLAYER_MODE)
			break;
		i = pausegame();
		textgfx_flags &= ~LOST_FOCUS;
		return i;
	}
	if (flags & DISCARD_MOVES) {
		if (++discard_count > 5)
			kb_flushinp();
		return -1;
	}
	discard_count = 0;
	plr = game->player+i;
	safe = dropsafe(i);
	key &= 0x7F;
	if (!(flags & DISCARD_DROPS)) {
		switch (key) {
		case HARDDROP:
			if (socket_fd > -1 && !i) {
				sock_sendpiece(plr);
				if (harddrop(plr, safe) == -1)
					return -1;
				sock_sendbyte(HARDDROP);
				return 0;
			}
			return harddrop(plr, safe);
		case MVDOWN:
			if (!TWOPLAYER_MODE)
				return softdrop(softdrop_speed, safe);
			if (!movedown(plr, 1))
				return 0;
			if (socket_fd > -1 && !i)
				sock_sendbyte(MVDOWN);
			return 1;
		}
	}
	switch (key) {
	case MVLEFT:
		moveleft(plr);
		break;
	case MVRIGHT:
		moveright(plr);
		break;
	case MVUP:
		rotate(plr, plr->rotationsys & ROT_CLOCKWISE);
		break;
	case A_BTN:
		rotate(plr, 1);
		break;
	case B_BTN:
		rotate(plr, 0);
		break;
	default:
		return -1;
	}
	if (socket_fd > -1 && !i)
		sock_sendbyte(key);
	upd_screen(1+i);
	return 1;
}
예제 #7
0
void Hero::onlogic()
{
	
	if(ifire == true)
	{
		procfire();
		return;
	}
	
	hlogic();

	// synchonized logic, based on 'speed' of the hero
	speedc++;
	
	if(speedc > speed)
	{
		speedc = 0;
		// first check for keys then joystick
		
		if(mxhwnd.KeyCheck(DIK_LEFT))
		{
			moveleft();
		}
		
		if(mxhwnd.KeyCheck(DIK_RIGHT))
		{
			moveright();
		}
		
		if(mxhwnd.KeyCheck(DIK_A))
		{
			jump();
		}

		if(mxhwnd.KeyCheck(DIK_S))
		{
			fire();
		}
		
		/*if(player.joystick == true)
		{
			MasterJoyStick* stick = getstick();
			if(stick->JoyLeft())
			{
				moveleft();
			}
			if(stick->JoyRight())
			{
				moveright();
			}
			int b;
			b = stick->JoyButtonDown();
			switch(b)
			{
			case 0:
				jump();
				break;
			case 1:
				fire();
				break;
			}
		}*/
	}
	
	
}