Beispiel #1
0
//Processes Options Menu
void OptionsMenu()
{
    DrawBG(0);              //cls
    echo_play_bgm(BGM_03);  //Play Nes_Mes2
    DrawBG(9);

    //Init text plane (Plane, text prio, text colors)
    VDP_setTextPlan(PLAN_B);
    VDP_setTextPriority(PTRUE);
    VDP_setPaletteColor((OBJPAL * 16)+15,0xE);    //Non higlited color
    VDP_setPaletteColor((PWRPAL * 16)+15,0xEE);   //Hilited color
    VDP_setTextPalette(OBJPAL);

    InitMenu(1,0,0,7,_FALSE);                   //Init a 6 item menu
    S_ID=0;
    M_ID=0;

    //Set joy handler to Options type
    JOY_setEventHandler( &BtnOptions );

    while (SItem==0)
    {
        VDP_waitVSync();
    }
    DrawBG(0);  //cls
}
Beispiel #2
0
//Processes Main Menu
void MainMenu()
{
    u8 Done=_FALSE;

    DrawBG(7);
    if (DBUG==_FALSE)
    {
        echo_wait_sfx(SFX_09);  //"Ultra Air Hockey!"
        echo_wait_sfx(SFX_08);  //Siren
    }

    Trig=PTRUE;
    //Loop until Done is PTRUE
    while (Done==_FALSE)
    {

        echo_play_bgm(BGM_02);              //Play HockeyFever (Loop)
        InitMenu(1,0,0,4,PTRUE);            //Init menu to 3 items
        JOY_setEventHandler(&BtnHMenu);   //Set appropriate button handler

        //While nothing is selected
        while (SItem==0)
        {
            VDP_waitVSync();
            //If a dir key was pressed, update the background to reflect highlighted choice
            if (Trig==PTRUE)
            {
                DrawBG(10+HItem);
            }
        }

        //Process the selected item
        switch (SItem)
        {
            //Play
            case 1:
                VDP_fadeOutAll(100,_FALSE);
                ChrselMenu();   //Do Char selection menu
                Done=PTRUE;
                break;

            //Options
            case 2:
                echo_wait_sfx(SFX_11);      //"Options"
                VDP_fadeOutAll(100,_FALSE);
                OptionsMenu();
                Trig=PTRUE;
                break;

            //Credits
            case 3:
                echo_wait_sfx(SFX_12);      //"Credits"
                VDP_fadeOutAll(100,_FALSE);
                Credits();
                Trig=PTRUE;
                break;
        }
    }
    JOY_setEventHandler( &BtnNada );    //Remove button handler
}
Beispiel #3
0
//Character selection menu
//@Fix glitchy BG screen and display of Arrow
void ChrselMenu()
{
    Sprite sprites[1];  //Sprite struct

    DrawBG(0);          //Cls
    DrawBG(8);          //Draw "How many players" BG
    InitMenu(1,0,0,3,_FALSE);   //Init a 2 item Menu

    //Setup the arrow sprite
    SYS_disableInts();
    SPR_init(16);   //Sprite tile cache of 16 tiles
    SYS_enableInts();

    // !@ Screws up
    SPR_initSprite(&sprites[0], &SPR_Arrow, 271, 266, TILE_ATTR(MISCPAL,TRUE,FALSE,FALSE));      //Init the Arrow Sprite
    VDP_setPalette(MISCPAL, SPR_Arrow.palette->data);                                              //Init pal OBJPAL to Arrow pal

    echo_play_sfx(SFX_13);              //"How many players are going to play today?"
    JOY_setEventHandler( &BtnHMenu );   //Setup joy handler to HMenu type
    //While no items are selected
    while (SItem==0)
    {
        //If 1 player hilighted
        if ((HItem==1) && (Trig==_FALSE))
        {
            SPR_setPosition(&sprites[0],271,266);   //Set new arrow position
            SPR_update(sprites, 1);                 //Update it
        }
        else
        {
            SPR_setPosition(&sprites[0],311, 266);
            SPR_update(sprites, 1);
        }
        VDP_waitVSync();
    }

    VDP_resetSprites();

    //@Toggle amt of players as appropriately
    if (SItem==1)
    {
        Opts[0]=_FALSE;
    }
    else
    {
        Opts[0]=PTRUE;
    }

    SPR_setPosition(&sprites[0],-128, -128);    //@Kill sprite
    SPR_update(sprites, 1);                     //Update it
    SPR_end;                                    //Kill sprite engine

    echo_wait_sfx(SFX_10);                      //"Let us play some hockey!"
    VDP_fadeOutAll(100,_FALSE);
}
Beispiel #4
0
//	--------------------------------------------------------------------
//	プレイヤー、敵、弾、背景の描画処理を呼ぶ
//	--------------------------------------------------------------------
void DrawGame()
{
    // 画面を初期化
    ClearDrawScreen();

    // 描画先画面を裏にする
    SetDrawScreen( DX_SCREEN_BACK );

    //	背景描画
    DrawBG();

    //	プレイヤーの描画処理
    DrawObject(Player);
    //	プレイヤーの弾描画
    DrawObject(PlayerShot);

    //	敵の描画
    DrawObject(Enemy);
    //	敵の弾描画
    DrawObject(EnemyShot);

    //	裏画面に描いたものを表画面に反映する
    ScreenFlip();

    return;
}
Beispiel #5
0
void InitVersus(){	
	LoadStage(stage);
	InitFighters(c1,c2);
	DrawBG(HUDBG);
	pausescr = LoadSprite("images/pause.png",1024,768,1);
	p1vic = LoadSprite("images/p1win.png",1024,768,1);
	p2vic = LoadSprite("images/p2win.png",1024,768,1);
	drawvic = LoadSprite("images/draw.png",1024,768,1);
}
Beispiel #6
0
void StageCanvas::OnDrawSprites() const
{
	if (m_edited && m_bg) 
	{
		s2::RenderParams params;
		params.mt = m_edited->GetLocalMat().Inverted();
		ee::SpriteRenderer::Instance()->Draw(m_bg, params);
	}

	DrawBG();

	m_panel->TraverseSprites(ee::DrawSpritesVisitor(GetVisibleRegion(), GetCameraScale()), ee::DT_VISIBLE);
//	m_panel->traverseShapes(ee::DrawShapesVisitor(sr), ee::DT_VISIBLE);

	m_stage->DrawEditOP();
}
Beispiel #7
0
//Joy handler for horizontal menu
void BtnHMenu(u16 joy, u16 changed, u16 state)
{
    if (joy == JOY_1)
    {
        //If Left pressed
        if (state & BUTTON_LEFT)
        {
            echo_wait_sfx(SFX_01);  //HiLite
            HItem--;                //Decrement HItem and wrap if necessary
            if (HItem<=MMin)
            {
                HItem=MMax-1;
            }
            Trig=_FALSE;
        }
        //if left released
        else if (changed & BUTTON_LEFT)
        {
            Trig=PTRUE;
        }

        //If Right button pressed
        if (state & BUTTON_RIGHT)
        {
            echo_wait_sfx(SFX_01);  //HiLite
            HItem++;                //Increment HItem, wrap if necessary
            if (HItem>=MMax)
            {
                HItem=MMin+1;
            }
            Trig=_FALSE;
        }
        else if (changed & BUTTON_RIGHT)
        {
            Trig=PTRUE;
        }

        //If Start pressed
        if (state & BUTTON_START)
        {
            echo_wait_sfx(SFX_02);  //Select
            SItem=HItem;            //Set SItem to HItem
            DrawBG(0);              //Cls
        }
    }
}
void
UIStatusBar::DrawFG(ILI9341_t3 *tft) {
  DrawBG(tft);

  tft->setTextColor(ILI9341_BLACK);
  tft->setTextSize(2);

  tft->setCursor(GetPaddedX(), GetPaddedY());
  char buf1[20];
  sprintf(buf1, "X=%3d Y=%3d", x, y);
  tft->println(buf1);

  tft->setCursor(GetPaddedX() + GetPaddedWidth()*3/4, GetPaddedY());
  char buf2[10];
  sprintf(buf2, "%4lums", millis() - last_time);
  last_time = millis();
  tft->print(buf2);

  SetDirty(true); // Always dirty, redraw every frame
}
Beispiel #9
0
void LoadStage(Stage_T stagesel){
	
	layer = (StageLayer*)malloc(sizeof(StageLayer));
	switch(stagesel){
		case ST_PLATFORM:
			st.bg = "images/bgimage1.png";
			SetLayer(layer,1,512,384,1536,1152,768,576,"images/bgimage2.png",1);
			SetLayer(layer->next,2,512,384,1536,1152,768,576,"images/bgimage2.png",1);
			SetLayer(layer->next->next,0,0,0,1024,768,0,0,"images/stage.png",0);
			
			platform.p_ypos = 540;
			platform.p_left = 220;
			platform.p_right = 790;
			platform.next=NULL;
			//	platform.next = (Platform*)malloc(sizeof(Platform));
		//	platform.next->p_ypos = 740;
		//	platform.next->p_left = 0;
		//	platform.next->p_right = 1024;
		//	platform.next->next=NULL;
			
			st.P1spawn= 270;
			st.P2spawn = 740;
			break;
		case ST_DEBUG:
		case ST_FIELD:
			st.bg = "images/bgtest.png";
			platform.p_ypos = 600;
			platform.p_left = 0;
			platform.p_right = 1025;
			SetLayer(layer,0,512,660,1722,162,861,81,"images/train.png",0);
			
			st.P1spawn = 200;
			st.P2spawn = 820;
			break;
	}
	st.platform_list = &platform;
	st.layer_list = layer;
	DrawBG(st.bg);
	
}
Beispiel #10
0
// ////////////////////////Apply section background/////////////////////////////
void LvlScene::setSectionBG(LevelSection section)
{
    //QGraphicsPixmapItem * item=NULL;
    QGraphicsRectItem * itemRect=NULL;
    QBrush brush;
    QPen pen;
    QPixmap image = QPixmap(QApplication::applicationDirPath() + "/" + "data/nobg.gif");
    QPixmap img;
    QPixmap img2; //Second image buffer
    //need a BGitem

    bool isUser1=false, isUser2=false, noimage=false;
    long x,y,h,w, j;

    if(
        (section.size_left!=0) ||
        (section.size_top!=0)||
        (section.size_bottom!=0)||
        (section.size_right!=0)
    )
    {   //Don't draw on unallocated section entry
        x=section.size_left;
        y=section.size_top;
        w=section.size_right;
        h=section.size_bottom;

        WriteToLog(QtDebugMsg, "SetSectionBG-> Check for user images");

        isUser1=false; // user's images are exist
        isUser2=false; // user's images are exist
        noimage=true;
        j = 0;
        if(section.background != 0 )
        {
            //Find user image
            for(j=0; j<uBGs.size(); j++)
            {
                if(uBGs[j].id==section.background)
                {
                    noimage=false;
                    if((uBGs[j].q==0)||(uBGs[j].q==2)) //set first image
                    {
                        img = uBGs[j].image;
                        isUser1=true;
                    }
                    if((uBGs[j].q>=1)) { // set Second image
                        img2 = uBGs[j].second_image;
                        isUser2=true;
                    }
                    break;
                }
            } //If not exist, will be used default

            j=pConfigs->getBgI(section.background);
            if(j>=0)
            {
                noimage=false;
                if(!isUser1)
                    img = pConfigs->main_bg[j].image;
                if(!isUser2)
                    img2 = pConfigs->main_bg[j].second_image;
            }

            if((noimage)&&(!isUser1))
            {
                WriteToLog(QtWarningMsg, "SetSectionBG-> Image not found");
                img=image;
            }
        }
        else noimage=true;

        //pConfigs->main_bg[j].type;

        brush = QBrush(QColor(0, 0, 0));
        //QBrush brush(QColor(255, 255, 255));
        pen = QPen(Qt::NoPen);
        //for (int i = 0; i < 11; i++) {

        //item = addRect(QRectF(x, y, , ), pen, brush);

        if((!noimage)&&(!img.isNull()))
        {
            //item = addPixmap(image);
            //item = new QGraphicsPixmapItem;
            DrawBG(x, y, w, h, section.id, img, img2, pConfigs->main_bg[j]);
            //BgItem[section.id]->setParentItem(item);
            //addItem(item);
            //item->setData(0, "BackGround"+QString::number(section.id) );
            //item->setPos(x, y);
        }
        else
        {
            itemRect = new QGraphicsRectItem;
            itemRect->setPen(pen);
            itemRect->setBrush(brush);
            itemRect->setRect(x, y, (long)fabs(x-w), (long)fabs(y-h));
            addItem(itemRect);
        }

        WriteToLog(QtDebugMsg, QString("SetSectionBG-> Item placed to x=%1 y=%2 h=%3 w=%4").arg(x).arg(y)
                   .arg((long)fabs(x-w)).arg((long)fabs(y-h)));
        //

        if(itemRect!=NULL)
        {
            itemRect->setData(0, QString("BackGround%1").arg(section.id) );
            itemRect->setZValue(bgZ);
        }

    } //Don't draw on reserved section entry

}
Beispiel #11
0
//Processes Credits screen
void Credits()
{
    JOY_setEventHandler( &BtnNada );    //Set Event handler to nothing
    const u8 x=1;       //Constant column value for text disp
    u8 y=1;             //Variable row ~
    const wait=3000;    //Time in MS to wait

    echo_play_bgm(BGM_14);  //Play IceHockey2
    DrawBG(0);              //cls
    DrawBG(10);             //Draw Hockey rink

    //Setup text planes and colors
    VDP_setTextPlan(PLAN_B);
    VDP_setTextPriority(PTRUE);
    VDP_setPaletteColor((OBJPAL * 16)+15,0xEE);   //Yellow
    VDP_setTextPalette(OBJPAL);

    //Draw a line, increment row, draw next line, repeat in screen chunks

    //            1234567890123456789012345678901234567
    VDP_drawText("+-----------------------------------+",x,y);y++;
    VDP_drawText("| ULTRA AIR HOCKEY (Genesis), V1.0  |",x,y);y++;
    VDP_drawText("|              Credits              |",x,y);y++;
    VDP_drawText("+-----------------------------------+",x,y);y++;
    VDP_drawText("|Producer                     Tamkis|",x,y);y++;
    VDP_drawText("|Art creator                  Tamkis|",x,y);y++;
    VDP_drawText("+-----------------------------------+",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                Music              |",x,y);y++;
    VDP_drawText("|All songs were converted to the    |",x,y);y++;
    VDP_drawText("|Echo sound engine                  |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|      Various module music artists |",x,y);y++;
    VDP_drawText("|Unless otherwise noted, all modules|",x,y);y++;
    VDP_drawText("|are from modarchive.org/           |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|http://modarchive.org/index.php?req|",x,y);y++;
    VDP_drawText("|uest=view_by_moduleid&query=NUMBER |",x,y);y++;
    VDP_drawText("v                                   v",x,y);y++;

    //wait MS, clear the text plane, repeat for next screen chunk
    waitMs(wait);
    VDP_clearPlan(BPLAN,0);
    y=1;

    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|hockey_fever.xm  The Einstein Crew |",x,y);y++;
    VDP_drawText("|144817                             |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|nes_mes2.mod        Goto80         |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|PITTITLE.mod        (Unknown)      |",x,y);y++;
    VDP_drawText("|112082                             |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|ice-hockey_94theme.mod Subtance/   |",x,y);y++;
    VDP_drawText("|inflow 121145                      |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|organmaster.mod     Gamma7         |",x,y);y++;
    VDP_drawText("|169287                             |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|intro101.mod        w.o.t.w of     |",x,y);y++;
    VDP_drawText("|supplex                            |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|hurry_up.mod        reflex/rebels  |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("v                                   v",x,y);y++;

    waitMs(wait);
    VDP_clearPlan(BPLAN,0);
    y=1;

    VDP_drawText("|slowmotion.mod     tobbx/Tobbe Lars|",x,y);y++;
    VDP_drawText("|157022                             |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|Castle_load.mod     Exodus         |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|complexity.mod      (Unknown)      |",x,y);y++;
    VDP_drawText("|92979                              |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|Reflexity_music.mod (subsong #3)   |",x,y);y++;
    VDP_drawText("|Unknown             109459         |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|chipmunks.mod       Jester/Sanity  |",x,y);y++;
    VDP_drawText("|36792                              |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|icehockey2.mod      Subversion     |",x,y);y++;
    VDP_drawText("|123683                             |",x,y);y++;
    VDP_drawText("+-----------------------------------+",x,y);y++;
    VDP_drawText("v                                   v",x,y);y++;

    waitMs(wait);
    VDP_clearPlan(BPLAN,0);
    y=1;

    VDP_drawText("|             Sound effects         |",x,y);y++;
    VDP_drawText("|Unless otherwise noted, all sfx are|",x,y);y++;
    VDP_drawText("|from Freesound.org                 |",x,y);y++;
    VDP_drawText("|http://www.freesound.org/people/   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|ID(+16) Name            URL        |",x,y);y++;
    VDP_drawText("|01      Menu highlight             |",x,y);y++;
    VDP_drawText("|broumbroum/sounds/50561/           |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|02      Menu select                |",x,y);y++;
    VDP_drawText("|Bertrof/sounds/131658/             |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|03      Puck hit                   |",x,y);y++;
    VDP_drawText("|krb21/sounds/118604/               |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|04/30   Puck deflect               |",x,y);y++;
    VDP_drawText("|BranRainey/sounds/108737/          |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("v                                   v",x,y);y++;

    waitMs(wait);
    VDP_clearPlan(BPLAN,0);
    y=1;

    VDP_drawText("|05      Bumper hit                 |",x,y);y++;
    VDP_drawText("|timgormly/sounds/170140/           |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|06      Powerup get                |",x,y);y++;
    VDP_drawText("|RandomationPictures/sounds/138491/ |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|07      Powerup use                |",x,y);y++;
    VDP_drawText("|jobro/sounds/35464/                |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|08      Goal siren                 |",x,y);y++;
    VDP_drawText("|UncleSigmund/sounds/117122/        |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|09-29   Announcer guy stuff        |",x,y);y++;
    VDP_drawText("|All generated w Acapela Box using  |",x,y);y++;
    VDP_drawText("|the English (UK) Peter voice       |",x,y);y++;
    VDP_drawText("|https://acapela-box.com/AcaBox/    |",x,y);y++;
    VDP_drawText("|index.php                          |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("v                                   v",x,y);y++;

    waitMs(wait);
    VDP_clearPlan(BPLAN,0);
    y=1;

    VDP_drawText("|31      Buzzer                     |",x,y);y++;
    VDP_drawText("|cognito%20perceptu/sounds/17468/   |",x,y);y++;
    VDP_drawText("+-----------------------------------+",x,y);y++;
    VDP_drawText("|             Beta testers          |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|DUDE #1    - Stuff                 |",x,y);y++;
    VDP_drawText("|DUDE #2    - Stuff                 |",x,y);y++;
    VDP_drawText("|DUDE #3    - Stuff                 |",x,y);y++;
    VDP_drawText("+-----------------------------------+",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|            Special Thanks         |",x,y);y++;
    VDP_drawText("|Oerg866 and SiktheHedgehog         |",x,y);y++;
    VDP_drawText("|Echo Sound Engine and related tools|",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|Stephane              Help, SGDK   |",x,y);y++;
    VDP_drawText("|Nemesis  Exodus emulator (debuging)|",x,y);y++;
    VDP_drawText("v                                   v",x,y);y++;

    waitMs(wait);
    VDP_clearPlan(BPLAN,0);
    y=1;

    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("+===================================+",x,y);y++;
    VDP_drawText("|                YOU                |",x,y);y++;
    VDP_drawText("|            FOR PLAYING!           |",x,y);y++;
    VDP_drawText("|  Ultra Air Hockey (Genesis) V1.0  |",x,y);y++;
    VDP_drawText("|        EagleSoft Ltd 2015         |",x,y);y++;
    VDP_drawText("|       www.eaglesoftltd.com        |",x,y);y++;
    VDP_drawText("+===================================+",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;
    VDP_drawText("|                                   |",x,y);y++;

    waitMs(wait);
    echo_wait_sfx(SFX_02);      //Play select sfx
    VDP_fadeOutAll(100,_FALSE);
    DrawBG(0);                  //cls
}
Beispiel #12
0
/*notice the default arguments for main.  SDL expects main to look like that, so don't change it*/
int main(int argc, char *argv[])
{

 // SDL_Surface *temp = NULL;

  
  int done;// the player
  const Uint8 *keys;// the player

  /* This section starts by loading the BG as a surface and converting it to a texture This will have to change 
  if I can manage to scroll the trexture arond the player*/
 
SDL_CreateWindowAndRenderer(800, 600, SDL_WINDOW_RESIZABLE, &mainWindow, &renderer);
SDL_SetWindowTitle(mainWindow, "Nitro Hotness");
 if( TTF_Init() == -1 )
    {
        return false;    
    }

  if( Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 4096 ) == -1 )
    {
        return false;    
    }

InitSpriteSystem();
InitEntitySystem(entityMax);


map mymap = setWorld();
ObstacleList ol = newObstacleList();
mew = newPlayer();
Obstacle Doh = newObstacle(0);
Road_M Path = initRoad();
AI rival = new_AI();
GUI HUD = InitGUI();
mew.position=0;
done = 0;

//The music that will be played
   Mix_Music *music = NULL;


   Mix_Chunk *buzz = NULL;
    buzz = Mix_LoadWAV( "sfx/buzz.wav" );
	readSave(&mew);
	showTitle();
	showMain();
  oldTime = 0;
  currentTime = 0;
  mytime = 0;

do
 	{
		
  oldTime = 0;
  currentTime = 0;
  mytime = 0;
	  if( Mix_PlayingMusic() == 0 )
                    {
                        //Play the music
                        if( Mix_PlayMusic( level_music, -1 ) == -1 )
                        {
                            return 1;
                        } 
					}
	 SDL_Event e;
	 SDL_PollEvent( &e ); 
		if(&e)
					{
					//User requests quit
					if( e.type == SDL_QUIT )
					{
						done = 1;
					}
					//user presses enter to go to next menu
					
					//User presses a key
					else if( e.type == SDL_KEYDOWN )
					{
						//Select surfaces based on key press
						switch( e.key.keysym.sym )
						{
						
						case SDLK_LEFT:
				//		slog("left is down");	
						mew.playerX += 3;
						mew.accel = (mew.accel - .000001);
						break;

						case SDLK_RIGHT:
					//	slog("right is down");
						mew.playerX -= 3;
						mew.accel = (mew.accel - .000001);
						break;

						case SDLK_UP:
					//	slog("up is down");
						 mew.accel = (mew.accel + .00007);
						 Mix_PlayChannel( 1, buzz, 0 );
						 break;
						
						case SDLK_DOWN:
					//	slog("down is down");
						mew.accel = (mew.accel - .00008);
						break;
						}
					}

					else if( e.type == SDL_KEYUP )
					{
						//Select surfaces based on key press
						switch( e.key.keysym.sym )
						{	
						
						case SDLK_RETURN :
						if(mew.done ==1)
						{
							Mix_HaltMusic();
							if(GP == 1)
							{
							mew.done=0;
							lvl++;
							//slog("new level is %i",lvl);
							mew.position = 0;
							rival.position =0;
							setWorld();
							Results(mew.rank,lvl);
							}
						else if (GP == 0)
							{
							mew.done=0;
							mew.position = 0;
							rival.position =0;
							levelSelect();
							}
						
						}
						else
						{
						slog("too soon");
						}
						
						case SDLK_LEFT:
					//	slog("left is up");	
						e.type = SDLK_CLEAR;
						break;

						case SDLK_RIGHT:
					//	slog("right is up");
						e.type = SDLK_CLEAR;
						break;

						case SDLK_UP:
					//	slog("up is up");
						mew.accel = (mew.accel - .001);
						Mix_HaltChannel(1);
						e.type = SDLK_CLEAR;
						break;

						case SDLK_DOWN:
					//	slog("down is up");
						mew.accel = 0;
						e.type = SDLK_CLEAR;
						break;

						default:
					//slog("simple decel");	
						mew.accel = (mew.accel-0.00001);
						break;

						}
					}

		if(mew.position > rival.position)
		{
			mew.rank = 1 ;
		}
		else if( rival.position > mew.position )
		{
			mew.rank = 2 ;
		}
		SDL_RenderClear(renderer);
		DrawBG(BG1,BG2);
		roadUpdate(Path,mymap,mew);
		roadDraw(Path,mymap,&mew);
		roadFetch(Path,mymap,&mew);
		checkForObstacles(ol , &mew, Doh);
		update_AI(&rival, &mew);
		UpdatePlayer(&mew);
		DrawGui(HUD,mew);
		NextFrame();
		keys = SDL_GetKeyboardState(NULL);

	if(keys[SDL_SCANCODE_ESCAPE])
    {
        done = 1;
    }
	
}
  }while(!done);
      //Free the sound effects
   //Free the music
  Mix_FreeMusic( music );
  CloseEntitySystem();
  CloseSpriteSystem();
  exit(0);		/*technically this will end the program, but the compiler likes all functions that can return a value TO return a value*/ 
 return 0;
}
Beispiel #13
0
// ////////////////////////Apply section background/////////////////////////////
void LvlScene::setSectionBG(LevelSection section, bool forceTiled)
{
    //QGraphicsPixmapItem * item=NULL;
    QGraphicsRectItem * itemRect=NULL;
    QBrush brush;
    QPen pen;
    QPixmap image = Themes::Image(Themes::dummy_bg);
    QPixmap nullimage;
    obj_BG *bgConfig=NULL;
    QPixmap *img=NULL;
    QPixmap *img2=NULL; //Second image buffer
    //need a BGitem

    bool noimage=false, wrong=false;
    long x,y,h,w;

    if(
        (section.size_left!=0) ||
        (section.size_top!=0)||
        (section.size_bottom!=0)||
        (section.size_right!=0)
      )
    { //Don't draw on unallocated section entry
        x=section.size_left;
        y=section.size_top;
        w=section.size_right;
        h=section.size_bottom;

        #ifdef _DEBUG_
        WriteToLog(QtDebugMsg, "SetSectionBG-> Check for user images");
        #endif

        noimage=true;
        if(section.background != 0 )
        {
            //Find user image
            if(uBGs.contains(section.background))
            {
                noimage=false;
                obj_BG &bgx = uBGs[section.background];
                bgConfig=&bgx;
                img =&bgx.image;
                img2=&bgx.second_image;
            } else //If not exist, will be used default
            if(pConfigs->main_bg.contains(section.background))
            {
                noimage=false;
                obj_BG &bgx = pConfigs->main_bg[section.background];
                bgConfig=&bgx;
                img =&bgx.image;
                img2=&bgx.second_image;
            }
            if(noimage)
            {
                #ifdef _DEBUG_
                WriteToLog(QtWarningMsg, "SetSectionBG-> Image not found");
                #endif
                img=&image;
                img2=&nullimage;
                wrong=true;
            }
        }
        else noimage=true;

        brush = QBrush(QColor(0, 0, 0));
        pen = QPen(Qt::NoPen);

        if((!noimage)&&(!img->isNull()))
        {
            DrawBG(x, y, w, h, section.id, *img, *img2, *bgConfig, forceTiled);
        }
        else
        {
            if(wrong)
                brush.setTexture(image);
            itemRect = new QGraphicsRectItem;
            itemRect->setPen(pen);
            itemRect->setBrush(brush);
            itemRect->setRect(x, y, labs(x-w), labs(y-h));
            addItem(itemRect);
        }

        #ifdef _DEBUG_
        WriteToLog(QtDebugMsg, QString("SetSectionBG-> Item placed to x=%1 y=%2 h=%3 w=%4").arg(x).arg(y)
                   .arg((long)fabs(x-w)).arg((long)fabs(y-h)));
        #endif
        //

        if(itemRect!=NULL)
        {
            itemRect->setData(ITEM_TYPE, QString("BackGround%1").arg(section.id) );
            itemRect->setZValue(Z_backImage);
        }

    } //Don't draw on reserved section entry

}