Esempio n. 1
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(){
	int skip = 0;
    int enabled = 1;
    int selectedConfig = 0;
    SetupCallbacks();

    initOSLib();
    oslIntraFontInit(INTRAFONT_CACHE_MED);
    oslNetInit();

    //Loads image:
    bkg = oslLoadImageFilePNG("bkg.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);

    //Load font:
    OSL_FONT *font = oslLoadFontFile("flash0:/font/ltn0.pgf");
    oslSetFont(font);

    if (!oslIsWlanPowerOn())
        sprintf(message, "Please turn on the WLAN.");

    //Get connections list:
    struct oslNetConfig configs[OSL_MAX_NET_CONFIGS];
    int numconfigs = oslGetNetConfigs(configs);
    if (!numconfigs){
        sprintf(message, "No configuration found!");
        enabled = 0;
    }

    while(runningFlag && !osl_quit){
        if (!skip){
			oslStartDrawing();
			oslDrawImageXY(bkg, 0, 0);
            if (enabled){
                sprintf(buffer, "Press X to connect to %s.", configs[selectedConfig].name);
    			oslDrawString(30, 50, buffer);
    			oslDrawString(30, 80, "Press UP and DOWN to change settings.");
            }
            oslDrawString(30, 150, "Press /\\ to quit.");
			oslDrawString(30, 200, message);

			oslEndDrawing();
		}
        oslEndFrame();
        skip = oslSyncFrame();

        oslReadKeys();
        if (osl_keys->released.triangle)
            runningFlag = 0;

        if (osl_keys->released.cross){
            connectToAP(selectedConfig + 1);
        }else if (osl_keys->released.up){
            if (++selectedConfig >= numconfigs)
                selectedConfig = numconfigs - 1;
        }else if (osl_keys->released.down){
            if (--selectedConfig < 0)
                selectedConfig = 0;
        }
    }
    //Quit OSL:
    oslNetTerm();
    oslEndGfx();
    sceKernelExitGame();
    return 0;

}
Esempio n. 2
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(){
    SetupCallbacks();
    oslSrand(1);
    //Init network (for net conf dialog):
    oslNetInit();
    int skip = 0;
    LedAnimFreq.f=2;
    const int calx1=-20,calx2=20,caly1=-20,caly2=20;
    //float fx,fy;
    float_or_int_t _movW,_movX,_movY,_movZ;

    DroneSck = oslNetSocketCreate();
    DroneUdp = make_udpsocket(AT_PORT);
    initOSLib();
    oslIntraFontInit(INTRAFONT_CACHE_MED);

    //Loads image:
    //OSL_IMAGE *bkg = oslLoadImageFileJPG("back1.jpg", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
    OSL_IMAGE *bkg = oslLoadImageFileJPG("back1.jpg", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_5650);
   	OSL_IMAGE *img1 = oslCreateImage (130,130,OSL_IN_RAM,OSL_PF_8BIT);
   	FirePalette (img1,255);
    oslClearImage (img1,0);

    //Load font:
    OSL_FONT *font = oslLoadFontFile("flash0:/font/ltn0.pgf");
    oslSetFont(font);

    while(runningFlag && !osl_quit){
        if (!skip){
            oslStartDrawing();
            oslDrawImageXY(bkg, 0, 0);

            oslReadKeys();
            _movX.f = ((float)osl_pad.analogX/128)*mscale;
            _movY.f = ((float)osl_pad.analogY/128)*mscale;
            _movZ.f = 0;
            _movW.f = 0;
            if ((osl_pad.analogX > calx1) && (osl_pad.analogX < calx2)) _movX.f = 0; //Deadzone X
            if ((osl_pad.analogY > caly1) && (osl_pad.analogY < caly2)) _movY.f = 0; //Deadzone Y
			if (osl_pad.held.triangle) _movZ.f = delta; //Up
			if (osl_pad.held.cross) _movZ.f = -delta; //Down
			if (osl_pad.held.L) _movW.f = -delta; //CW
			if (osl_pad.held.R) _movW.f = delta; //CCW
            if (_movX.f==0 && _movY.f==0 && _movZ.f==0 && _movW.f==0) Hover=0; else Hover=1;

            oslDrawStringf(320, 10, "Tic#= %d",AT_SEQ);
            oslDrawStringf(10, 220, "x= %d  y= %d  z= %d  w= %d  !Hvr= %d",osl_pad.analogX,osl_pad.analogY,_movZ.i,_movW.i,Hover);
            oslDrawStringf(10, 240, "xf= %1.2f  yf= %1.2f  Scl= %1.2f",_movX.f,_movY.f,mscale);

            if (Connected==1) GameTic++;

            if (drawMenu==1) {
            	Menu();}
            else {
    			if (osl_pad.pressed.up) {
    				//Drone.AddCmd "AT*ANIM=", CStr(Seq) & "," & Anim_Time(Seq) vb anim code
    				snprintf(netbuf,1024,"AT*ANIM=%d,%d,%d%c",AT_SEQ++,ARDRONE_ANIM_FLIP_AHEAD,MAYDAY_TIMEOUT[ARDRONE_ANIM_FLIP_AHEAD],CR);
    				sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));}
    			if (osl_pad.pressed.down) {
    				snprintf(netbuf,1024,"AT*ANIM=%d,%d,%d%c",AT_SEQ++,ARDRONE_ANIM_FLIP_BEHIND,MAYDAY_TIMEOUT[ARDRONE_ANIM_FLIP_BEHIND],CR);
    				sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));}
    			if (osl_pad.pressed.right) {
    				snprintf(netbuf,1024,"AT*ANIM=%d,%d,%d%c",AT_SEQ++,ARDRONE_ANIM_FLIP_RIGHT,MAYDAY_TIMEOUT[ARDRONE_ANIM_FLIP_RIGHT],CR);
    				sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));}
    			if (osl_pad.pressed.left) {
    				snprintf(netbuf,1024,"AT*ANIM=%d,%d,%d%c",AT_SEQ++,ARDRONE_ANIM_FLIP_LEFT,MAYDAY_TIMEOUT[ARDRONE_ANIM_FLIP_LEFT],CR);
    				sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));}
                if (osl_pad.pressed.start) {
                	drawMenu=1;}
				if (osl_pad.pressed.circle){//Take off
					snprintf(netbuf,1024,"AT*REF=%d,%d%c",AT_SEQ++,AT_REF|512,CR);//TAKE OFF
					sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));}
				if (osl_pad.pressed.square){//Land
					snprintf(netbuf,1024,"AT*REF=%d,%d%c",AT_SEQ++,AT_REF,CR);
					sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));}
            }
            if (showjoypad) JoyPadGfx(img1);
            if (showfire) FireFx(img1);
        	if (showjoypad||showfire) oslDrawImageXY(img1, 345, 85);

        	oslEndDrawing();

		}

		if (GameTic >= TicRoof){
        	GameTic=0;
            //snprintf(netbuf,1024,"AT*COMWDG=%d%cAT*PCMD=%d,%d,%d,%d,%d,%d%c",AT_SEQ++,CR,AT_SEQ++,Hover,_movX.i,_movY.i,_movZ.i,_movW.i,CR);//XY
            snprintf(netbuf,1024,"AT*PCMD=%d,%d,%d,%d,%d,%d%c",AT_SEQ++,Hover,_movX.i,_movY.i,_movZ.i,_movW.i,CR);//XY
			sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));}


        oslEndFrame();
        skip = oslSyncFrame();
    }
    //Quit OSL:
    oslNetTerm();
    oslEndGfx();
    oslQuit();

    sceKernelExitGame();
    return 0;

}
Esempio n. 3
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(){
    int skip = 0;
    SetupCallbacks();

    initOSLib();
    oslIntraFontInit(INTRAFONT_CACHE_MED);

    //Loads image:
    OSL_IMAGE *bkg = oslLoadImageFilePNG("bkg.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);
    OSL_IMAGE *rect_01 = oslLoadImageFilePNG("rect_01.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888);

    //Load fonts:
    OSL_FONT *pgfFont = oslLoadFontFile("flash0:/font/ltn0.pgf");
    oslIntraFontSetStyle(pgfFont, 0.5, RGBA(255,255,255,255), RGBA(0,0,0,0), INTRAFONT_ALIGN_LEFT);

    OSL_FONT *oftFont = oslLoadFontFile("font.oft");
    oslSetTextColor(RGBA(255,255,255,255));
    oslSetBkColor(RGBA(0,0,0,0));

    while(runningFlag && !osl_quit){
        if (!skip){
            oslStartDrawing();
            oslDrawImageXY(bkg, 0, 0);

            oslDrawImageXY(rect_01, 50, 50);
            oslSetFont(pgfFont);
            oslDrawString(55, 55, "pgf on alpha image");
            oslSetFont(oftFont);
            oslDrawString(55, 70, "oft on alpha image");

            oslDrawFillRect(30, 150, 200, 250, RGB(150, 150, 150));
            oslSetFont(pgfFont);
            oslDrawString(35, 155, "pgf on rect");
            oslSetFont(oftFont);
            oslDrawString(35, 170, "oft on rect");

            oslDrawFillRect(300, 150, 400, 250, RGB(100, 100, 100));
            oslSetFont(pgfFont);
            oslDrawString(305, 155, "pgf on rect");
            oslSetFont(oftFont);
            oslDrawString(305, 170, "oft on rect");

            oslDrawGradientRect(300, 20, 430, 120, RGBA(100, 100, 100, 100),RGBA(100, 100, 100, 100), RGBA(200, 200, 200, 100), RGBA(200, 200, 200, 100));
            oslSetFont(pgfFont);
            oslDrawString(305, 25, "pgf on gradient rect");
            oslSetFont(oftFont);
            oslDrawString(305, 40, "oft on gradient rect");

            oslEndDrawing();
        }
        oslEndFrame();
        skip = oslSyncFrame();
    }
    //Quit OSL:
    oslEndGfx();
    oslQuit();

    sceKernelExitGame();
    return 0;

}