Beispiel #1
0
void Game::DBZLoop()
{
	float toMove;
	if (!g_pInput->m_Touched && g_pInput->m_PrevTouched)
	{
		toMove = (float)(ScreenHeight / 100);
		g_pInput->Reset();
	}
	else
	{
		toMove = -((float)ScreenHeight / 1500);
	}

	OutputLine(toMove);
	projectiles[PLAYER_ONE].at(0)->m_Y += toMove;
	ResizeLine(projectileLines[PLAYER_ONE].at(0), PLAYER_ONE, projectiles[PLAYER_ONE].back()->m_Y);

	projectiles[PLAYER_TWO].at(0)->m_Y = projectiles[PLAYER_ONE].at(0)->m_Y;
	ResizeLine(projectileLines[PLAYER_TWO].at(0), PLAYER_TWO, projectiles[PLAYER_TWO].back()->m_Y);

	if(toMove > 0)
	{
		if (player[PLAYER_TWO]->HitTest(projectiles[PLAYER_TWO].at(0)->m_X + 20, projectiles[PLAYER_TWO].at(0)->m_Y + projectiles[PLAYER_TWO].at(0)->getWidth()))
		{
			DBZWin(PLAYER_TWO);
		}
	}
	else
	{
		if (player[PLAYER_ONE]->HitTest(projectiles[PLAYER_ONE].at(0)->m_X + 20, projectiles[PLAYER_ONE].at(0)->m_Y - projectiles[PLAYER_ONE].at(0)->getWidth()))
		{
			DBZWin(PLAYER_ONE);
		}
	}
}
Beispiel #2
0
void Game::InitialiseHadoken(CSprite* previous, bool isAI)
{
	Hadoken* temp = new Hadoken();
	temp->m_X = previous->m_X;
	temp->m_Y = previous->m_Y;
	temp->SetImage(g_pResources->getSettingsButton());
	temp->m_AnchorX = previous->m_AnchorX;
	temp->m_AnchorY = previous->m_AnchorY;
	// Fit player to Device size
	temp->m_ScaleX = (float)(ScreenWidth / 8) / temp->GetImage()->GetWidth();
	temp->m_ScaleY = temp->m_ScaleX;
	temp->setWidth(ScreenWidth / 8);
	projectiles[isAI].push_back(temp);

	CSprite* tempLine = new CSprite();
	tempLine->m_X = player[isAI]->m_X + (temp->getWidth() / 2);
	tempLine->m_Y = player[isAI]->m_Y;
	tempLine->m_AnchorX = 0.5;
	tempLine->m_AnchorY = (float)(isAI); /*1.0 for AI, 0.0 fir player*/
	tempLine->SetImage(g_pResources->getGreenImage());
	tempLine->m_ScaleX = (float)(ScreenWidth / 50) / lifeBars[isAI]->GetImage()->GetWidth();

	projectileLines[isAI].push_back(tempLine);
	AddChild(projectileLines[isAI].back());

	ResizeLine(tempLine, isAI, projectiles[isAI].back()->m_Y);

	//we add teh hadoken after to remove overlap
	AddChild(projectiles[isAI].back());
}
Beispiel #3
0
void Game::NormalGameLoop()
{
	//check if the player's charcter is moving (We do not allow any movement on top of animation)
	if (!(player[PLAYER_ONE]->getAnimActiv()))
	{
		CheckResetAnimation(PLAYER_ONE);
		//check if there was previously an animation that has not been restored

		//check for finger down
		if (g_pInput->m_Touched && !g_pInput->m_PrevTouched)
		{
			if (CheckButtons())
			{
				touchCounter = 0;
				CheckInputEvents(player[PLAYER_ONE]->getPrevMovement());
			}

			if (player[PLAYER_ONE]->getPrevMovement() == 4)
			{
				MakeHadoken(false);
			}
		}

		//check for hold
		else if (g_pInput->m_Touched && g_pInput->m_PrevTouched)
		{
			if (CheckButtonsStillTouched())
			{
				if (player[PLAYER_ONE]->getPrevMovement() == 4)
				{
					//resize square
					if (projectileLines[PLAYER_ONE].size() > 0)
					{
						ResizeLine(projectileLines[PLAYER_ONE].back(), PLAYER_ONE, projectiles[PLAYER_ONE].back()->m_Y);
					}
				}
				else if (touchCounter < DASH_LIMIT)
				{
					touchCounter++;
				}
				CheckInputEvents(player[PLAYER_ONE]->getPrevMovement());
			}
		}

		//check for finger up
		else if (!g_pInput->m_Touched && g_pInput->m_PrevTouched)
		{
			FingerUp();
		}

		//set the previous state to the current state
		//this is done explicitly as this was removed from Input->Update() for optimisation
		g_pInput->m_PrevTouched = g_pInput->m_Touched;

	}
	else if (player[PLAYER_ONE]->getAttacking()) //else you are punching or kicking check if the player two gets hit. :)
	{
		Collision(PLAYER_TWO, 20, pushBack);
	}

	if (!(player[PLAYER_TWO]->getAnimActiv()))
	{
		CheckResetAnimation(PLAYER_TWO);
		//This is where the code for AI goes.

		if (player[PLAYER_TWO]->getPrevMovement() == 4)
		{
			if (projectiles[PLAYER_TWO].size() == 0)
			{
				player[PLAYER_TWO]->setPrevMovement(-1);
			}
		}
		else
		{
			CheckAINextMove();
		}
	}
	else if (player[PLAYER_TWO]->getAttacking())
	{
		Collision(PLAYER_ONE, -20, -pushBack);
	}

	bool exploded = HadokenOnHadoken();


	if (!exploded)
	{
		CheckProjectiles(PLAYER_ONE);
		CheckProjectiles(PLAYER_TWO);
	}
}
Beispiel #4
0
/******************************************************************************
* Interpret the command line and scan the given GIF file.		      *
******************************************************************************/
int main(int argc, char **argv)
{
    int	i, iy, last_iy, l, t, w, h, Error, NumFiles, ExtCode,
	ImageNum = 0,
	SizeFlag = FALSE,
	ScaleFlag = FALSE,
	XScaleFlag = FALSE,
	YScaleFlag = FALSE,
	HelpFlag = FALSE;
    double Scale, y;
    GifRecordType RecordType;
    char s[80];
    GifByteType *Extension;
    GifRowType LineIn, LineOut;
    char **FileName = NULL;
    GifFileType *GifFileIn = NULL, *GifFileOut = NULL;

    if ((Error = GAGetArgs(argc, argv, CtrlStr,
		&GifQuietPrint, &SizeFlag, &XSize, &YSize, &ScaleFlag, &Scale,
		&XScaleFlag, &XScale, &YScaleFlag, &YScale,
		&HelpFlag, &NumFiles, &FileName)) != FALSE ||
		(NumFiles > 1 && !HelpFlag)) {
	if (Error)
	    GAPrintErrMsg(Error);
	else if (NumFiles > 1)
	    GIF_MESSAGE("Error in command line parsing - one GIF file please.");
	GAPrintHowTo(CtrlStr);
	exit(EXIT_FAILURE);
    }

    if (HelpFlag) {
	fprintf(stderr, VersionStr);
	GAPrintHowTo(CtrlStr);
	exit(EXIT_SUCCESS);
    }

    /* If specific direction was set, set other direction to 1: */
    if (!XScaleFlag && YScaleFlag) XScale = 1.0;
    if (!YScaleFlag && XScaleFlag) YScale = 1.0;

    /* If the specific direction was not set, but global one did use it: */
    if (!XScaleFlag && ScaleFlag) XScale = Scale;
    if (!YScaleFlag && ScaleFlag) YScale = Scale;

    if (XScale > MAX_SCALE) {
	sprintf(s, "XScale too big, maximum scale selected instead (%f).",
								MAX_SCALE);
	GIF_MESSAGE(s);
	XScale = MAX_SCALE;
    }
    if (YScale > MAX_SCALE) {
	sprintf(s, "YScale too big, maximum scale selected instead (%f).",
								MAX_SCALE);
	GIF_MESSAGE(s);
	YScale = MAX_SCALE;
    }

    if (NumFiles == 1) {
	if ((GifFileIn = DGifOpenFileName(*FileName)) == NULL)
	    QuitGifError(GifFileIn, GifFileOut);
    }
    else {
	/* Use the stdin instead: */
	if ((GifFileIn = DGifOpenFileHandle(0)) == NULL)
	    QuitGifError(GifFileIn, GifFileOut);
    }
    BackGroundColor = GifFileIn->SBackGroundColor;

    /* If size was specified, it is used to derive the scale: */
    if (SizeFlag) {
	XScale = XSize / ((double) GifFileIn->SWidth);
	YScale = YSize / ((double) GifFileIn->SHeight);
    }
    else
    {
	XSize = (int) (GifFileIn->SWidth * XScale + 0.5);
	YSize = (int) (GifFileIn->SHeight * YScale + 0.5);
    }

    /* As at this time we know the Screen size of the input gif file, and as */
    /* all image(s) in file must be less/equal to it, we can allocate the    */
    /* scan lines for the input file, and output file. The number of lines   */
    /* to allocate for each is set by ScaleDown & XScale & YScale:	     */
    LineOut = (GifRowType) malloc(XSize * sizeof(GifPixelType));
    LineIn = (GifRowType) malloc(GifFileIn->SWidth * sizeof(GifPixelType));

    /* Open stdout for the output file: */
    if ((GifFileOut = EGifOpenFileHandle(1)) == NULL)
	QuitGifError(GifFileIn, GifFileOut);

    /* And dump out its new scaled screen information: */
    if (EGifPutScreenDesc(GifFileOut, XSize, YSize,
	GifFileIn->SColorResolution, GifFileIn->SBackGroundColor,
	GifFileIn->SColorMap) == GIF_ERROR)
	QuitGifError(GifFileIn, GifFileOut);

    /* Scan the content of the GIF file and load the image(s) in: */
    do {
	if (DGifGetRecordType(GifFileIn, &RecordType) == GIF_ERROR)
	    QuitGifError(GifFileIn, GifFileOut);

	switch (RecordType) {
	    case IMAGE_DESC_RECORD_TYPE:
		if (DGifGetImageDesc(GifFileIn) == GIF_ERROR)
		    QuitGifError(GifFileIn, GifFileOut);
		/* Put the image descriptor to out file: */
		l = (int) (GifFileIn->Image.Left * XScale + 0.5);
		w = (int) (GifFileIn->Image.Width * XScale + 0.5);
		t = (int) (GifFileIn->Image.Top * YScale + 0.5);
		h = (int) (GifFileIn->Image.Height * YScale + 0.5);
		if (l < 0) l = 0;
		if (t < 0) t = 0;
		if (l + w > XSize) w = XSize - l;
		if (t + h > YSize) h = YSize - t;

		if (EGifPutImageDesc(GifFileOut, l, t, w, h,
		    GifFileIn->Image.Interlace,
		    GifFileIn->Image.ColorMap) == GIF_ERROR)
		    QuitGifError(GifFileIn, GifFileOut);

		if (GifFileIn->Image.Interlace) {
		    GIF_EXIT("Cannt resize interlaced images - use GifInter first.");
		}
		else {
		    GifQprintf("\n%s: Image %d at (%d, %d) [%dx%d]:     ",
			PROGRAM_NAME, ++ImageNum,
			GifFileOut->Image.Left, GifFileOut->Image.Top,
			GifFileOut->Image.Width, GifFileOut->Image.Height);

		    for (i = GifFileIn->Image.Height, y = 0.0, last_iy = -1;
			 i-- > 0;
			 y += YScale) {
			if (DGifGetLine(GifFileIn, LineIn,
					GifFileIn->Image.Width) == GIF_ERROR)
			    QuitGifError(GifFileIn, GifFileOut);

			iy = (int) y;
			if (last_iy < iy && last_iy < YSize) {
			    ResizeLine(LineIn, LineOut,
				       GifFileIn->Image.Width, GifFileOut->Image.Width);

			    for (;
				 last_iy < iy && last_iy < GifFileOut->Image.Height - 1;
				 last_iy++) {
				GifQprintf("\b\b\b\b%-4d", last_iy + 1);
				if (EGifPutLine(GifFileOut, LineOut,
						GifFileOut->Image.Width) ==
								    GIF_ERROR)
				    QuitGifError(GifFileIn, GifFileOut);
			    }
			}
		    }

		    /* If scale is not dividable - dump last lines: */
		    while (++last_iy < GifFileOut->Image.Height) {
			GifQprintf("\b\b\b\b%-4d", last_iy);
			if (EGifPutLine(GifFileOut, LineOut,
					GifFileOut->Image.Width) == GIF_ERROR)
			    QuitGifError(GifFileIn, GifFileOut);
		    }
		}
		break;
	    case EXTENSION_RECORD_TYPE:
		/* Skip any extension blocks in file: */
		if (DGifGetExtension(GifFileIn, &ExtCode, &Extension) == GIF_ERROR)
		    QuitGifError(GifFileIn, GifFileOut);
		if (EGifPutExtension(GifFileOut, ExtCode, Extension[0],
							Extension) == GIF_ERROR)
		    QuitGifError(GifFileIn, GifFileOut);

		/* No support to more than one extension blocks, so discard: */
		while (Extension != NULL) {
		    if (DGifGetExtensionNext(GifFileIn, &Extension) == GIF_ERROR)
			QuitGifError(GifFileIn, GifFileOut);
		}
		break;
	    case TERMINATE_RECORD_TYPE:
		break;
	    default:		    /* Should be traps by DGifGetRecordType. */
		break;
	}
    }
    while (RecordType != TERMINATE_RECORD_TYPE);

    if (DGifCloseFile(GifFileIn) == GIF_ERROR)
	QuitGifError(GifFileIn, GifFileOut);
    if (EGifCloseFile(GifFileOut) == GIF_ERROR)
	QuitGifError(GifFileIn, GifFileOut);

    free(LineOut);
    free(LineIn);

    return 0;
}