Esempio n. 1
0
void ColorItem::Update(BView *owner, const BFont *font)
{
	if (fText)
		SetWidth(font->StringWidth(fText));

	font_height fheight;
	font->GetHeight(&fheight);

	float height = ceilf(fheight.ascent) + ceilf(fheight.descent)
		+ ceilf(fheight.leading) + 1;

	if (height < COLOR_ITEM_HEIGHT) height = COLOR_ITEM_HEIGHT;
	fBaselineOffset = (height / 2) + fheight.descent + 1;
	
	SetHeight(height);
}
Esempio n. 2
0
///////////////////////////////////////////////
//  CONSTRUCTOR / DECONSTRUCT / OP OVERLOADS
///////////////////////////////////////////////
CBullet::CBullet()
{
	m_pOwner = NULL;	
	SetWidth(16);
	SetHeight(16);
	SetDamage(5);
	SetType(OBJ_BULLET);
	ES->RegisterClient("enemyhit",this);
	ES->RegisterClient("camerachange",this);
	m_fTimer = 0.0f;
	m_fRotation = 0.0f;

	// Screw specifics
	m_bScrew = false;
	m_bPuke = false;
};
Esempio n. 3
0
void
BStringItem::Update(BView *owner, const BFont *font)
{
	if (fText != NULL) {
		SetWidth(font->StringWidth(fText)
			+ be_control_look->DefaultLabelSpacing());
	}

	font_height fheight;
	font->GetHeight(&fheight);

	fBaselineOffset = 2 + ceilf(fheight.ascent + fheight.leading / 2);

	SetHeight(ceilf(fheight.ascent) + ceilf(fheight.descent)
		+ ceilf(fheight.leading) + 4);
}
Esempio n. 4
0
std::shared_ptr<touchmind::model::node::NodeModel>
touchmind::model::node::NodeModel::Create(touchmind::selection::SelectionManager *pSelectionManager) {
  ASSERT(pSelectionManager != nullptr);
  auto node = std::make_shared<NodeModel>();
  node->SetSelectionManager(pSelectionManager);

  auto defaultProp = pSelectionManager->GetDefaultPropertyModel();
  node->SetBackgroundColor(defaultProp->UpdateProperty_GetNodeBackgroundColor());
  node->SetNodeShape(defaultProp->UpdateProperty_GetNodeShape());

  auto path = node->GetPathModel();
  path->SetSelectionManager(pSelectionManager);
  path->SetColor(defaultProp->UpdateProperty_GetLineColor());
  path->SetWidth(defaultProp->UpdateProperty_GetLineWidth());
  path->SetStyle(defaultProp->UpdateProperty_GetLineStyle());
  return node;
}
CPowerupRapidFire::CPowerupRapidFire()
{
	CSGD_EventSystem *pES = CSGD_EventSystem::GetInstance();
	
	pES->RegisterClient("scroll left", this);
	pES->RegisterClient("scroll right",this);

	SetType(POWERUP_RAPIDFIRE);
	rPowerupRect.top = 8;
	rPowerupRect.bottom = 30;
	rPowerupRect.left = 8;
	rPowerupRect.right = 30;

	SetWidth(30);
	SetHeight(30);
	SetScoreValue(100);
}
Esempio n. 6
0
CheckBoxObject::CheckBoxObject(std::string name_) :
Object(name_),
borderWidth(1),
padding(5)
{
    //Create the SFGUI CheckBox object
    obj = sfg::CheckButton::Create("Texte");

    SetString("Case à cocher");

    //Default size of the object
    SetWidth(180);
    SetHeight(24);

    fontSize = 12;

    //Colors "Schemes"
    borderColor = new ColorScheme(sf::Color(146, 147, 151, 255),
                                  sf::Color(146, 147, 151, 255),
                                  sf::Color(146, 147, 151, 255),
                                  sf::Color(173, 173, 173, 255));

    backgroundColor = new ColorScheme(sf::Color(255, 255, 255, 255),
                                      sf::Color(201, 201, 201, 255),
                                      sf::Color(230, 230, 230, 255),
                                      sf::Color(140, 140, 140, 255));

    textColor = new ColorScheme(sf::Color(0, 0, 0, 255),
                                sf::Color(0, 0, 0, 255),
                                sf::Color(0, 0, 0, 255),
                                sf::Color(100, 100, 100, 255));

    checkColor = new ColorScheme(sf::Color(122, 122, 122, 255));

    SetBoxSize(14);
    SetCheckSignSize(6);

    obj->SetPosition( sf::Vector2f( GetX(), GetY() ) );

    obj->SetId(ToString<void*>(this));

    ConnectSignals();
    ResetEventInformations();

    UpdateProperties();
}
g2Slider::g2Slider(g2Controller* Parent, g2Theme* MainTheme)
: g2Controller(Parent, MainTheme)
{
    // Default progress is 50% within [0, 1]
    Progress = 0.5f;
    MinBound = 0.0f;
    MaxBound = 1.0f;
    
    // Default to no dragging
    IsDragging = false;
    
    // Set the width to default value
    SetWidth(0);
    
    // Default to no live value
    LiveValue = NULL;
}
void
MediaListItem::Update(BView* owner, const BFont* font)
{
	// we need to override the update method so we can make sure our
	// list item size doesn't change
	BListItem::Update(owner, font);

	float iconHeight = MediaIcons::sBounds.Height() + 1;
	if ((Height() < iconHeight + kITEM_MARGIN * 2)) {
		SetHeight(iconHeight + kITEM_MARGIN * 2);
	}

	Renderer renderer;
	renderer.SetTitle(Label());
	SetRenderParameters(renderer);
	SetWidth(renderer.ItemWidth());
}
Esempio n. 9
0
Paddle::Paddle(unsigned id)
  : Entity(id)
  , keysym_up_(-1)
  , keysym_down_(-1)
  , up_key_down_(false)
  , down_key_down_(false)
  , events_enabled_(true)
  , speed_increse_(0)
{
  SetWidth(WIDTH);
  SetHeight(HEIGHT);

  finger_down.connect([this] (int x, int y, int dx, int dy) {
    if (!paused_ && events_enabled_ && input_boundary_.PointInside({x, y}))
      SetY(y - height() / 2);
  });
}
Esempio n. 10
0
ActorLifebar::ActorLifebar() : Sprite()
{
	Health = 50; // Out of 100!
	pending_health = 0;
	time = 0;

	SetImage(GameState::GetInstance().GetSkinImage("healthbar.png"));

	SetWidth(PlayfieldHeight / 2);
	SetHeight(Configuration::GetSkinConfigf("Height", "Lifebar" ));
	Centered = Configuration::GetSkinConfigf( "Centered", "Lifebar" ) != 0;
	SetPosition( Configuration::GetSkinConfigf("X", "Lifebar" ), Configuration::GetSkinConfigf("Y", "Lifebar" ));
	SetRotation( Configuration::GetSkinConfigf("Rotation", "Lifebar" ) );
	AffectedByLightning = true;

	UpdateHealth();
}
Esempio n. 11
0
void CLaser::KeyValue(KeyValueData *pkvd)
{
	if(FStrEq(pkvd->szKeyName, "LaserTarget"))
	{
		pev->message   = ALLOC_STRING(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if(FStrEq(pkvd->szKeyName, "width"))
	{
		SetWidth((int)atof(pkvd->szValue));
		pkvd->fHandled = TRUE;
	}
	else if(FStrEq(pkvd->szKeyName, "NoiseAmplitude"))
	{
		SetNoise(atoi(pkvd->szValue));
		pkvd->fHandled = TRUE;
	}
	else if(FStrEq(pkvd->szKeyName, "TextureScroll"))
	{
		SetScrollRate(atoi(pkvd->szValue));
		pkvd->fHandled = TRUE;
	}
	else if(FStrEq(pkvd->szKeyName, "texture"))
	{
		pev->model     = ALLOC_STRING(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if(FStrEq(pkvd->szKeyName, "EndSprite"))
	{
		m_iszSpriteName = ALLOC_STRING(pkvd->szValue);
		pkvd->fHandled  = TRUE;
	}
	else if(FStrEq(pkvd->szKeyName, "framestart"))
	{
		pev->frame     = atoi(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else if(FStrEq(pkvd->szKeyName, "damage"))
	{
		pev->dmg       = atof(pkvd->szValue);
		pkvd->fHandled = TRUE;
	}
	else
		CBeam::KeyValue(pkvd);
}
Esempio n. 12
0
bool TILEMAP::Load(const std::string& filename, CONTENTMANAGER& contentManager)
{
    ZIPSTREAM zipstream;
    ZIPSTRING zipstring;
    Json::Value root;
    Json::Reader reader;

    if (!zipstream.Open(filename))
    {
        std::cout << "Failed to load tilemap '" << filename << "'." << std::endl;
        return false;
    }
    if (!zipstring.Read(zipstream))
    {
        std::cout << "Failed to load tilemap '" << filename << "' : stream error." << std::endl;
        return false;
    }
    if (!reader.parse(zipstring.Str(), root))
    {
        std::cout << "Failed to load tilemap '" << filename << "' : " << reader.getFormatedErrorMessages() << std::endl;
        return false;
    }
    if (!contentManager.Load<TEXTURE>(texture, root["texture"].asString()))
    {
        std::cout << "Failed to load tilemap '" << filename << "' : texture not found." << std::endl;
        return false;
    }
    tileSize = root["tileSize"].asUInt();
    SetHeight( root["height"].asInt() );
    SetWidth( root["width"].asInt() );

    Json::Value jtiles = root["tiles"];
    for (unsigned int y=0; y<height; y++)
    {
        for (unsigned int x=0; x<width; x++)
        {
            SetTile(x, y, jtiles[(y*width)+x].asUInt());
        }
    }

    ConstructTileset();

    std::cout << "Tilemap '" << filename << "' loaded." << std::endl;
    return true;
}
Esempio n. 13
0
void Window::RefreshSize() {
    
    int new_height, new_width;
    
    //Directly refresh sizes
    getmaxyx(stdscr, new_height, new_width);
    
    if (new_height != GetHeight() ||
        new_width != GetWidth()) {
        
        //Notify handler -> Director?
        
    }
    
    //Update new size
    SetHeight(new_height);
    SetWidth(new_width);
}
Esempio n. 14
0
void
MimeTypeItem::Update(BView* owner, const BFont* font)
{
	BStringItem::Update(owner, font);

	if (fShowIcon) {
		SetWidth(Width() + B_MINI_ICON + 2.0f);

		if (Height() < B_MINI_ICON + 4.0f)
			SetHeight(B_MINI_ICON + 4.0f);

		font_height fontHeight;
		font->GetHeight(&fontHeight);

		fBaselineOffset = fontHeight.ascent
			+ (Height() - ceilf(fontHeight.ascent + fontHeight.descent)) / 2.0f;
	}
}
g2TextField::g2TextField(g2Controller* Parent, g2Theme* MainTheme)
: g2Controller(Parent, MainTheme)
{
    // Allocate the editable label and center
    TextEdit = new g2LabelEdit(this, MainTheme);
    
    // Center
    int CharHeight = GetTheme()->GetCharacterHeight();
    int ControllerHeight;
    GetTheme()->GetComponentSize(g2Theme_TextField, NULL, &ControllerHeight);
    TextEdit->SetPos(g2TextField_LabelEditOffset, ControllerHeight / 2 - CharHeight / 2);
    
    // Default to black
    TextEdit->SetColor(0.0f, 0.0f, 0.0f);
    
    // Default width
    SetWidth(0);
}
Esempio n. 16
0
	//CharacterSpawn::CharacterSpawn(std::shared_ptr<Settings> &settings, Map *map)
	CharacterSpawn::CharacterSpawn(std::shared_ptr<BaseSettings> &settings)
	{
		hasImage_ = false;
		hasColor_ = false;
		hasImageReference_ = false;
		currentRotation_ = 0;
		settings_ = settings;
		//map_ = map;
		SetCurrentPosition(1, 1);
		SetColor(al_map_rgb_f(1, 1, 1));
		SetWidth(0.8);
		SetHeight(0.8);




		//fprintf(stderr, "An CharacterSpawn created\n");
	}
Esempio n. 17
0
/**
 *  Konstruktor von @p iwTextfile.
 *
 *  @todo Das Fenster ist zu klein, um 80 Zeichen pro Zeile darstellen zu
 *        koennen. Ein horizontaler Scrollbalken fuer 640x480 waere nicht
 *        schlecht.
 *
 *  @author Devil
 *  @author FloSoft
 *  @author OLiver
 */
iwTextfile::iwTextfile(const std::string& filename, const std::string& title)
    : IngameWindow(CGI_README, 0xFFFF, 0xFFFF, 640, 480, title, LOADER.GetImageN("resource", 41))
{
    // Pfad mit gewählter Sprache auswählen
    std::string path = GetFilePath(FILE_PATHS[88]) + SETTINGS.language.language + "/" + filename;

    std::ifstream file(path.c_str());

    ctrlMultiline* text = AddMultiline(2, 10, 20, width - 20, 450, TC_GREEN1, NormalFont, glArchivItem_Font::DF_LEFT | glArchivItem_Font::DF_TOP);

    if(!file.good())
    {
        // lokalisierte Vresion nicht gefunden, Standard öffnen
        path = FILE_PATHS[88] + filename;
        file.clear();
        file.open(path.c_str());
        if(!file.good())
        {
            // immer noch nichts gefunden? --> Dann Fehlermeldung
            text->AddString(_("The readme file was not found!"), COLOR_RED, false);
            // und raus
            return;
        }
    }

    std::string line; // buffer for one line
    unsigned short max_line_width = 0; // use this to find max length of lines, to set window width
    unsigned short current_line_width;

    while(!file.eof())
    {
        std::getline(file, line); // get next line
        text->AddString(line.c_str(), COLOR_YELLOW, false); // add this line to the window contents
        current_line_width = NormalFont->getWidth(line); // get the width of line in normal font
        if (current_line_width > max_line_width) // if wider than max, re-set max
        {
            max_line_width = current_line_width;
        }
    }
    file.close();

    SetWidth(max_line_width + 20 + 30); // set window width to our determined max width
    text->SetWidth(max_line_width + 30);
}
Esempio n. 18
0
Character::Character(Settings *settings, int mapWidth, int mapHeight, std::vector<std::vector<Cell>> *cellMap)
{
    hasText_ = false;
    movespeed_ = 0;
    currentRotation_ = 0;
    hasImage_ = false;
    hasColor_ = false;
    hasImageReference_ = false;
    aiEnabled_ = true;

    mapWidth_ = mapWidth;
    mapHeight_ = mapHeight;

    cellMap_ = cellMap;


    settings_ = settings;
    KeyLeft_ = false;
    KeyRight_ = false;
    KeySpace_ = false;
    SetCurrentPosition(mapWidth_ / Constants::TileSize() + 1, mapHeight_ / Constants::TileSize() + 1);
    SetColor(al_map_rgb_f(1, 1, 1));
    SetWidth(0.8);
    SetHeight(0.8);

    SetGravityY(-9.8);
    SetVelocityY(0.125);
    SetMaxVelocityY(1);
    SetAccelerationY(0.03125);


    SetMoveSpeedDelta(0.0625);
    SetMoveSpeed(30);
    SetJumpSpeed(12);

    font30_ = al_load_font("arial.ttf", Constants::TileSize(), 0);



    SetCharacterYAxisState(CHARACTERYAXISSTATES::CHARACTERFALLING);



}
void
LanguageListItemWithFlag::Update(BView* owner, const BFont* font)
{
	LanguageListItem::Update(owner, font);

	float iconSize = Height();
	SetWidth(Width() + iconSize + 4);

	if (fCountryCode.IsEmpty())
		return;

	fIcon = new(std::nothrow) BBitmap(BRect(0, 0, iconSize - 1, iconSize - 1),
		B_RGBA32);
	if (fIcon != NULL && BLocaleRoster::Default()->GetFlagIconForCountry(fIcon,
			fCountryCode.String()) != B_OK) {
		delete fIcon;
		fIcon = NULL;
	}
}
IconListItem::IconListItem(BBitmap *mini_icon,const char *text, int level, bool expanded) :
	BListItem(level,expanded)
{
	if (mini_icon) { 
		BRect rect(0.0, 0.0, 15.0, 15.0);
		icon = new BBitmap(rect, B_CMAP8);
		
		if ((mini_icon->BytesPerRow() == icon->BytesPerRow()) &&
        	(mini_icon->BitsLength() == icon->BitsLength()))
        	memcpy(icon->Bits(), mini_icon->Bits(), mini_icon->BitsLength());
        else
        	delete icon;
	} 
	SetHeight(18.0);
	label.SetTo(text);
	BFont font(be_plain_font);
	float width_of_item=font.StringWidth(text);
	SetWidth(width_of_item);
} 
Esempio n. 21
0
Ladder::Ladder(int no)
{
	ladderNum = no;

	switch (ladderNum)
	{
	case 0:
		ladder = new ZeroSprite("Texture/Ladder/ladder0.png");
		break;

	case 1:
		ladder = new ZeroSprite("Texture/Ladder/ladder.png");
		break;
	}

	SetWidth(ladder->Width());
	SetHeight(ladder->Height());
	PushScene(ladder);
}
bool PCB_PLANE::Parse( XNODE*         aNode,
                       wxString       aDefaultMeasurementUnit,
                       wxString       aActualConversion,
                       wxStatusBar*   aStatusBar )
{
    XNODE*          lNode;
    wxString        pourType, str, propValue;

    // aStatusBar->SetStatusText( aStatusBar->GetStatusText() + wxT( " Plane..." ) );

    lNode = FindNode( aNode, wxT( "netNameRef" ) );

    if( lNode )
    {
        lNode->GetAttribute( wxT( "Name" ), &propValue );
        propValue.Trim( false );
        propValue.Trim( true );
        m_net = propValue;
        m_netCode = GetNetCode( m_net );
    }

    if( FindNode( aNode, wxT( "width" ) ) )
        SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(),
                  aDefaultMeasurementUnit, &m_width, aActualConversion );

    lNode = FindNode( aNode, wxT( "pcbPoly" ) );

    if( lNode )
    {
        // retrieve plane outline
        FormPolygon( lNode, &m_outline, aDefaultMeasurementUnit, aActualConversion );

        m_positionX = m_outline[0]->x;
        m_positionY = m_outline[0]->y;
    }
    else
    {
        return false;
    }

    return true;
}
CBillboardAnimation::CBillboardAnimation(CXMLTreeNode &parser){
	SetColor(CColor(parser.GetVect3fProperty("color",Vect3f(1.0f))));
	float size=parser.GetFloatProperty("size",2.0f);
	SetHeight(size);
	SetWidth(size);
	m_TimePerImage=parser.GetFloatProperty("time",0.2f);
	m_Loop=parser.GetBoolProperty("loop",false);
	CXMLTreeNode l_Node = parser["Textures"];
	for(int i=0;i<l_Node.GetNumChildren();i++){
		
		std::string l_TexturePath=l_Node(i).GetPszProperty("tex","");
		CTexture *l_Texture = CORE->GetTextureManager()->GetTexture(l_TexturePath);
		m_Textures.push_back(l_Texture);
	}
	m_Index=0;
	m_fTime=0.0f;
	SetTexture(m_Textures[m_Index]);
	SetPos(Vect3f(0.0f,0.0f,0.0f));
	
}
Esempio n. 24
0
BOOL CGate::InitProperty(CGateList::tagGate *p)
{
	SetName(p->cName);//名字
	SetLenth(p->wLenth);//长		
	SetWidth(p->wWidth);//宽
	SetLevel(p->wLevel);//等级
	SetGraphicsID(p->dwModelId);//模型ID
	SetMaxHP(p->wMaxHp);//最大HP
	SetHP(p->wMaxHp);	//当前HP
	SetUnAttack(p->bIsunbeatable);//是否无敌
	SetBlockType(p->byBlockType);//阻挡类型
	SetDef(p->lDef);//物防	
	SetMagicDef(p->lMagicDef);//魔防
	SetNameColor(p->wNameColor);//名字颜色
	SetHitSound(string(p->cHitSound));//击中音效
	SetDestorySound(string(p->cDestorySound));//损毁音效
	SetOpenSound(string(p->cOpenSound));//打开音效
	SetCloseSound(string(p->cCloseSound));//关闭音效
	return TRUE;
}
CBillboardAnimation::CBillboardAnimation(CBillboardAnimation &other){
	
	SetColor(other.GetColor());
	SetHeight(other.GetHeight());
	SetWidth(other.GetWidth());
	SetPos(Vect3f(0.0f,0.0f,0.0f));
	m_TimePerImage=other.GetTimePerImage();
	m_Loop=other.GetLoop();
	m_fTime=0.0f;
	m_Index=0;

	std::vector<CTexture*> l_TextVector = other.GetTextureVector();
	for( uint16 i=0;i<l_TextVector.size();i++){
		m_Textures.push_back(l_TextVector.at(i));
	}
	
	SetTexture(m_Textures[m_Index]);


}
Esempio n. 26
0
CTurtle::CTurtle(void)
{
	m_nType = OBJECT_TURTLE;
	m_nCurrSelectedSkill = -1;
	m_bIsAlive = true;
	SetVelX(100.0f);
	SetVelY(50.0f);
	SetWidth(50);
	SetHeight(80);
	m_nCurrWeapon = 0;
	m_pOwner = NULL;
	m_nNumType = -1;

	m_nPrevLvl = 0;
	m_nPrevStr = 0;
	m_nPrevDef = 0;
	m_nPrevAcc = 0;
	m_nDamageDon = 0;
	m_nDamageRec = 0;
}
CEnemyPsycrow::CEnemyPsycrow()
{
	CSGD_EventSystem *pES = CSGD_EventSystem::GetInstance();
	CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance();
	COptions *op = COptions::GetInstance();

	pES->RegisterClient("psycrow fire", this);
	pES->RegisterClient("state transition 1", this);
	pES->RegisterClient("state transition 2", this);
	pES->RegisterClient("state transition 3", this);
	pES->RegisterClient("state transition 4", this);

	m_nState = PSYCROW_STATE1;
	m_nSoundID = CSGD_WaveManager::GetInstance()->LoadWave("Resource/sounds/JoA_Squawk.wav");
	CSGD_WaveManager::GetInstance()->SetVolume(m_nSoundID, op->GetSFXVolume() - 40);
	m_fFireReady = 5.0f;
	m_fHitTimer = 0.4f;
	m_nOffset = 0;
	bIsFired = false;
	m_fFiringTimer = 0.5f;
	m_fSineFloat = 3.14f;
	m_nColor = 255;
	m_nScale = 1.5f;

	SetHP(250 * op->GetDifficulty());
	SetVelX(75 * op->GetDifficulty());
	SetVelY(0.0f);
	SetXFlip(-1);
	SetHeight(84);
	SetWidth(70);
	SetPosX(320);
	SetPosY(240);
	SetPower(0);
	SetType(ACTOR_ENEMY);
	SetScoreValue(1000 * op->GetDifficulty());
	SetHit(false);
	pBullet = NULL;

	bIsFiring = false;

}
Esempio n. 28
0
	bool Manager::ParseEvent(sf::Event event, Manager *pManager)
	{
		if (event.type == event.KeyPressed || event.type == event.KeyReleased || event.type == event.TextEntered)
		{
			if (iFocused != lstFocusable.end())
			{
				return ((*iFocused)->ParseEvent(event, this));
			}
			else
			{
				return false;
			}
		}
		else
		{
			if (event.type == event.Resized)
			{
				SetWidth(event.size.width);
				SetHeight(event.size.height);
			}

			bool bReturn = SpreadEvent(event, this);
			if (!bReturn && event.type == event.MouseButtonPressed && iFocused != lstFocusable.end())
			{
				(*iFocused)->SetFocused(false);
				iFocused = lstFocusable.end();
			}
			if (event.type == event.MouseButtonReleased && pWidgetPressed != NULL)//Extra precaution in case it got skipped
			{
				pWidgetPressed->ParseEvent(event, this);
			}

			if (!bReturn && event.type == event.MouseMoved && pWidgetHovered != NULL)//Extra precaution like before one
			{
				pWidgetHovered->ParseEvent(event, this);
				pWidgetHovered = NULL;
				GetMouseCursor().SetState(CRS_DEFAULT);
			}
			return bReturn;
		}
	}
Esempio n. 29
0
void Player::Init()
{
	SetTag("Player");
	SetWidth(c_iPlayerWidth);
	SetHeight(c_iPlayerHeight);
	SetAlive(c_bPlayerAlive);
	SetPosition(c_v2DInitPlayerPos);
	SetSpriteID( CreateSprite( "./images/PlayerShip.png" , GetWidth(), GetHeight(), true));

	eCurrentWeapon = BULLET; //Start with standard Bullets

	m_iBulletTimer = 0;
	m_iMissileTimer = 0;
	m_iLaserTimer = 0;
	m_iBulletArrayPosition = c_iPlayerMaxBullets; // Currently Bullets should be [0] - [7]
	m_iMissileArrayPosition = m_iBulletArrayPosition + c_iPlayerMaxMissiles; // should be [8] - [10]
	m_iLaserArrayPosition = m_iMissileArrayPosition + c_iPlayerMaxLasers; // should be [11] -[21]
	m_iBulletAmmo = c_iPlayerMaxBullets;
	m_iMissileAmmo = c_iPlayerMaxMissiles;
	m_iLaserAmmo = c_iPlayerMaxLasers;

	//Bullets go in list first
	for(int i = c_iPlayerMaxBullets; i > 0; i--)
		 GetProjectiles().push_back(new Bullet);

	//Missiles next
	for(int i = m_iMissileArrayPosition; i > m_iBulletArrayPosition; i--)
		 GetProjectiles().push_back(new Missile);

	//Laser last
	for(int i = m_iLaserArrayPosition; i > m_iMissileArrayPosition; i--)
		 GetProjectiles().push_back(new Laser);

	//Init all owned Projectiles
	for(int i = 0; i <  GetProjectiles().size(); ++i)
	{
		 GetProjectiles()[i]->Init();
	}

	
}
Esempio n. 30
0
void MenuBar::Add(Menu* lpMenu)
{
	Container::Add(lpMenu);

	int lNewMenuWidth = lpMenu->GetDimensions().m_width - (lpMenu->GetMenuItemSpacer() * 2);
	int lNewMenuHeight = lpMenu->GetDimensions().m_height - (lpMenu->GetMenuItemSpacer() * 2);

	// Check to see if this new menu has a bigger height
	if(lNewMenuHeight > mBiggestHeight)
	{
		mBiggestHeight = lNewMenuHeight;

		SetHeight(mBiggestHeight + (lpMenu->GetMenuItemSpacer() * 2));

		// Notify all our children menu items of the NEW biggest height
		ComponentList::const_iterator iterator;

		for(iterator = m_vpComponentList.begin(); iterator != m_vpComponentList.end(); ++iterator)
		{
			if((*iterator)->GetComponentType() == EComponentType_Menu)
			{
				(*iterator)->SetHeight(mBiggestHeight);
			}
		}
	}

	// Set the location of the new menu
	lpMenu->SetDimensions(mCurrentMenuBarWidth, 0, lNewMenuWidth, mBiggestHeight);

	// Reset the main menu to be the width of its original text length
	lpMenu->ResetToTextWidth();

	// Get this original menu width and use this as the new width marker, this means menu bars dont have massive
	// gaps for the biggest entry size.
	int lOriginalMenuWidth = lpMenu->GetDimensions().m_width - (lpMenu->GetMenuItemSpacer() * 2);

	mCurrentMenuBarWidth += lOriginalMenuWidth + (lpMenu->GetMenuItemSpacer() * 2);

	// Extend our width
	SetWidth(mCurrentMenuBarWidth);
}