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


C++ Fleet::asignBullet方法代码示例

本文整理汇总了C++中Fleet::asignBullet方法的典型用法代码示例。如果您正苦于以下问题:C++ Fleet::asignBullet方法的具体用法?C++ Fleet::asignBullet怎么用?C++ Fleet::asignBullet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Fleet的用法示例。


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

示例1: main

int main ( int argc, char** argv ){

    if ( SDL_Init( SDL_INIT_EVERYTHING ) < 0 ) {
        printf( "Unable to init SDL: %s\n", SDL_GetError() );
        return 1;
    }
    // make sure SDL cleans up before exit
    atexit(SDL_Quit);
    // create a new window
    screen = SDL_SetVideoMode(900, 600, 8, SDL_HWSURFACE|SDL_DOUBLEBUF);
    if ( !screen ) {
        printf("Unable to set 640x480 video: %s\n", SDL_GetError());
        return 1;
    }


    Fleet f;
    Bullet b3;
    f.asignBullet(&b3);



    Barrier bar1(000,98,1);
   	/* Barrier bar2(000,200,1);
    Barrier bar3(000,300,1);
	Barrier bar4(000,400,0);
	Barrier bar5(000,500,0);
	Barrier bar6(000,599,0);*/


    Ship s2;
    s2.position(  (GAME_W /2)  + 100 ,GAME_H-30);
	//s2.setMode(2);
   	Bullet b2;
    b2.setDownOrientation();
    s2.asignBullet(&b2);


    Ship s1;
	//s1.setMode(1);
    s1.position( (GAME_W / 2)- 100 , GAME_H-30);
    Bullet b1;
    s1.asignBullet(&b1);


    SideBar sb;



    actors.push_back(&b1);
    actors.push_back(&b2);
   // actors.push_back(&b3);
   // actors.push_back(&f);

    actors.push_back(&bar1);


    Bonus bonus;
    actors.push_back(&bonus);
    actors.push_back(&sb);

    Stairs stairs(160,98,1);
    actors.push_back(&stairs);   

    actors.push_back(&s1);
    actors.push_back(&s2);

    Uint8 * keystate;
    bool done = false;

    while (!done)
    {
        //Start the frame timer
        fps.start();

        keystate = SDL_GetKeyState(NULL);
        if(keystate[SDLK_LEFT]) {
        	//if(!s1.climbing){
            	s1.moveLeft();
        	//}
        }
        if(keystate[SDLK_RIGHT]) {
            s1.moveRight();
        }

        if(keystate[SDLK_UP]) {
        	int collided = 0;
        	if(s1.onGround){
	        	for (int i=0; i<Stairs::SHIPS_QTY; i++) {
	                if (check_collision(s1.rect,stairs.rect[i])) {
	                	s1.climbing = true;
	                	s1.moveUp();
	                	collided = 1;
	                	//std::cout << "Climbing en true??" << s1.climbing << "\n";
	                }
	            }
				if(!collided){
					std::cout << "ELSEClimbing en true??" << s1.climbing << "\n";

	                s1.climbing= false;
//.........这里部分代码省略.........
开发者ID:tatianainama,项目名称:sisop,代码行数:101,代码来源:engine.cpp


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