Exemple #1
0
void Drawable2D::SetSpriteAttr(ResourceRef value)
{
    // Delay applying material update
    materialUpdatePending_ = true;

    ResourceCache* cache = GetSubsystem<ResourceCache>();

    if (value.type_ == Sprite2D::GetTypeStatic())
    {
        SetSprite(cache->GetResource<Sprite2D>(value.name_));
        return;
    }

    if (value.type_ == SpriteSheet2D::GetTypeStatic())
    {
        // value.name_ include sprite speet name and sprite name.
        Vector<String> names = value.name_.Split('@');
        if (names.Size() != 2)
            return;

        const String& spriteSheetName = names[0];
        const String& spriteName = names[1];

        SpriteSheet2D* spriteSheet = cache->GetResource<SpriteSheet2D>(spriteSheetName);
        if (!spriteSheet)
            return;

        SetSprite(spriteSheet->GetSprite(spriteName));
    }
}
void ContainerItemButton::setItem(Item* item)
{
	edit_item = item;
	if(edit_item)
		SetSprite(edit_item->getClientID());
	else
		SetSprite(0);
}
Exemple #3
0
void DrawMetaSprite(int16_t x, int16_t y, uint8_t f){

	uint8_t foff = f*4;
	SetSprite(x+0,y+0,pgm_read_byte(&sprite_frame_table[foff]),pgm_read_byte(&sprite_mirror_table[foff++]));
	SetSprite(x+8,y+0,pgm_read_byte(&sprite_frame_table[foff]),pgm_read_byte(&sprite_mirror_table[foff++]));
	SetSprite(x+0,y+8,pgm_read_byte(&sprite_frame_table[foff]),pgm_read_byte(&sprite_mirror_table[foff++]));
	SetSprite(x+8,y+8,pgm_read_byte(&sprite_frame_table[foff]),pgm_read_byte(&sprite_mirror_table[foff]));
}
Exemple #4
0
// Animates movement //
void Player::Animate() 
{
	if(state == 3)
		SetSprite(shipMove[1]);
	else if(state == 4)
		SetSprite(shipMove[2]);
	else
		SetSprite(shipMove[0]);
}
Exemple #5
0
void ButtonActor::setPressed(bool pressed){
	ClearSpriteInfo();
	if(pressed)
	{
		SetSprite(m_path +"on.png");
		m_countup=0;
	}
	else
		SetSprite(m_path +"off.png");
	m_pressed=pressed;
	
}
void TextGameObject::PrepareSprite()
{
    if(textBlock->IsSpriteReady())
    {
        if(GetSprite() != textBlock->GetSprite()) 
        {
            SetSprite(textBlock->GetSprite());
        }
    }
    else 
    {
        SetSprite(NULL);
    }
}
Exemple #7
0
void DoorActor::setLocked(const bool locked)
{
    if((locked) && (m_collFlags.damage==0))
	{
		SetSprite(m_spritePath +"off.png");
        m_mask=m_closed;
	}
	if(!locked)
	{
		SetSprite(m_spritePath +"on.png");
        m_mask=m_open;
	}
	m_locked=locked;
}
Exemple #8
0
Snake::Snake(Grid* grid) :
    m_grid(grid),
    m_direction(DirectionUp),
    m_inputBufferMaxSize(3),
    m_movespeed(10.f),
    m_numConsumed(0),
    m_isStopped(false),
    m_pointMultiplicator(1),
    m_isInvulnerable(false)
{
    const float kVerticesPerPixelX = theCamera.GetWorldMaxVertex().X * 2 / theCamera.GetWindowWidth();
    const float kVerticesPerPixelY = theCamera.GetWorldMaxVertex().Y * 2 / theCamera.GetWindowHeight();
    
    SetSize(Vector2(32 * kVerticesPerPixelX, 32 * kVerticesPerPixelY));
    SetPosition(0, 0);
    SetSprite(getSnakeHeadPath(false));
    
    Vector2 offset(0, -m_grid->GetUnitSize().Y);
    Actor* t = addTailPiece(offset*3.f);
    t = addTailPiece(offset*2.f);
    t = addTailPiece(offset);
    
	theSwitchboard.SubscribeTo(this, "GridCollision");
    theSwitchboard.SubscribeTo(this, "FoodConsumed");
    theSwitchboard.SubscribeTo(this, "MoveUp");
    theSwitchboard.SubscribeTo(this, "MoveDown");
    theSwitchboard.SubscribeTo(this, "MoveLeft");
    theSwitchboard.SubscribeTo(this, "MoveRight");
}
Exemple #9
0
void
Snake::Consume(Consumable* consumable)
{
    m_biteTimer = 0;
    SetSprite(getSnakeHeadPath(true));
    consumable->performConsumption(this);
}
Asteroid::Asteroid(int x, int y, SDL_Surface *sprite, Player *p) {
	GameObject();

	m_posX = x;
	m_posY = y;

	m_velX = 1;
	m_velY = 0;

	m_dirX = -1;
	m_dirY = 0;

	m_boundX = 35;
	m_boundY = 35;

	m_curFrame = 0;
	m_frameWidth = 64;
	m_frameHeight = 64;

	m_frameCount = 0;
	m_frameDelay = 3;

	m_maxFrame = 64;
	m_animationColumns = 8;
	m_animationRow = 0;
	m_animationDirection = 1;

	SetSprite(sprite);
	SetID(ENEMY);
	Asteroid::p=p;
}
ProjectileNinjaStar::ProjectileNinjaStar(bool bDirection, int xPos, int yPos)
{
	/* Set Sprite Number */
	SetSprite(1, CR::AssetList::ninja_star);


	/* Set Sprite Direction */
	SetDirection(bDirection);

	/* Set Weapon Bounding Box */
	SetWeaponBounds(16,16);

	/* Set Activate & Delay Timer */
	SetActiveTime(4);
	SetDelayTime(.25);

	/* Set Velocity Direction */
	if(bDirection) SetVelocityVector(80, 0);
	else SetVelocityVector(-80, 0);

	/* Set Start Position */
	SetPosition(xPos, yPos);

	/* Set Damage Value */
	SetWeaponDamage(2);	
	
	/* Initialize Sprite */
	SetAnimation(0, 0, true, false, 30, true);
	projectile_spr->EnableFrameSkip(false);
}
ProjectilePrisonerRock::ProjectilePrisonerRock(bool bDirection, int xPos, int yPos)
{
	/* Set Sprite Number */
	SetSprite(1, CR::AssetList::prisoner_rock);

	/* Set Sprite Direction */
	SetDirection(bDirection);

	/* Set Weapon Bounding Box */
	SetWeaponBounds(12,12);

	/* Set Activate & Delay Timer */
	SetActiveTime(3);
	SetDelayTime(.25);

	/* Set Velocity Direction */	
	if(bDirection) SetVelocityVector((float)(rand()%50+75), 0);
	else SetVelocityVector((float)(-(rand()%50+75)), 0);

	/* Set Acceleration Vector */
	SetAccelerationVector(0, (float)(rand()%75 + 65));
	
	/* Set Start Position */
	SetPosition(xPos, yPos);

	/* Set Damage Value */
	SetWeaponDamage(5);

	proj_flags.S_NON_PROJECTILE = true;

	/* Initialize Sprite */
	SetAnimation(0, 0, true, false, 10, true);
}
static void SpriteInit(bool EnabledBlend,u16 alpha)
{
  if(EnabledBlend==false) alpha=15;
  
  initSprites();
  updateOAM(12);
  
  s32 spx[12],spy[12];
  
  spx[ 0]=0; spy[ 0]=0;
  spx[ 1]=1; spy[ 1]=0;
  spx[ 2]=2; spy[ 2]=0;
  spx[ 3]=3; spy[ 3]=0;
  spx[ 4]=0; spy[ 4]=1;
  spx[ 5]=1; spy[ 5]=1;
  spx[ 6]=2; spy[ 6]=1;
  spx[ 7]=3; spy[ 7]=1;
  spx[ 8]=0; spy[ 8]=2;
  spx[ 9]=1; spy[ 9]=2;
  spx[10]=2; spy[10]=2;
  spx[11]=3; spy[11]=2;
  
  for(u32 idx=0;idx<12;idx++){
    SetSprite(idx,1,(8*8)+(8*spx[idx])+((8*8*4)*spy[idx]),alpha);
    
    s32 px=spx[idx]*64;
    s32 py=spy[idx]*64;
    
    SetPosSprite(idx,(s32)px,(s32)py,EnabledBlend);
  }
  
  updateOAM(12);
}
AtmosTool::AtmosTool(size_t id) : Item(id)
{
    SetSprite("icons/device.dmi");
    SetState("atmos");
    //SetState("cutters");
    name = "Atmos tool";
}
Exemple #15
0
EffectEnemyDead01::EffectEnemyDead01() : GameObject(TEXTURE_EFF_00)
{
	m_maxLifeTime   = 10;
	RECT srcRect;
	SetRect(&srcRect,0, 0, 32, 32);
	SetSprite(srcRect, 1,0, 32, 32, false);
}
//--------------------------------------------------------------------------------------
//Enemy_01_02
//--------------------------------------------------------------------------------------
Enemy_01_02::Enemy_01_02(D3DXVECTOR2 &position, int actionMode, int startShootFrame) :Enemy(TEXTURE_STG1ENM)
{
	m_position			= position;
	m_startShootFrame	= startShootFrame;
	m_shootInterval		= 10;
	m_maxShootCount		= 2;
	m_shootLoopFrame	= 0;

	m_actionMode	= actionMode;
	m_name			= "red elf";
//	m_v				= 2;
	RECT rect ;
	SetRect(&rect, 0, 32, 256, 64);
	SetSprite(rect, 8, 8, 32, 32);
	switch(m_actionMode)
	{
	case 1:
		motionInfos.push_back(new MotionInfo(0, new LineTrack(D3DXVECTOR2(0, 1), 2, 0, 0, NULL_POSITION), true));
		motionInfos.push_back(new MotionInfo(30, new LineTrack(D3DXVECTOR2(0, 1), 0, 0, 30, NULL_POSITION), true));
		motionInfos.push_back(new MotionInfo(40, new CircleTrack(D3DX_PI * 0.5, 60, 2, 40, true, D3DXVECTOR2(0, -60)), true));
		motionIndex = 0;
		break;
	case 2:
		motionInfos.push_back(new MotionInfo(0, new LineTrack(D3DXVECTOR2(0, 1), 2, 0, 0, NULL_POSITION), true));
		motionInfos.push_back(new MotionInfo(30, new LineTrack(D3DXVECTOR2(0, 1), 0, 0, 30, NULL_POSITION), true));
		motionInfos.push_back(new MotionInfo(40, new CircleTrack(D3DX_PI * 0.5, 60, 2, 40, false, D3DXVECTOR2(0, -60)), true));
		motionIndex = 0;
		break;
	default:
		motionIndex = 0;
		break;
	}
}
//--------------------------------------------------------------------------------------
//Enemy_01_01
//--------------------------------------------------------------------------------------
Enemy_01_01::Enemy_01_01(D3DXVECTOR2 &position, int mode, int startShootFrame)	: Enemy(TEXTURE_STG1ENM)
{
	m_position			= position;
	m_startShootFrame	= startShootFrame;
	m_actionMode		= mode;
	m_hp				= 4;
	m_name				= "blue elf";
	m_shootInterval		= 120;
	m_maxShootCount		= 1;
	m_shootLoopFrame	= 0;
	RECT rect ;
	SetRect(&rect, 0, 0, 256, 32);
	SetSprite(rect, 8, 8, 32, 32);
	switch(m_actionMode)
	{
	case 1:
		motionInfos.push_back(new MotionInfo(0, new LineTrack(D3DXVECTOR2(1, 10), 3, 0, 0, NULL_POSITION), true));
		motionInfos.push_back(new MotionInfo(60, new CircleTrack(D3DX_PI, 60, 3, 60, false), true));
		motionInfos.push_back(new MotionInfo(120, new CircleTrack(D3DX_PI, 60, 3, 120, true), true));
		motionInfos.push_back(new MotionInfo(180, new LineTrack(D3DXVECTOR2(1, 10), 3, 0, 180, NULL_POSITION), true));
		motionIndex = 0;
		break;
	case 2:
		motionInfos.push_back(new MotionInfo(0, new LineTrack(D3DXVECTOR2(-1, 10), 3, 0, 0, NULL_POSITION), true));
		motionInfos.push_back(new MotionInfo(60, new CircleTrack(D3DX_PI, 60, 3, 60, true), true));
		motionInfos.push_back(new MotionInfo(120, new CircleTrack(D3DX_PI, 60, 3, 120, false), true));
		motionInfos.push_back(new MotionInfo(180, new LineTrack(D3DXVECTOR2(-1, 10), 3, 0, 180, NULL_POSITION), true));
		motionIndex = 0;
		break;
	default:
		break;
	}
}
void UITextField::RenderText()
{
#ifdef __DAVAENGINE_IPHONE__
    // nothing to do
#else

#if 0
    SafeRelease(textSprite);

    int32 w = GetRect().dx;
    int32 h = GetRect().dy;

    EnsurePowerOf2(w);
    EnsurePowerOf2(h);

    int16 * buf;
	buf = new int16[w * h];
	memset(buf, 0, w * h * sizeof(int16));

    Size2i ds = textFont->DrawString(text, buf, w, h, 0, 0);
    String addInfo = WStringToString(Format(L"Text texture: %S", text.c_str()));
    Texture *tex = Texture::CreateTextFromData(FORMAT_RGBA4444, (uint8*)buf, w, h, addInfo.c_str());
    delete [] buf;

    textSprite = Sprite::CreateFromTexture(tex, 0, 0, GetRect().dx, GetRect().dy);
    SafeRelease(tex);

    textSprite->SetDefaultPivotPoint(0.0f, (float32)(textFont->GetBaseline() - h));
    
    SetSprite(textSprite, 0);

#endif

#endif
}
Exemple #19
0
Lattice::Lattice(size_t id) : Structure(id)
{
    SetSprite("icons/structures.dmi");
    SetState("latticefull");

    name = "Lattice";
}
Exemple #20
0
/**
 * The constructor sets up all the information that this CharActor will
 *  use to draw itself to the screen.
 * 
 * @param mask One generic bitmask for pixel perfect collision.
 * 
 * @param argPosition Starting position.
 * 
 * @param size The size of the actor in GL units.
 */
CharActor::CharActor(const Bitmask * const mask, const Vector2& argPosition ,const Vector2& size)
	: CollidingActor(mask, size)
	, m_direction(SOUTH)
	, m_moving(false)
	, m_movingNorth(false)
	, m_movingEast(false)
	, m_movingSouth(false)
	, m_movingWest(false)
	, m_movementSpeed(3.0f)
	, m_idleness(0.0f)
	, m_idleAnim(false)
    , m_dead(false)
{
	SetSprite("Resources/Images/animations/chars/arth/stand/lookAroundDown/lookAroundDown_00.png");
    SetPosition(argPosition);

    m_bBox = BoundingBox(Vector2(GetPosition().X-(_size.X/2), GetPosition().Y-(_size.Y/2)),
                         Vector2(GetPosition().X+(_size.X/2), GetPosition().Y+(_size.Y/2)));
    //m_bBox.RenderBox();
    //m_bBox.RenderOutline();

	//theSwitchboard.SubscribeTo(this, "CameraChange");
	theSwitchboard.SubscribeTo(this, "UpArrowPressed");
	theSwitchboard.SubscribeTo(this, "DownArrowPressed");
	theSwitchboard.SubscribeTo(this, "LeftArrowPressed");
	theSwitchboard.SubscribeTo(this, "RightArrowPressed");
	theSwitchboard.SubscribeTo(this, "UpArrowReleased");
	theSwitchboard.SubscribeTo(this, "DownArrowReleased");
	theSwitchboard.SubscribeTo(this, "LeftArrowReleased");
	theSwitchboard.SubscribeTo(this, "RightArrowReleased");
}
// Default constructor.
Torch::Torch() :
m_brightness(1.f)
{
	// Set sprite.
	int textureID = TextureManager::AddTexture("../../resources/spr_torch.png");
	SetSprite(TextureManager::GetTexture(textureID), false, 5, 12);
}
GameEntity::GameEntity( const char* a_pSpriteSheet, GLFWwindow * window)
{
	GameWindow = window;
	elapsedTime = 0;
	LoadVertShader("./Resources/LoadVertexShader.glsl");
	LoadFragShader("./Resources/LoadFragmentShader.glsl");
	LinkShaders();
	GLint uvAttrib = glGetAttribLocation(m_ShaderProgram,"texcoord");
	glEnableVertexAttribArray(uvAttrib);
	matrix_location = glGetUniformLocation (m_ShaderProgram, "matrix");
	LoadSprites(a_pSpriteSheet);
	LoadAnimations(atlas.sAnimations.c_str());
	LoadTexture(atlas.sSheet.c_str());


	m_dFrames = (1.0/15.0);
	currentAnimation = "Idle";
	currentSprite = "Idle_01";
	currentFrame = 0;
	currentPlayType = SINGLE;
	m_uvScale.m_fX = atlas.v2Size.m_fY;
	m_uvScale.m_fY	= atlas.v2Size.m_fX;
	SetSprite();
	SetUVData();
	iFacing = "Right"; //flag for facing


}
//---------------------------------------------------------
bool CMine_Sweeper::MakeBoard(int level)
{
	int		i, x, y;
	CSG_Colors	Colors;

	switch( level )
	{
		case 0:	Mine_NX = 8;	Mine_NY = 8;	N_Mines=10;
			break;
		
		case 1: Mine_NX = 16;	Mine_NY = 16;	N_Mines=40;
			break;
		
		case 2: Mine_NX = 30;	Mine_NY = 16;	N_Mines=99;
			break;
	}

	pInput	= SG_Create_Grid(SG_DATATYPE_Int,SPRITE_SIZE*Mine_NX, SPRITE_SIZE*Mine_NY);
	pInput->Set_Name(_TL("Mine Sweeper"));
	Parameters("GRID")->Set_Value(pInput);

	//-----------------------------------------------------
	CSG_Parameter	*pLUT	= DataObject_Get_Parameter(pInput, "LUT");

	if( pLUT && pLUT->asTable() )
	{
		pLUT->asTable()->Del_Records();

		for(i=0; i<16; i++)
		{
			CSG_Table_Record	*pRecord	= pLUT->asTable()->Add_Record();
			
			pRecord->Set_Value(0, SG_GET_RGB(mine_res_color[i*3], mine_res_color[i*3+1], mine_res_color[i*3+2]));
			pRecord->Set_Value(3, i);
		}

		DataObject_Set_Parameter(pInput, pLUT);
		DataObject_Set_Parameter(pInput, "COLORS_TYPE", 1);	// Color Classification Type: Lookup Table
	}

	Colors.Set_Count(16);
	for ( i=0;i<16; i++)
	{
		Colors.Set_Color(i, SG_GET_RGB(mine_res_color[i*3],	mine_res_color[i*3+1],	mine_res_color[i*3+2]));
	}
	DataObject_Set_Colors(pInput, Colors);
	DataObject_Update(pInput, 0.0, 15.0, true);

	//-----------------------------------------------------
	for(  y = 0; y <  Mine_NY; y++)	
	for(  x = 0; x <  Mine_NX; x++)
	{
		SetSprite(x,y,SPRITE_CLOSE);
	}

	pInput->Set_Value(0, 0);

	return true;			
}
Exemple #24
0
//TODO:Add EffectBulletHit,showed when player's bullet hit an enemy
EffectBulletHit::EffectBulletHit(const D3DXVECTOR2 &centerPosition)
						:GameObject(TEXTURE_EFF_00)
{
	RECT srcRect;
	SetRect(&srcRect,32, 0, 64, 32);
	SetSprite(srcRect, 1,0, 32, 32, false);
	SetCenter(centerPosition);
}
void E_Tortoise_Fly::IsAttacked()
{
    sound = new FrkSound("resources\\sounds\\effect\\smb3_kick.wav");
    sound->Play();
    status = 3;
    m_hSpeed.x = 0;
    SetSprite();
}
Exemple #26
0
void UBillboardComponent::SetSpriteAndUV(UTexture2D* NewSprite, int32 NewU, int32 NewUL, int32 NewV, int32 NewVL)
{
	U = NewU;
	UL = NewUL;
	V = NewV;
	VL = NewVL;
	SetSprite(NewSprite);
}
Exemple #27
0
BrushButton::BrushButton(wxWindow* parent, Brush* _brush, RenderSize sz, uint32_t id) :
	ItemToggleButton(parent, sz, uint16_t(0), id),
	brush(_brush)
{
	ASSERT(sz != RENDER_SIZE_64x64);
	ASSERT(brush);
	SetSprite(brush->getLookID());
	SetToolTip(wxstr(brush->getName()));
}
Exemple #28
0
void Player::ClearDamage()
{
    if (Alive())
    {
        Hurt = false;
        _damagedSpriteSet = false;
        SetSprite(PLAYERSPRITE_FILENAME.c_str(), X, Y);
    }
}
AmmunitionBox::AmmunitionBox(size_t id) : Item(id)
{
    SetSprite("icons/ammo.dmi");
    SetState("357");

    name = "Revolver Ammunition",
	
    bullets_ = 50;
}
void CMine_Sweeper::Show_GameBoard(bool ShowMines)
{
	int x,y;

	if (ShowMines)
	{
		for(  y = 0; y <  Mine_NY; y++)	
		for(  x = 0; x <  Mine_NX; x++)
		{
			if(GameBoard->asInt(x, y) & isBomb)
			{
				if (FlagBoard->asInt(x,y) == FLAG)
					SetSprite(x,y,SPRITE_FLAG);
				else
					SetSprite(x,y,SPRITE_BOMB);
			}
			else
			{
				if (GameBoard->asInt(x, y) == isOpen )
					SetSprite(x,y,SPRITE_NUMMER(Get_Number_of_Bombs(x,y)));
				else			
					SetSprite(x,y,SPRITE_CLOSE);
			}
			
			if (GameBoard->asInt(x, y) & isBumm) SetSprite(x,y,SPRITE_BOMB_BUMM);

			if ( !(GameBoard->asInt(x, y) & isBomb) && (FlagBoard->asInt(x,y) == FLAG)) 
				SetSprite(x,y,SPRITE_BOMB_NO);
		}
	}
	else
	for(  y = 0; y <  Mine_NY; y++)	
	for(  x = 0; x <  Mine_NX; x++)
	{
		if(GameBoard->asInt(x, y) == isOpen)
		{
			SetSprite(x,y,SPRITE_NUMMER(Get_Number_of_Bombs(x,y)));
		}
		else
		{
			if(FlagBoard->asInt(x,y))
			SetSprite(x,y,FlagBoard->asInt(x,y));
			else
			SetSprite(x,y,SPRITE_CLOSE);
		}
	}

	DataObject_Update(pInput, 0.0, 15.0);
}