当前位置: 首页>>代码示例>>C++>>正文


C++ drawSprite函数代码示例

本文整理汇总了C++中drawSprite函数的典型用法代码示例。如果您正苦于以下问题:C++ drawSprite函数的具体用法?C++ drawSprite怎么用?C++ drawSprite使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了drawSprite函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ufo

// entscheidet ob UFO erstellt oder aktualisert wird
void ufo(Game *g)
{
    // 1:1 Chance nach MIN_UFO_PAUSE
    if (!g->enemyContainer.ufo.alive && (MIN_UFO_PAUSE + g->enemyContainer.ufo.lastufo) < ms_time() && (rand() % 2)) {
        g->enemyContainer.ufo.lastufo = ms_time();
        g->enemyContainer.ufo.alive = true;
        g->enemyContainer.ufo.posx = -UFO_WIDTH;
        SDL_Rect rect = {g->enemyContainer.ufo.posx, BORDER_TOP + 5, UFO_WIDTH, UFO_HEIGHT};
        drawSprite(g->screen, &rect, "ufo.bmp");
    } else if (g->enemyContainer.ufo.alive) {
        // UFO lebt noch, Position Aktualisieren
        SDL_Rect rect = {g->enemyContainer.ufo.posx, BORDER_TOP + 5, UFO_WIDTH, UFO_HEIGHT};
        SDL_FillRect(g->screen, &rect, SDL_MapRGB(g->screen->format, 0, 0, 0));
        g->enemyContainer.ufo.posx += UFO_SPEED;
        rect.x = g->enemyContainer.ufo.posx;
        
        if (g->enemyContainer.ufo.posx < WIDTH) {
            // Zeichnen
            drawSprite(g->screen, &rect, "ufo.bmp");
        } else {
            // Außerhalb
            g->enemyContainer.ufo.lastufo = ms_time();
            g->enemyContainer.ufo.alive = false;
        }
    } else if ((MIN_UFO_PAUSE + g->enemyContainer.ufo.lastufo) < ms_time()) {
        // UFO Start verschieben
        g->enemyContainer.ufo.lastufo += ((rand() % 11) * 1000);
    }
}
开发者ID:mkaay,项目名称:spaceinvaders,代码行数:30,代码来源:game.c

示例2: render

void render()
{

    float rad;		// radians of rotation based on frame counter

    // clear the colour (drawing) and depth sort back (offscreen) buffers
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // count the frame and base a rotation on it.
    frame++;
    rad = frame * (0.0175f);

    for (int i=0; i<max_flares; i++) {
        drawSprite( flares[i].x,flares[i].y,flare_size,flare_size,0,flareTex);
    }
       
	
	drawSprite( mx,my,64,64,0,flareTex);

    // see printf documentation for the formatting of variables...
    glPrintf(100, 240, font1,"frame=%i, mousebtn: %i, targets: %i", frame, mx, max_targets);

    // swap the front (visible) buffer for the back (offscreen) buffer
    swapBuffers();

}
开发者ID:armageddon421,项目名称:gles2framework,代码行数:26,代码来源:test.c

示例3: initialiseBackgroundLayer

void Screen::splashScreen() {
	byte *bgfile = _vm->_resman->openResource(2950);

	initialiseBackgroundLayer(NULL);
	initialiseBackgroundLayer(NULL);
	initialiseBackgroundLayer(_vm->fetchBackgroundLayer(bgfile));
	initialiseBackgroundLayer(NULL);
	initialiseBackgroundLayer(NULL);

	_vm->fetchPalette(bgfile, _palette);
	setPalette(0, 256, _palette, RDPAL_FADE);
	renderParallax(_vm->fetchBackgroundLayer(bgfile), 2);

	closeBackgroundLayer();

	byte *loadingBar = _vm->_resman->openResource(2951);
	byte *frame = _vm->fetchFrameHeader(loadingBar, 0);

	AnimHeader animHead;
	CdtEntry cdt;
	FrameHeader frame_head;

	animHead.read(_vm->fetchAnimHeader(loadingBar));
	cdt.read(_vm->fetchCdtEntry(loadingBar, 0));
	frame_head.read(_vm->fetchFrameHeader(loadingBar, 0));

	SpriteInfo barSprite;

	barSprite.x = cdt.x;
	barSprite.y = cdt.y;
	barSprite.w = frame_head.width;
	barSprite.h = frame_head.height;
	barSprite.scale = 0;
	barSprite.scaledWidth = 0;
	barSprite.scaledHeight = 0;
	barSprite.type = RDSPR_RLE256FAST | RDSPR_TRANS;
	barSprite.blend = 0;
	barSprite.colourTable = 0;
	barSprite.data = frame + FrameHeader::size();
	barSprite.isText = false;

	drawSprite(&barSprite);

	fadeUp();
	waitForFade();

	for (int i = 0; i < animHead.noAnimFrames; i++) {
		frame = _vm->fetchFrameHeader(loadingBar, i);
		barSprite.data = frame + FrameHeader::size();
		drawSprite(&barSprite);
		updateDisplay();
		_vm->_system->delayMillis(30);
	}

	_vm->_resman->closeResource(2951);

	fadeDown();
	waitForFade();
}
开发者ID:jweinberg,项目名称:scummvm,代码行数:59,代码来源:screen.cpp

示例4: while

void SLib::drawMap(std::map<int, std::map<int, int> > _map)
{
  unsigned int i = 0;
  unsigned int j;

  this->m_window.clear();

  while (i < _map.size())
    {
      j = 0;
      while (j < _map[0].size())
	{
	  switch (_map[i][j])
	    {
	    case 0: //WALL
	      drawSprite(this->Wall, i, j);
	      break;
	    case 2:
	      if (this->_type == NIBBLER)
		drawSprite(this->snake, i, j); //BODY
	      else
		drawSprite(this->Pac, i, j);
	      break;
	    case 3:
	      drawSprite(this->foodPicture, i, j);
	      break;
	    case 7:
	      drawSprite(this->Rouge, i, j); //ROUGE
	      break;
	    case 4:
	      drawSprite(this->Rose, i, j); //ROSE
	      break;
	    case 5:
	      drawSprite(this->Orange, i, j); // ORANGE
	      break;
	    case 6:
	      drawSprite(this->Bleu, i, j);//BLEU
	      break;
	    case 1:
	      drawSprite(this->Grass, i, j); //FLOOR
	      break;
	    case 8:
	      drawSprite(this->foo, i, j);
	      break;
	    }
	  j++;
	}
      i++;
    }
  AffScore();
  AffLife();
  this->m_window.display();
}
开发者ID:Zibaire,项目名称:epitech_projects,代码行数:53,代码来源:SLib.cpp

示例5: renderAlive

void renderAlive(void) {
	if (aimY > 0.0f) {
		drawCanon();
		drawBody();
	} else {
		drawBody();
		drawCanon();
	}

	if (firing) drawFire();

	drawSprite(locX+aimX, locY+aimY,	SCALE_CROSSHAIR, 0.0f, BLOCK_CROSSHAIR1, 0);
	drawSprite(locX+lookX, locY+lookY,	SCALE_CROSSHAIR, 0.0f, BLOCK_CROSSHAIR2, 0);
}
开发者ID:carlmartus,项目名称:ld30_multiverse,代码行数:14,代码来源:dude.c

示例6: beginScene

//=============================================================================
// Return the number of pixels colliding between the two sprites.
// Pre: The device supports a stencil buffer and pOcclusionQuery points to
// a valid occlusionQuery object.
// Post: Returns the number of pixels of overlap
//=============================================================================
DWORD Graphics::pixelCollision(const SpriteData &sprite1, const SpriteData &sprite2)
{
    if(!stencilSupport)     // if no stencil buffer support
        return 0;

    beginScene();

    // Set up stencil buffer using current entity
    device3d->SetRenderState(D3DRS_STENCILENABLE,   true);
    device3d->SetRenderState(D3DRS_STENCILFUNC,     D3DCMP_ALWAYS);
    device3d->SetRenderState(D3DRS_STENCILREF,      0x1);
    device3d->SetRenderState(D3DRS_STENCILMASK,     0xffffffff);
    device3d->SetRenderState(D3DRS_STENCILWRITEMASK,0xffffffff);
    device3d->SetRenderState(D3DRS_STENCILFAIL,     D3DSTENCILOP_KEEP);
    device3d->SetRenderState(D3DRS_STENCILPASS,     D3DSTENCILOP_REPLACE);

    // Write a 1 into the stencil buffer for each non-transparent pixel in ent
    spriteBegin();
    // Enable stencil buffer (must be after spriteBegin)
    device3d->SetRenderState(D3DRS_STENCILENABLE,   true);
    drawSprite(sprite2);            // write 1s to stencil buffer
    spriteEnd();

    // Change stencil buffer to only allow writes where the stencil value is 1
    // (where the ent sprite is colliding with the current sprite)
    device3d->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_EQUAL);
    device3d->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_KEEP);
    
    // Begin occlusion query to count pixels that are drawn
    pOcclusionQuery->Issue(D3DISSUE_BEGIN);

    spriteBegin();
    // Enable stencil buffer (must be after spriteBegin)
    device3d->SetRenderState(D3DRS_STENCILENABLE,   true);
    drawSprite(sprite1);            // draw current entity 
    spriteEnd();
    // End occlusion query
    pOcclusionQuery->Issue(D3DISSUE_END);

    // Wait until the GPU is finished.
    while(S_FALSE == pOcclusionQuery->GetData( &numberOfPixelsColliding, 
                                  sizeof(DWORD), D3DGETDATA_FLUSH ))
    {}

    // Turn off stencil
    device3d->SetRenderState(D3DRS_STENCILENABLE, false);

    endScene();
    return numberOfPixelsColliding;
}
开发者ID:Danice123,项目名称:DungeonCrawler,代码行数:56,代码来源:graphics.cpp

示例7: drawSprite

	void Animation::draw(float deltaTime, float x, float y, float w, float h, const GameShader& shader) {
		time_ += deltaTime * speed_;
		if (reset_) {
			reset_ = false;
			lastTime_ = time_;
		}

		if (frames_.getSize() > 0) {
			// New frame?
			if (!end_ && time_ > frames_[index_].time_ + lastTime_) {
				if (loop_) {
					index_ = (1 + index_) % frames_.getSize();
				} else {
					if (index_ + 1 < frames_.getSize()) {
						++index_;
					} else {
						end_ = true;
					}
				}
				lastTime_ = time_; // Frame updated.
			}

			Frame& frame = frames_[index_];
			drawSprite(frame.sprite_, shader, x, y, w * frame.sprite_.getWidth() / frame.bodyWidth_, h * frame.sprite_.getHeight() / frame.bodyWidth_);
		}
	}
开发者ID:mwthinker,项目名称:Zombie,代码行数:26,代码来源:animation.cpp

示例8: animate_spermicides

void animate_spermicides(char *base) {

	if (spermicides->first == NULL) return;

	lst_iitem_t* curSp;
	
	int n = 0;
	for(curSp = spermicides->first; curSp != NULL; curSp = curSp->next)
		n++;
	
	for(curSp = spermicides->first; curSp != NULL; curSp = curSp->next){
		destroySprite(curSp->spr, base);
		
		if (!check_spermicide_colision(curSp->spr,curSp->spr->y - curSp->spr->yspeed)) {
			curSp->spr->y -= curSp->spr->yspeed;
			drawSprite(curSp->spr, base);
		}
		else {
			deleteSprite(curSp->spr);
			curSp = lst_remove(spermicides, curSp->spr);
			if (curSp == NULL) break;
		}
	}
	
}
开发者ID:BGCX261,项目名称:zoidslcom-svn-to-git,代码行数:25,代码来源:sperm.c

示例9: GraffitiFormHandleEvent

static Boolean GraffitiFormHandleEvent(EventPtr event){
  Boolean handled = false;
  switch (event->eType) {
    case frmOpenEvent:
      FrmDrawForm(FrmGetActiveForm());
      handled = true;
      break;
    case keyDownEvent:
      if(event->data.keyDown.chr == sentence[offset]){
        offset++;
        if(offset == StrLen(sentence)){ FrmGotoForm(WinForm); }
      }
      handled = true;
      break;
    case nilEvent: {
      if(offset < StrLen(sentence)){
        updateSprite(&nextLetter);
        drawSprite(&nextLetter);
      }
      handled = true;
      break;
    }
    default:
      break;
  }
  return handled;
}
开发者ID:ysei,项目名称:palmos,代码行数:27,代码来源:IntExp.c

示例10: Draw

static void Draw(struct SPRITE *s)
{

    // pipe into standard draw routine, compensating for camera use
    drawSprite(s, s->box.centerX, s->box.bottom);

}
开发者ID:spaceflounder,项目名称:sr389,代码行数:7,代码来源:sprite.c

示例11: drawEntity

void drawEntity(Game* game, Entity* entity)
{
	if(entity->texture)
	{
		Pointf location = createPointf(
			entity->position.x - entity->origin.x, 
			entity->position.y - entity->origin.y);
			
		drawTexture(game, entity->texture, location, entity->depth);
	}
	
	if(entity->drawRectangle)
	{
		Rectanglei rectangle = createRectanglei(
			(int)entity->position.x - entity->origin.x + entity->offset.x,
			(int)entity->position.y - entity->origin.y + entity->offset.y,
			entity->size.x,
			entity->size.y
		);
		
		drawRectangle(game, rectangle, entity->color);
	}
	
	if(entity->sprite.alive)
	{
		drawSprite(game, &entity->sprite);
	}
}
开发者ID:Jools64,项目名称:shmup,代码行数:28,代码来源:engine.c

示例12: SmallText

void SmallText(char* strg,int x,int y)						//Output text (numbers only) using small graphics font
{
	int str_length=strlen(strg)-1;
    int scr_print;
	for (scr_print=0;scr_print<=str_length;scr_print++)
        drawSprite(smallfont,screen,(strg[scr_print]-48)*8,0,(scr_print*8)+x,y,8,8);
}
开发者ID:dave18,项目名称:Fuzed,代码行数:7,代码来源:fuzed.cpp

示例13: Text

void Text(char* strg,int x,int y)						//Output text using graphics font
{
	int str_length=strlen(strg)-1;
    int scr_print;
	for (scr_print=0;scr_print<=str_length;scr_print++)
        drawSprite(font,screen,(strg[scr_print]-32)*16,0,(scr_print*16)+x,y,16,16);
}
开发者ID:dave18,项目名称:Fuzed,代码行数:7,代码来源:fuzed.cpp

示例14: drawTextbox

void drawTextbox(){
    int i, j;
    int shiftX = (SCREEN_WIDTH / 2) - (textboxSprite->width / 2);
    int shiftY = SCREEN_HEIGHT - 20 - textboxSprite->height;
    int alphaX, alphaY;
    int charX, charY;
    int charNum;
    int OFFSET = 14;
    int LINE_SPACE = 6;
    
    drawSprite(textboxSprite, shiftX, shiftY);
    for (i = currLine; i < currLine + NUM_LINES && i < numLines; i++){
        for (j = 0; j < NUM_CHAR_LINE; j++){
            if (lines[i][j] == '\0'){
                break;
            }
            
            charNum = lines[i][j] - 32;
            if (charNum < 0 || charNum > 94){
                charNum = 99;
            }
            
            
            alphaX = ((lines[i][j] - 32) % ALPHA_WIDTH) * LETTER_WIDTH;
            alphaY = ((lines[i][j] - 32) / ALPHA_HEIGHT) * LETTER_HEIGHT;
            charX = shiftX + OFFSET + (j * LETTER_WIDTH);
            charY = shiftY + OFFSET + ((i - currLine) * (LINE_SPACE + LETTER_HEIGHT));
            drawSpriteSrcDst(alphabetSprite, alphaX, alphaY, LETTER_WIDTH, LETTER_HEIGHT, charX, charY);
        }
    }
}
开发者ID:albong,项目名称:ominsquash_prototype,代码行数:31,代码来源:textbox.c

示例15: healthBar

/**
* @brief Displays the players health bar.
*/
void healthBar()
{
	Vec2d scale;
	scale.y= 1;
	scale.x = (float)(playerData.health)/playerData.maxhealth;
	drawSprite(health_bar,0,vec2d(10,50),scale,0,gt_graphics_get_active_renderer());
}
开发者ID:ljg6,项目名称:MyGame2D,代码行数:10,代码来源:game.c


注:本文中的drawSprite函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。