• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ drawSprite函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: rect

void ComposerEngine::redraw() {
	if (!_needsUpdate && _dirtyRects.empty())
		return;

	for (Common::List<Sprite>::iterator i = _sprites.begin(); i != _sprites.end(); i++) {
		Common::Rect rect(i->_pos.x, i->_pos.y, i->_pos.x + i->_surface.w, i->_pos.y + i->_surface.h);
		bool intersects = false;
		for (uint j = 0; j < _dirtyRects.size(); j++) {
			if (!_dirtyRects[j].intersects(rect))
				continue;
			intersects = true;
			break;
		}
		if (!intersects)
			continue;
		drawSprite(*i);
	}

	for (uint i = 0; i < _dirtyRects.size(); i++) {
		const Common::Rect &rect = _dirtyRects[i];
		byte *pixels = (byte *)_screen.getBasePtr(rect.left, rect.top);
		_system->copyRectToScreen(pixels, _screen.pitch, rect.left, rect.top, rect.width(), rect.height());
	}
	_system->updateScreen();

	_needsUpdate = false;
	_dirtyRects.clear();
}
开发者ID:athrxx,项目名称:scummvm,代码行数:28,代码来源:graphics.cpp


示例17: drawShowCountDown

void drawShowCountDown(SDL_Surface* screen,int i)
{
  psysSet_t ps;

  drawSprite(screen, graphics.countDownSpr[i], HSCREENW-140/2,HSCREENH-60/2);

  if(i!=lastShown)
  {
    ps.layer=PSYS_LAYER_TOP;
    ps.x=HSCREENW-140/2;
    ps.y=HSCREENH-60/2;
    ps.vel=20; // +/- in each dir
    ps.life=1000;
    ps.lifeVar=1300;
    ps.fade=0;
    ps.gravity=0;
    ps.bounce=1;      //If 1, particles will bounce off screen borders ( (vel * -1)/2 )
    ps.fadeColor=0x00;
    ps.srcImg=graphics.countDownSpr[i]->img;
    ps.srcRect=graphics.countDownSpr[i]->clip;

    spawnParticleSystem(&ps);

    lastShown=i;
  }

}
开发者ID:manolaz,项目名称:Wizznic,代码行数:27,代码来源:draw.c


示例18: pause_menu

int pause_menu()
{
  static int i = 0;
  SDL_Renderer *render;
  render = gt_graphics_get_active_renderer();
  SDL_RenderClear(gt_graphics_get_active_renderer());
  ResetBuffer();
  mainScreen = loadSprite("images/pause_screen.png",800,600,1);
  selection = loadSprite("images/selection.png",149,53,1);
  if(i == 0)
	{
		drawSprite(mainScreen,0,vec2d(0,0),vec2d(1,1),0,gt_graphics_get_active_renderer());
		drawSprite(selection,0,vec2d(311,294),vec2d(1,1),0,gt_graphics_get_active_renderer());
  }else if(i ==1)
  {
	  drawSprite(mainScreen,0,vec2d(0,0),vec2d(1,1),0,gt_graphics_get_active_renderer());
	  drawSprite(selection,0,vec2d(311,377),vec2d(1,1),0,gt_graphics_get_active_renderer());
	  
  }
  NextFrame();
  SDL_PumpEvents();
  keys = SDL_GetKeyboardState(NULL);
  if(keys[SDL_SCANCODE_ESCAPE])
    {
        done = 1;
    }
  if(keys[SDL_SCANCODE_DOWN])
    {
	  i = 1;
	}
  if(keys[SDL_SCANCODE_UP])
  {
	  i = 0;
  }
  if(keys[SDL_SCANCODE_RETURN])
  {
	  if(i == 0)
	  {
		  gameState = 1;
	  }
	  else
	  {
		  done = 1;
	  }
  }	  
   return 1;
}
开发者ID:ljg6,项目名称:MyGame2D,代码行数:47,代码来源:game.c


示例19: move

void move() {
  // Для алгоритма поиска поути
  if(!path_find()) {
    if(playSound) soundBadMove();
    return;
  }

  if(showPath) {
    // Рисуем шаги на экране
    path_save();
    while(1) {
      switch(path_nextStep()) {
        case 1: drawSpriteStep(path_x, path_y+1, 0); break;
        case 2: drawSpriteStep(path_x, path_y-1, 1); break;
        case 3: drawSpriteStep(path_x+1, path_y, 2); break;
        case 4: drawSpriteStep(path_x-1, path_y, 3); break;
      }
      drawSprite(path_x, path_y, path_c);
      if(path_n==LAST_STEP) break;
      if(playSound) soundJumpSel();
      delay(STEP_SPEED);
    };
 
    // Удаляем нарисованные шаги с экрана
    path_load();
    while(1) {
      drawSprite(path_x, path_y, 0);
      path_nextStep();
      if(path_n==LAST_STEP) break;
    };
  } else {
    drawSprite(selX, selY, 0);
    drawSprite(cursorX, cursorY, path_c);
  }

  // Реально перемещаем шарик. Все выше было лишь анимацией.
  game[cursorX][cursorY] = path_c;

  // Снимаем курсор
  selX = -1;

  // Очищаем игровое поле от временных значений
  path_end();
  
  // Добавляем 3 шарика
  gameStep();
}
开发者ID:VWarlock,项目名称:OldLines,代码行数:47,代码来源:lines.c


示例20: updateBlocks

void updateBlocks(Game *g)
{
    SDL_Rect rect;
    rect.h = 20;
    rect.w = 20;
    for (int i = 0; i < BLOCK_COUNT; i++) {
        for (int x = 0; x < BLOCK_WIDTH/BLOCK_TILE_WIDTH; x++) {
            for (int y = 0; y < BLOCK_HEIGHT/BLOCK_TILE_HEIGHT; y++) {
                rect.x = g->blocks[i].posx[x][y];
                rect.y = g->blocks[i].posy[x][y];
                
                if (g->blocks[i].damage[x][y] < MAX_BLOCK_DAMAGE) {
                    if (x == 0 && y == 0) {
                        drawSprite(g->screen, &rect, "block_topleft.bmp");
                    } else if (x == 3 && y == 0) {
                        drawSprite(g->screen, &rect, "block_topright.bmp");
                    } else if (x == 0 && y == 2) {
                        drawSprite(g->screen, &rect, "block_bottomleft.bmp");
                    } else if (x == 1 && y == 2) {
                        drawSprite(g->screen, &rect, "block_bottommiddleleft.bmp");
                    } else if (x == 2 && y == 2) {
                        drawSprite(g->screen, &rect, "block_bottommiddleright.bmp");
                    } else if (x == 3 && y == 2) {
                        drawSprite(g->screen, &rect, "block_bottomright.bmp");
                    } else {
                        drawSprite(g->screen, &rect, "block_fill.bmp");
                    }
                } else {
                    SDL_FillRect(g->screen, &rect, SDL_MapRGB(g->screen->format, 0, 0, 0));
                }
            }
        }
    }
}
开发者ID:mkaay,项目名称:spaceinvaders,代码行数:34,代码来源:game.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ drawString函数代码示例发布时间:2022-05-30
下一篇:
C++ drawSphere函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap