You are on page 1of 4

//=============================================== // DragonFireSDK.

h //=============================================== int WorldSetxy(int x,int y); int ImageAdd(char *filename); int ViewAdd(int im,int x,int y); int ViewAdd(char *filename,int x,int y); int ViewAdd(char *filename,int x,int y,int (*callback)(int id,int event,int x,in t y),int id); int ViewGetx(int vw); int ViewGety(int vw); int ViewSetxy(int vw,int x,int y); int ViewSetImage(int vw,int im); int ViewSetVisible(int vw,int flag); int TouchAdd(int x,int y,int width,int height,int (*callback)(int id,int event,i nt x,int y),int id); // event: 1=down, 2=move, 3=up int TouchGetxy(int i,int &x,int &y); void RandomSetSeed(unsigned int seed); void Randomize(); int Random(unsigned int range); // ret number from 0 to <range int ButtonAdd(char *filename,int x,int y,int (*callback)(int id),int id); int PushButtonAdd(char *filename,int x,int y,int (*callback)(int id),int id); int FontAdd(char *foldername); int int int int int int int int int int int int TextAdd(int x,int y,char *text,int font); TextSetText(int tx,char *text); TextSetxy(int tx,int x,int y); TextGetx(int tx); TextGety(int tx); FileOpenResource(char *filename); FileOpen(char *filename); FileCreate(char *filename); FileRead(int fh,char *buf,int len); FileWrite(int fh,char *buf,int len); FileSeek(int fh,int seek); FileClose(int fh);

int SoundAdd(char *filename); int SoundPlay(int sn); void DeckShuffle(int deck[52]); void printf(char* lpszFormat, ...); void sprintf(char *szBuffer,char* lpszFormat, ...); void StrCopy(char *name,char *filename); void StrAppend(char *name,char *filename); void LandscapeMode();

void PortraitMode(); int ViewSetRotate(int vw,int degrees); int ViewSetSize(int vw,int width,int height); int ViewSetTouch(int vw,int tc);

***************** /*==================================================== Piano.cpp Simple app that simulates a piano keyboard. ====================================================*/ #include "DragonFireSDK.h" // Defines the position of each of the white keys. int WhiteKeyY[9] = {0, 55, 110, 165, 220, 275, 330, 385, 440}; // Defines the position of each of the black keys. // Each is offset from its neighboring white key by 35 // pixels. int BlackKeyY[6] = { 35, 90, 200, 255, 310, 420}; // Holds handles to each of the white piano keys' sounds. int WhiteKeySound[9]; // Holds handles to each of the black piano keys' sounds. int BlackKeySound[6]; // Forward declaration for Key Press Event. int OnKeyPress(int id); //==================================================== // AppMain is the first function called by the // DragonFireSDK. It is resposible // for initialization of all variables and creating the // appilcation's objects. void AppMain() { int i; char FileName[255]; // View iPhone Simulator Landscape LandscapeMode(); // Load a background image. ViewAdd("Assets/Images/Background.png", 0, 0); // Initialize each white key and then set up its corresponding sound. // White key sounds and ID's start at 0. for (i = 0; i < 9; i++) { PushButtonAdd("Assets/Images/WhiteKey", WhiteKeyY[i], 0, OnKeyPress, i); sprintf(FileName, "Assets/Sounds/WhiteKey%d.wav", i); WhiteKeySound[i] = SoundAdd(FileName); } // Initialize each black key and then set up its corresponding sound.

// Black key sounds start at zero, their ID's start at 10. for (i = 0; i < 6; i++) { PushButtonAdd("Assets/Images/BlackKey", BlackKeyY[i], 0, OnKeyPress, i+10) ; sprintf(FileName, "Assets/Sounds/BlackKey%d.wav", i); BlackKeySound[i] = SoundAdd(FileName); } // Load an image to hide the "top" of each key. ViewAdd("Assets/Images/TopBar.png", 0, 0); } //==================================================== void OnTimer() { // Do nothing. } //==================================================== // OnKeyPress responds to all Key Presses on the piano keyboard. int OnKeyPress(int id) { // White keys have ID's less than 10. No index adjustment necessary. if (id < 10) { SoundPlay(WhiteKeySound[id]); } // Black keys have ID's greater than 10. //Adjust index by 10 for Black Key range. else { SoundPlay(BlackKeySound[id-10]); } return 0; }

*********** //=========================== BubbleWrap.cpp //=========================== #include "DragonFireSDK.h" int BubblePoppedImage; int BubbleSound; int BubbleView[8*12]; bool BubblePoppedStatus[8*12]; //=========================== int OnPopBubble(int id, int evt, int x, int y) { if (evt==1) { if (!BubblePoppedStatus[id]) {

BubblePoppedStatus[id] = true; ViewSetImage(BubbleView[id], BubblePoppedImage); SoundPlay(BubbleSound); } } return 0; } //=========================== void AppMain() { int x; int y; int id; BubblePoppedImage = ImageAdd("Images/BubblePopped.png"); BubbleSound = SoundAdd("Sounds/BubbleSound.wav"); id=0; for (x=0; x<8; ++x) { for (y=0; y<12; ++y) { BubblePoppedStatus[id] = false; BubbleView[id] = ViewAdd("Images/BubbleNormal.png", x*40, y*40, OnPopBub ble, id); ++id; } } } //=========================== void OnTimer() { } //===========================

You might also like