コード例 #1
0
void AttitudeIndicator::itemSizeChanged(float w, float h) {
    // The guage has changed size: redraw the cached pixmaps.
    createCard(w,h);
    createFrame(w,h);
    createGlass(w,h);
    createBackground(w,h);
}
コード例 #2
0
ファイル: cardsprite.cpp プロジェクト: jsj2008/kdegames
// Calculate a pixmap for a frame. Only calculates it if it
// is not previously stored to avoid double calculations.
void CardSprite::calcFrame(int no)
{
  QPixmap pixmap = mFrames.at(no);
  // Check whether frame is already loaded
  if (pixmap.isNull())
  {
    double dx = 0.0;
    double dy = 0.0;
    // Frontside
    if (no == 0)
    {
      pixmap = thememanager()->getCard(mSuite, mCardType, mWidth);
    }
    // Backside
    else if (no >= mFrames.count()-1)
    {
      pixmap = thememanager()->getCardback(mWidth);
    }
    // Animation
    else
    {
      QPixmap front = thememanager()->getCard(mSuite, mCardType, mWidth);
      QPixmap back  = thememanager()->getCardback(mWidth);
      pixmap        = createCard(front, back, no, mFrames.count());
      dx            = (front.width()-pixmap.width())/2.0;
      dy            = (front.height()-pixmap.height())/2.0;
    }
    mFrames[no]   = pixmap;
    mHotspots[no] = QPointF(dx, dy);
  }
}
コード例 #3
0
void GatyaTenDrawScene::initCard()
{
    _cards.clear();
    
    for (int i=0;i<CARD_NUM;i++) {
        Cards card;
        if (isSRCard()) {
            int j = arc4random_uniform((int)SRGirlList.size());
            card.filePath = SRGirlList.at(j);
        } else {
            int j = arc4random_uniform((int)RGirlList.size());
            card.filePath = RGirlList.at(j);
        }
        
        _cards.push_back(card);
    }
    
    int tag = 1;
    
    for (int x = 0; x < 4; x++) {
        for (int y = 0; y < 3; y++) {
            if(y == 2 && x > 1) {
                break;
            }
            createCard(CardSprite::PositionIndex((ONE_CARD_WIDTH*CARD_SCALE)*x+(ONE_CARD_WIDTH*CARD_SCALE)/2+(ONE_CARD_WIDTH*CARD_SCALE)*(x+1)/5, WINSIZE.height*4/5 - ONE_CARD_HEIGHT*CARD_SCALE*y - 25*y), tag);
            tag++;
        }
    }
}
コード例 #4
0
ファイル: turnbank.cpp プロジェクト: dankrusi/ExtPlane-Panel
TurnAndBank::TurnAndBank(ExtPlanePanel *panel, ExtPlaneConnection *conn) :
    PanelItem(panel, PanelItemTypeGauge, PanelItemShapeCircular),
    _client(this, typeName(), conn)
{
    _rollValue = 10;
    _slipValue = -20;
    
    //    _rollRef = QString("sim/cockpit2/gauges/indicators/turn_rate_roll_deg_pilot");
    _rollRef = QString("sim/cockpit2/gauges/indicators/roll_electric_deg_pilot");   // Matches XP's C172
    //_rollRef = QString("sim/cockpit2/gauges/indicators/turn_rate_heading_deg_pilot");
    _slipRef = QString("sim/cockpit2/gauges/indicators/slip_deg");
    
    //    _card = QPixmap(QString("junk"));//../images/engine_FUELP.png"));

    createCard();
    //createGlass();
    createFrame();
    createBall();
    //_bezel = QPixmap::fromImage(QImage(QString("../images/bezel_square_.png")), Qt::AutoColor);
    
    connect(&_client, SIGNAL(refChanged(QString,double)), this, SLOT(refChanged(QString,double)));
    _client.subscribeDataRef(_slipRef,0.02);
    _client.subscribeDataRef(_rollRef,0.1);
    
}
コード例 #5
0
ファイル: Deck.cpp プロジェクト: Diadlo/Framework
void Deck::dealerCard(int cardX) {
    int cardY= cardPaddingY;
    Card *card = createCard(DEALER);
    newCardX = cardX;
    newCardY = cardY;
    card->setPosition(10, 10);
    Game::addObject(card);
}
コード例 #6
0
ファイル: Game.cpp プロジェクト: power3919/2048
bool Game::init()
{
    if (!Layer::init()) {
        return false;
    }
    auto size = Director::getInstance()->getVisibleSize();
    
    auto layerColor = LayerColor::create(Color4B(200, 150, 100, 200));
    addChild(layerColor);
    
    //标题
    auto titleLabel = Label::createWithTTF("2048 Game","fonts/Marker Felt.ttf",70);
    titleLabel->setColor(Color3B(200, 250, 100));
    titleLabel->setPosition(Vec2(size.width/2,size.height/2+550));
    auto letter = titleLabel->getLetter(1);
    auto letter1 = titleLabel->getLetter(3);
    auto rote = RepeatForever::create(RotateBy::create(1, 180));
    auto rote1 = RepeatForever::create(RotateBy::create(1, 180));
    letter->runAction(rote);
    letter1->runAction(rote1);//设置字体旋转
    addChild(titleLabel);
    
    auto Label = Label::createWithTTF("score:", "fonts/arial.ttf", 50);
    Label->setColor(Color3B::BLUE);
    Label->setPosition(Vec2(80,size.height/2+450));
    addChild(Label);
    
    char t[10];
    score=0;
    sprintf(t,"%d",score);
    scoreLabel = Label::createWithTTF(t, "fonts/Marker Felt.ttf", 40);
    scoreLabel->setColor(Color3B::BLUE);
    scoreLabel->setPosition(Vec2(170,size.height/2+450));
    addChild(scoreLabel);
    
    auto newGame = Label::createWithTTF("new Game", "fonts/Marker Felt.ttf",50);
    newGame->setColor(Color3B::GRAY);
    newGame->setPosition(Vec2(110,size.height/2+380));
    addChild(newGame);
    
    auto bt = Button::create("buttonreplay.png");
    bt->setPosition(Vec2(260,size.height/2+380));
    bt->addClickEventListener(CC_CALLBACK_0(Game::restart, this));
    addChild(bt);
    
    auto listener = EventListenerTouchOneByOne::create();
    listener->onTouchBegan=CC_CALLBACK_2(Game::onTouchBegan, this)
    ;
    listener->onTouchEnded=CC_CALLBACK_2(Game::onTouchEnded, this);
    _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
    
    createCard();
    createCardNumber();
    createCardNumber();
    return true;
}
コード例 #7
0
ファイル: Deck.cpp プロジェクト: Diadlo/Framework
void Deck::onClick() {
    if (cardPaddingX == 0)
        cardPaddingX = (Game::getWindowWidth() - this->getWidth() - OFFSET*5)/2;

    Card *card = createCard(PLAYER);
    int playerCardAmount = BlackJack::amount - 2; // 2 card have dealer
    newCardX = cardPaddingX + playerCardAmount * OFFSET;
    newCardY = Game::getWindowHeight() - this->getHeight() - this->cardPaddingY;
    card->setPosition(10, 10);
}
コード例 #8
0
CardDesk::Card *SlickerCardManager::createCard(const QString &desktopFile, const QString &configFile,
											KConfigGroup *group)
{
		KGlobal::dirs()->addResourceType("cardapplets", KStandardDirs::kde_default("data") + "slicker/cardapplets");
		QString desktopPath = KGlobal::dirs()->findResource("cardapplets", desktopFile);

		if (desktopPath == QString::null) return 0L;

		PluginInfo info(desktopPath, configFile);
		return createCard(info, group);
}
コード例 #9
0
ファイル: deck.c プロジェクト: camilohel777/ansiCprojects
/* Creates a deck of cards. */
void createDeck(Card deck[]){
    
    int i, j, k;
    k = 0;
    for (i = ACE; i <= KING; i++) {
        for (j = CLUBS; j <= SPADES; j++) {
            deck[k] = createCard(j, i);
            k++;
        }
    }
}
コード例 #10
0
ファイル: gendertest.cpp プロジェクト: KDE/kcontacts
void GenderTest::shouldExportEmptyGender()
{
    KContacts::AddresseeList lst;
    KContacts::Addressee addr;
    addr.setEmails(QStringList() << QStringLiteral("*****@*****.**"));
    addr.setUid(QStringLiteral("testuid"));
    lst << addr;
    KContacts::VCardTool vcard;
    const QByteArray ba = vcard.exportVCards(lst, KContacts::VCard::v4_0);
    QByteArray expected = createCard(QByteArray());
    QCOMPARE(ba, expected);
}
コード例 #11
0
CardDesk::Card *SlickerCardManager::newCardDialog()
{
	//should new card dialog return an object rather than pointer?
	QString cardDesktopFile = NewCardDialog::selectPlugin();
	if (cardDesktopFile == QString::null)
		return 0L;
	CardDesk::Card *card = createCard(cardDesktopFile);
	if (card) {
		registerCard(card);
		return card;
	}
	//cancel pressed
	return 0L;
}
コード例 #12
0
ファイル: gendertest.cpp プロジェクト: KDE/kcontacts
void GenderTest::shouldExportOnlyGenderWithoutTypeCommentGender()
{
    KContacts::AddresseeList lst;
    KContacts::Addressee addr;
    addr.setEmails(QStringList() << QStringLiteral("*****@*****.**"));
    addr.setUid(QStringLiteral("testuid"));
    KContacts::Gender gender;
    gender.setComment(QStringLiteral("comment"));
    addr.setGender(gender);
    lst << addr;
    KContacts::VCardTool vcard;
    const QByteArray ba = vcard.exportVCards(lst, KContacts::VCard::v4_0);
    QByteArray expected = createCard(QByteArray("GENDER:;comment"));
    QCOMPARE(ba, expected);
}
コード例 #13
0
    void createContent(int width, int height, Canvas& canvas) override {
        mBg = createBitmapNode(canvas, 0xFF9C27B0, 0, 0, width, height);
        canvas.drawRenderNode(mBg.get());

        canvas.insertReorderBarrier(true);
        mSingleBitmap = mAllocator(dp(160), dp(120), kRGBA_8888_SkColorType,
                                   [](SkBitmap& skBitmap) { skBitmap.eraseColor(0xFF0000FF); });

        for (int y = dp(18) - dp(178); y < height - dp(18); y += dp(178)) {
            bool isFirstCard = true;
            for (int x = dp(18); x < width - dp(18); x += dp(178)) {
                sp<RenderNode> card = createCard(x, y, dp(160), dp(160), isFirstCard);
                isFirstCard = false;
                canvas.drawRenderNode(card.get());
                mCards.push_back(card);
            }
        }
        canvas.insertReorderBarrier(false);
    }
コード例 #14
0
int main ()
{
	int** newCard; 
	int index;
	Player Harry; //This is how you make a player. 
	Player Bob
	for(index=0; index<10; index++)//generate bingoCards for every player connected
	{
		newCard = createCard();
		initCard(newCard);
	}
	
	/*Heres a little demo on how you would access elements inside the struct*/
	strncpy(Harry.playerName,"Harrison",20); //copy Name into the structs playerName field.
	Harry.playerBingoCard = newCard; //give Harry his bingo card so he can beat old women at bingo 
	printf("Player Name: %s\n", Harry.playerName); //access Player's name
	printCard(Harry.playerBingoCard); //access Player's bingo card	
	return 0; 	
}
コード例 #15
0
    void createContent(int width, int height, TestCanvas& canvas) override {
        srand(0);
        cardHeight = dp(60);
        cardSpacing = dp(16);
        cardWidth = std::min((height - cardSpacing * 2), (int)dp(300));
        cardLeft = (width - cardWidth) / 2;

        for (int y = 0; y < height + (cardHeight + cardSpacing - 1); y += (cardHeight + cardSpacing)) {
            cards.push_back(createCard(cards.size(), y));
        }
        listView = TestUtils::createNode(0, 0, width, height,
                [this](RenderProperties& props, TestCanvas& canvas) {
            for (size_t ci = 0; ci < cards.size(); ci++) {
                canvas.drawRenderNode(cards[ci].get());
            }
        });

        canvas.drawColor(Color::Grey_500, SkXfermode::kSrcOver_Mode);
        canvas.drawRenderNode(listView.get());
    }
コード例 #16
0
void HelloWorld::showInitCards(){
    for (int tag = 1; tag <= 10; tag++) {
        auto card = getChildByTag(tag);
        if (card) {
            card->removeFromParent();
        }
    }
    
    //5列 x 2行分のループ
    for (int x = 0; x < 5; x++) {
        for (int y = 0; y < 2; y++) {
            PosIndex posIndex;
            posIndex.x = x;
            posIndex.y = y;
            
            //カードの生成
            createCard(posIndex);
        }
    }
}
コード例 #17
0
ファイル: decks.c プロジェクト: hardesc/HardesBlackJack
/*
 Initialize an instance of struct deck by creating instances of struct card and initializing
 them using global arrays of pointers to structs of type cardValue and cardSuit, respectively.
 Set the cards_left property to the size of the deck.
 -----------------------------------------------------------------------------------------
 Parameters: deck *d
 Preconditions:
 - d is not null
 - global values: NO_OF_CARDS, NO_OF_DECKS, NO_OF_SUITS, NO_OF_CARD_ALUES, and NO_OF_EXTRA_CARDS are
   accurately entered and correspond to the aforementioned global arrays to be filled here
 - Total number of cards in the deck is equal to the # of suits times the # of values + extras
 Postconditions: The deck is initialized and filled with NO_OF_CARDS instances of struct card pointers.
 */
void _initDeck(deck *d){
    
    int g, h,i, j, k = 0;
    assert(d);
    assert(NO_OF_CARDS == NO_OF_DECKS * ((NO_OF_SUITS * NO_OF_CARD_VALUES) + NO_OF_EXTRA_CARDS));
    
    makeCardSuits(suitArr);//fills the global array of pointers to cardSuit structs
    makeCardValues(valueArr);//fills the global array of pointers to cardValue structs
    if (HI_LO_ACES == 1) {
        makeHiLoAces(hi_loAceArr);/*fills the global array of pointers to separate card structs (so that changing one ace to hi/lo does not change all aces to hi/lo.*/
    }
    if (NO_OF_EXTRA_CARDS > 0) {
        makeExtraCards(extraCardsArr);
    }
    
    /*deck loop*/
    for (h = 0; h < NO_OF_DECKS; h++) {
        
        /*cardSuit loop*/
        for (i = 0; i < NO_OF_SUITS; i++){
            d->suits[i] = suitArr[i];
            /*cardValue loop*/
            for(j = 0; j < NO_OF_CARD_VALUES; j++){
                d->values[i] = valueArr[i];
                d->cards[k] = createCard(valueArr[j], suitArr[i]);
                if ((HI_LO_ACES == 1) && (strcmp(d->cards[k]->value->name, "Ace") == 0)) {
                    d->cards[k]->value = hi_loAceArr[i];
                }
                k++;
            }
        }
        for (g = 0; g < NO_OF_EXTRA_CARDS; g++) {
            d->cards[k] = extraCardsArr[g];
        }
    }
    d->cards_left = NO_OF_CARDS;
    d->top = d->cards[NO_OF_CARDS - 1];
}
コード例 #18
0
void SlickerCardManager::loadCards()
{
 	kdDebug(155004) << ("SlickerCardManager::loadCards()\n");
 	KConfig *config = kapp->config();

	config->setGroup("General");
 	QStringList ids = config->readListEntry("Cards");

 	for (QStringList::Iterator it = ids.begin(); it != ids.end(); ++it)
 	{
 		kdDebug(155004) << "found card: " << *it << endl;
		QString groupName = QString("Card_").append(*it);
		
		if (!config->hasGroup(groupName)) continue;
		KConfigGroup group(config,groupName);

 		CardDesk::Card *card = createCard(group.readEntry("AppletDesktopFile"), group.readEntry("AppletConfigFile"), &group);

		if (!card) continue;
		card->setCardId(*it);
		registerCard(card);

 	}
}
コード例 #19
0
ファイル: hsi_ks55.cpp プロジェクト: bobgates/ExtPlane-Panel
HSI::HSI(QObject *parent, ExtPlaneConnection *conn) :
PanelItem(parent), _client(this, typeName(), conn)
{
    
    _bezel = QPixmap::fromImage(QImage(QString("../../images/KCS_55_bezel.png")), Qt::AutoColor);
    
    _thickBars=10;
    _thinBars=5;
    _numbers=30;
    
    createCard(); 
   
    _heading=45;
    
    /*
     hsi_bearing_deg_mag_pilot          float	930+	no	degrees_magnetic	Indicated relative bearing to the pilot's HSI-selected navaid
     hsi_relative_bearing_deg_pilot     float	930+	no	degrees             Indicated relative bearing to the pilot's HSI-selected navaid
     hsi_flag_from_to_pilot             int     930+	no	enum                Nav-To-From indication, nav1, pilot, 0 is flag, 1 is to, 2 is from.
     hsi_hdef_dots_pilot                float	930+	no	dots                CDI lateral deflection in dots, nav1, pilot
     hsi_vdef_dots_pilot                float	930+	no	dots                CDI vertical deflection in dots, nav1, pilot
     hsi_has_dme_pilot                  int     930+	no	boolean             Is there a DME signal from nav1's DME? 1 if yes, 0 if no
     hsi_dme_distance_nm_pilot          float	930+	no	nautical_miles      nav1 DME distance in nautical miles, pilot HSI
     hsi_dme_speed_kts_pilot            float	930+	no	knots               nav1 DME speed in knots. pilot HSI
     hsi_dme_time_min_pilot             float	930+	no	minutes             nav1 DME time in minutes. pilot HSI
     hsi_flag_glideslope_pilot          int     940+	no	boolean             Glide slope flag, pilot side HSI
     hsi_display_horizontal_pilot       int     940+	no	boolean             Is there some kind of horizontal signal on pilot side HSI
     hsi_display_vertical_pilot         int     940+	no	boolean             Is there some kind of vertical signal on pilot side HSI
     */
    
    /*  {
     QString         name;
     float           tolerance;
     DataRefType     dataType;
     void *          value;
     }; */  

    //QList<DataRefStruct *> _dataRefs;
/*    
    bool    _hasDME;
    int     _toFrom;  // 0 = Flag, 1=To, 2=From
*/    
    
    const static DataRefStruct dataRefs[] = {
        {"sim/cockpit2/gauges/indicators/heading_AHARS_deg_mag_pilot", 0.2, 
            drFloat, &_heading},
        {"sim/cockpit2/radios/actuators/hsi_obs_deg_mag_pilot", 0.2,    // direction of yellow line
            drFloat, &_course},
        {"sim/cockpit2/radios/indicators/hsi_hdef_dots_pilot",0.01,       
            drFloat, &_hdots},
        {"sim/cockpit2/radios/indicators/hsi_vdef_dots_pilot",0.05,
            drFloat, &_vdots},
        {"sim/cockpit2/radios/indicators/hsi_dme_distance_nm_pilot",0.1,           //
            drFloat, &_dme},
        {"sim/cockpit2/radios/indicators/hsi_flag_glideslope_pilot",0.1,           //
            drFloat, &_glideslopeFlag},
        {"sim/cockpit2/radios/indicators/hsi_display_horizontal_pilot",0.2,
            drFloat, &_hasHorizontal},
        {"sim/cockpit2/radios/indicators/hsi_display_vertical_pilot",0.2,      
            drFloat, &_hasVertical},
        {"sim/cockpit2/radios/indicators/hsi_has_dme_pilot",0.2,          
            drFloat, &_hasDME},
        {"sim/cockpit2/radios/indicators/hsi_dme_time_min_pilot",0.2,           
            drFloat, &_dmeTime},
        {"sim/cockpit2/radios/indicators/hsi_flag_from_to_pilot",0.2,           
            drFloat, &_toFrom},
        {"sim/cockpit2/autopilot/heading_dial_deg_mag_pilot",0.2,           // Orange bug
            drFloat, &_bug}
    };

    connect(&_client, SIGNAL(refChanged(QString,double)), this, SLOT(refChanged(QString,double)));
    int nDataRefs = 12;
    
    for (int i=0;i<nDataRefs;i++){
        _dataRefLookup.insert(dataRefs[i].name, dataRefs[i]);//.value);
        _client.subscribeDataRef(dataRefs[i].name, dataRefs[i].tolerance);
    }
}
コード例 #20
0
ファイル: game.c プロジェクト: harrison-n/osGameTerminal
void *connection_handler(void *socket_desc)
{
	//Get the socket descriptor
	int sock = *(int*)socket_desc;
	int read_size;
	char *message , client_message[2000];

	/*close(0); 
	close(1); 
	close(2); */
	dup2( sock, STDOUT_FILENO );  /* duplicate socket on stdout */
	dup2( sock, STDERR_FILENO );  /* duplicate socket on stderr too */
	dup2( sock, STDIN_FILENO );

	int** newCard;
	int index;
	int numbCalledArray[1000] = {0};
	int *ptrCalledArrayTail;
	ptrCalledArrayTail = numbCalledArray;

	Player Harry; //This is how you make a player.

	newCard = createCard();
	initCard(newCard);
 

	/*Heres a little demo on how you would access elements inside the struct*/
	strncpy(Harry.playerName,"Harrison",20); //copy Name into the structs playerName field.
	Harry.playerBingoCard = newCard; //give Harry his bingo card so he can beat old women at bingo
	printf("Player Name: %s\n", Harry.playerName); //access Player's name
	printCard(Harry.playerBingoCard); //access Player's bingo card


	/*Heres a demo on how you would draw a number
	ptrCalledArrayTail = drawNumber(ptrCalledArrayTail, numCalledArray);
	printf("The final number drawn is %d", *ptrCalledArrayTail--);
	*/
     
    //Send some messages to the client
    //message = "Greetings! I am your connection handler\n";
    //write(sock , message , strlen(message));

    

    drawStuff(Harry.playerBingoCard);  
    //write(sock , drawStuff(Harry.playerBingoCard) , strlen(message));
     
    //Receive a message from client
    /*while( (read_size = recv(sock , client_message , 2000 , 0)) > 0 )
    {
        //Send the message back to client
        write(sock , client_message , strlen(client_message));
    
	bzero(client_message, 2000);
    }
     
    if(read_size == 0)
    {
        puts("Client disconnected");
        fflush(stdout);
    }
    else if(read_size == -1)
    {
        perror("recv failed");
    }
     */
         
    //Free the socket pointer
    free(socket_desc);
     
    return 0;
}