⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e_canvas.c

📁 凌阳32位单片机开发的小游戏
💻 C
字号:
/******************************************************************************
 *
 *     The information contained herein is the exclusive property of
 *   Sunplus Technology Co. And shall not be distributed, reproduced,
 *   or disclosed in whole in part without prior written permission.
 *
 *         (C) COPYRIGHT 2005   SUNPLUS TECHNOLOGY CO.
 *                        ALL RIGHTS RESERVED
 *
 * The entire notice above must be reproduced on all authorized copies.
 *
 *****************************************************************************/

/******************************************************************************
 *  Filename:   	E_Canvas.c
 *  Author:     	Robin.xjliu  (eMail: xjliu@sunplus.com)
 *  Tel:        	00885-028-87848688-5884
 *  Date:       	2005-11-21
 *  Description:	texture control
 *  Reference:
 *  Version history:
 *-----------------------------------------------------------------------------
 *	Version   YYYY-MM-DD-INDEX   Modified By         Description
 *	1.0.0     2005-11-21           xjliu               Create
 *
 *****************************************************************************/
#include "Include/E_Canvas.h"

S16	iTextCount_Y[3] = {0,0,0};

extern MOTION *pPlayer;
extern bool	g_bMoveFlag_X;
extern bool	g_bMoveFlag_Y;
extern U8	g_nScreenStep_X;
extern U8	g_nScreenStep_Y;

/**
 * E_HScroll
 */
void E_HScroll(U16 nText, U16 nStep, U8 nDirection)
{
	//U16 temp;

	g_bTextScrollFlag = true;
	if (nDirection)
	{//right
		if ( (g_aTextPos_X[nText] + nStep) > (SCREENBUFF_WIDTH - SCREEN_WIDTH) 
			&& nText == TEXT2)
		{
			pPlayer->pSprite->stPos.x += (g_aTextPos_X[nText] + nStep - (SCREENBUFF_WIDTH - SCREEN_WIDTH));
			//g_nScreenStep_X -= (g_aTextPos_X[nText] + nStep - (SCREENBUFF_WIDTH - SCREEN_WIDTH));//add by xjliu for sprite move
			g_bMoveFlag_X = false;//add by xjliu for sprite move
			nStep = (SCREENBUFF_WIDTH - SCREEN_WIDTH) - g_aTextPos_X[nText];
		}
		g_aTextPos_X[nText] = (g_aTextPos_X[nText] + nStep);// & 0x000003FF;
	}
	else
	{//left
		if ( g_aTextPos_X[nText] - nStep < 0 && nText == TEXT2 )
		{
			//temp = (nStep - g_aTextPos_X[nText]);
			pPlayer->pSprite->stPos.x -= (nStep - g_aTextPos_X[nText]);//(nStep - g_aTextPos_X[nText]);
			//g_nScreenStep_X -= temp;//add by xjliu for sprite move
			g_bMoveFlag_X = false;//add by xjliu for sprite move
			nStep = g_aTextPos_X[nText];
		}
		g_aTextPos_X[nText] = (g_aTextPos_X[nText] - nStep);// & 0x000003FF;
	}
}

/**
 * E_VScroll
 */
void E_VScroll(U16 nText, U16 nStep, U8 nDirection)
{
	g_bTextScrollFlag = true;
	if (nDirection)
	{//down
		g_aTextPos_Y[nText] = (g_aTextPos_Y[nText] + nStep);
		iTextCount_Y[nText] += nStep;	//add by xjliu for vertical scroll
		if ( g_aTextPos_Y[nText] & (~((S32)pAniText[nText]->cySize - 1)) )
		{//g_aTextPos_Y > pAniTextTemp->cySize
			if (iTextCount_Y[nText] > START_Y - 1 && nText == TEXT2)
			{
				pPlayer->pSprite->stPos.y += iTextCount_Y[nText] - (START_Y - 1);
				//g_nScreenStep_Y -= iTextCount_Y[nText] - (START_Y - 1);//add by xjliu for Sprite move
				g_bMoveFlag_Y = false;//add by xjliu for sprite move
				g_aTextPos_Y[nText] = pAniText[nText]->cySize - 1;
				iTextCount_Y[nText] = START_Y - 1;
				return;
			}
			g_aPNTPtrFlag[nText]	|= 0x03;//flag = 1, ptr add
			g_aTextPos_Y[nText]		&= (S32)pAniText[nText]->cySize - 1;
		}
	}
	else
	{//up
		g_aTextPos_Y[nText] = (g_aTextPos_Y[nText] - nStep);
		iTextCount_Y[nText] -= nStep;
		if ( g_aTextPos_Y[nText] & (~((S32)pAniText[nText]->cySize - 1)) )
		{//g_aTextPos_Y < 0
			if (iTextCount_Y[nText] < -(START_Y - 1) && nText == TEXT2)
			{
				pPlayer->pSprite->stPos.y -= (-(START_Y - 1)) - iTextCount_Y[nText];
				//g_nScreenStep_Y -= (-(START_Y - 1)) - iTextCount_Y[nText];//add by xjliu for Sprite move
				g_bMoveFlag_Y = false;//add by xjliu for sprite move
				g_aTextPos_Y[nText] = 0;
				iTextCount_Y[nText] = -(START_Y - 1);
				return;
			}
			g_aPNTPtrFlag[nText]	|= 0x01;//flag = 1, ptr sub
			g_aTextPos_Y[nText]		&= (S32)pAniText[nText]->cySize - 1;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -