Discussion on Black and White - A Classical Android Piano Game

76 comments found.

hi, can i convert mp3 file to ogg?? and can i add the notes with my sound or other piano sounds?,thanks

because i want to make small size with ogg, i was replace mp3 file to my own sounds and its work. Can you tell me where and how can i put my Public Key Base 64 from playstore? and how can i change canvas button with my png? thanks

Hi, this feature isn’t included in the code. To draw an image on each piano button you need to modify the code in block.java, line 90:
//draw the sprite to screen
    public void draw(Canvas canvas) {
        //draw image
        for (int i = 0; i < block_paint.length; i++) {
            if (i == type)
                canvas.drawRect(x, y, x + (screen.ScreenWidth() / 4), y + getHeight(), block_paint[i]);
        }

        if (screen.debug_mode)
            physics.drawDebug(canvas);
    }
The app id from the Play store needs to be put in strings.xml between the > < of the “app_id”:
<string name="app_id"></string>
    <!-- Google Play services leaderboard Ids - You need to create 4 leaderboards in google Play developer console, one for each top score. Then just get each one's id and put it here -->
    <string name="Classic_leaderboard_id"></string>
    <string name="Arcade_leaderboard_id"></string>
    <string name="Zen_leaderboard_id"></string>
    <string name="Bomb_leaderboard_id"></string>

How can we add multiple music ? Different music as per user selection ?

Hi, This is not a feature of the game. here’s a small rough guide that might help you do it. 1) load different sound fx like:

In mainagme.java youu need to:
sound_effect_notes = new int[sound_effect_notes_ref.length];
        for (int i = 0; i < sound_effect_notes_ref.length; i++) {
            sound_effect_notes[i] = sp.load(activity, sound_effect_notes_ref[i], 1);
        }

sound_effect_notes_zen = new int[sound_effect_notes_ref_zen.length];
        for (int i = 0; i < sound_effect_notes_ref_zen.length; i++) {
            sound_effect_notes_zen[i] = sp.load(activity, sound_effect_notes_ref_zen[i], 1);
        }
2) and in line 686 play the correct sound from the correct array by placing the current code:
    if (sound_effect_notes[music_notes[randomSong][currentNote]] != 0 && !sound_muted)
                                    sp.play(sound_effect_notes[music_notes[randomSong][currentNote]], 1, 1, 0, 0, 1);
inside if statements like so:
if (GamePlayMode == Classic) {
} else if (GamePlayMode == Arcade) {
} else if (GamePlayMode == Zen) {
} else if (GamePlayMode == Bomb) {
}

How can I solve this problem a lot of Android Studio transfer tactics.?

Hi, The app uses Android Api 21. Most probably when importing into android studio the Api was set to the most recent one automatically. To fix this issue change the api to 21 fromthe gradle file. This tutorial might help you a bit: https://www.youtube.com/watch?v=pw4jKsOU7go (in it he’s changing to 23. You need to change to 21)

Hey how can i add new tracks ?? and can i load this project in android studio ?

New tracks can be added by modifying this array in maingame.java line 101:
    //music notes. Each one of the 3 lists below represents a song. One of them is selected randomly. The numbers indicate the note to play as the user hits the black tiles.
    //TODO: You may wish to play with the numbers to create your own song
    int[][] music_notes = new int[][]
    {
            { 8, 15, 10, 15, 12, 15, 12, 17, 12, 15, 12, 16, 12, 16, 12, 11, 12, 16, 12, 11, 12, 16, 12, 11, 12, 18, 12, 16, 12, 17, 12, 10, 12, 17, 12, 10, 12, 17, 12, 10, 17, 18, 12, 17, 12, 18, 13, 11, 18, 18, 13, 17, 13, 12, 11, 9, 11, 14, 11, 10, 9, 15, 12, 10, 12, 8 },
            { 8, 10, 12, 15, 9, 11, 13, 16, 11, 13, 15, 18, 15, 13, 11, 16, 13, 11, 9, 15, 12, 10 },
            { 10, 11, 12, 17, 15, 16, 15, 15, 14, 14, 9, 10, 11, 16, 14, 15, 14, 13, 12, 12, 10, 11, 12, 15, 16, 17, 16, 15, 13, 16, 17, 18, 17, 16, 12, 13, 12, 11 },

    };
Each number represents a note. I suggest playing the track on a piano and then put in the numbers accordingly.

This project was done in eclipse, but it can be imported to android studio using the wizard. Check out this tutorial: https://www.youtube.com/watch?v=2_vq7QcVdc0

hi can i disable the google play leaderboard ?

Hi, yes it can be disabled by leaving the following empty in strings.xml:
<string name="app_id"></string>

Hi how i can add new image as background in menu screen instead of current colors, please help.

Hi, This is not included in the code. To add a background image you can add your code in maingame.java line 880 instead of the following:
//draw menu background    canvas.drawColor(getResources().getColor(R.color.white));

The image needs to be small, else you might have problems with memory on some phones. If you wish to make a large image I suggest using the Picasso library: http://square.github.io/picasso/

Instead of giving the app many files , can it be easy to give only one file and to define the numbers of notes and the app will sepeate reading the file ? like a function that play and stop the audio until the player click again ?

Hi, I didn’t understand your question exactly. Can you give me more detail, please?

You game use the notes sounds and play theme with numbers given in mainGame file, is it possible to change that so i can put only one track file and instead of calling each notes it will call only that track ? and the numbers thing will be used to seperate that track , play and pause …

Hi, you mean just play a .mp3 audio file and pause/play when user hits the button? If so, this is not possible. I had tried it and it didn’t produce good results.

Hello, I am interested in buying this source code but first I need to know: --Is it possible, and how easy is it to discard all the songs included and create entirely new ones? Thank you.

Hi, Glad to hear that :)

Open maingame.java and in line 99 add the musical notes (sound files of piano keys):
    //list of notes recorded from piano
    int[] sound_effect_notes_ref = new int[] { R.raw.note1, R.raw.note2, R.raw.note3, R.raw.note4, R.raw.note5, R.raw.note6, R.raw.note7, R.raw.note8, R.raw.note9, R.raw.note10, R.raw.note11, R.raw.note12, R.raw.note13, R.raw.note14, R.raw.note15, R.raw.note16, R.raw.note17, R.raw.note18, R.raw.note19, R.raw.note20, R.raw.note21 };
</ore>

Then in line 103, you have 3 songs which are called randomly when a game starts. A song is formed with notes played after each other. So to play ‘note1’ put in 0…

<pre>
//TODO: You may wish to play with the numbers to create your own song
    int[][] music_notes = new int[][]
    {
            { 8, 15, 10, 15, 12, 15, 12, 17, 12, 15, 12, 16, 12, 16, 12, 11, 12, 16, 12, 11, 12, 16, 12, 11, 12, 18, 12, 16, 12, 17, 12, 10, 12, 17, 12, 10, 12, 17, 12, 10, 17, 18, 12, 17, 12, 18, 13, 11, 18, 18, 13, 17, 13, 12, 11, 9, 11, 14, 11, 10, 9, 15, 12, 10, 12, 8 },
            { 8, 10, 12, 15, 9, 11, 13, 16, 11, 13, 15, 18, 15, 13, 11, 16, 13, 11, 9, 15, 12, 10 },
            { 10, 11, 12, 17, 15, 16, 15, 15, 14, 14, 9, 10, 11, 16, 14, 15, 14, 13, 12, 12, 10, 11, 12, 15, 16, 17, 16, 15, 13, 16, 17, 18, 17, 16, 12, 13, 12, 11 },

    };
</pre>

hello :) my customer bought your code but i have some errors pleas can you help me ?

[2016-01-28 22:32:05 – google-play-services_lib] Project has no project.properties file! Edit the project properties to set one. [2016-01-28 22:33:00 – White Tiles 7] C:\Users\Saiko\Desktop\pte\White Tiles 7\AndroidManifest.xml:27: error: Error: String types not allowed (at ‘configChanges’ with value ‘orientation|keyboardHidden|screenSize’). 2016-01-28 22:33:00 – White Tiles 7 C:\Users\Saiko\Desktop\pte\White Tiles 7\AndroidManifest.xml:39: error: Error: No resource found that matches the given name (at ‘value’ with value ’@integer/google_play_services_version’). 2016-01-28 22:33:00 – White Tiles 7 C:\Users\Saiko\Desktop\pte\White Tiles 7\AndroidManifest.xml:43: error: Error: String types not allowed (at ‘configChanges’ with value ‘keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize’). 2016-01-28 22:33:00 – White Tiles 7 C:\Users\Saiko\Desktop\pte\White Tiles 7\AndroidManifest.xml:27: error: Error: String types not allowed (at ‘configChanges’ with value ‘orientation|keyboardHidden|screenSize’). 2016-01-28 22:33:03 – White Tiles 7 C:\Users\Saiko\Desktop\pte\White Tiles 7\AndroidManifest.xml:39: error: Error: No resource found that matches the given name (at ‘value’ with value ’@integer/google_play_services_version’). 2016-01-28 22:33:03 – White Tiles 7 C:\Users\Saiko\Desktop\pte\White Tiles 7\AndroidManifest.xml:43: error: Error: String types not allowed (at ‘configChanges’ with value ‘keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize’). [2016-01-28 22:33:03 – White Tiles 7]

Please comment with the account that made the purchase for support.

[2016-01-28 22:32:05 – google-play-services_lib] Project has no project.properties file! Edit the project properties to set one.

[2016-01-28 22:33:00 – White Tiles 7] C:\Users\Saiko\Desktop\pte\White Tiles 7\AndroidManifest.xml:27: error: Error: String types not allowed (at ‘configChanges’ with value ‘orientation|keyboardHidden|screenSize’). [2016-01-28 22:33:00 – White Tiles 7]

[2016-01-28 22:33:00 – White Tiles 7] C:\Users\Saiko\Desktop\pte\White Tiles 7\AndroidManifest.xml:39: error: Error: No resource found that matches the given name (at ‘value’ with value ’@integer/google_play_services_version’). [2016-01-28 22:33:00 – White Tiles 7]

[2016-01-28 22:33:00 – White Tiles 7] C:\Users\Saiko\Desktop\pte\White Tiles 7\AndroidManifest.xml:43: error: Error: String types not allowed (at ‘configChanges’ with value ‘keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize’). [2016-01-28 22:33:00 – White Tiles 7]

[2016-01-28 22:33:03 – White Tiles 7] C:\Users\Saiko\Desktop\pte\White Tiles 7\AndroidManifest.xml:27: error: Error: String types not allowed (at ‘configChanges’ with value ‘orientation|keyboardHidden|screenSize’). [2016-01-28 22:33:03 – White Tiles 7]

[2016-01-28 22:33:03 – White Tiles 7] C:\Users\Saiko\Desktop\pte\White Tiles 7\AndroidManifest.xml:39: error: Error: No resource found that matches the given name (at ‘value’ with value ’@integer/google_play_services_version’). [2016-01-28 22:33:03 – White Tiles 7]

[2016-01-28 22:33:03 – White Tiles 7] C:\Users\Saiko\Desktop\pte\White Tiles 7\AndroidManifest.xml:43: error: Error: String types not allowed (at ‘configChanges’ with value ‘keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize’). [2016-01-28 22:33:03 – White Tiles 7]

yes sir and all skd are installed, i tried to delete the android 6 but sadly same problem

i’m still waiting you Sir

Please use the account that purchased the file for support

Hi neurondigital , I hope you’re doing well

i have questions before buying this apps ,

Can i import this apps in eclipse today ? because adt (ADT) in Eclipse has ended .

should i migrate this app projects to Android Studio ?

if it’s not possible to import the project in eclipse how can i import it in android studio ?

Thanks,

Mourad

Hi, The app was designed for eclipse. You can still install the latest version of the eclipse ADT and Android SDK version.

If you like, you can also import the app in Android studio. It will also work.

hello , i want to purchase this source code, but i want to know if i can change the black tiles with image ?

Hi, this feature isn’t included in the code. To draw an image you need to modify the code in block.java, line 90. You can replace the draw function with something like so, were YOUR_LOADED_BITMAP_HERE is your bomb bitmap loaded.


    //draw the sprite to screen
    public void draw(Canvas canvas) {
        //draw image
if(type ==Black)
          canvas.drawBitmap(YOUR_LOADED_BITMAP_HERE, x + (screen.ScreenWidth() / 4), y + getHeight(), null);
else
         canvas.drawRect(x, y, x + (screen.ScreenWidth() / 4), y + getHeight(), block_paint[type]);

        if (screen.debug_mode)
            physics.drawDebug(canvas);
    }

how i can replace black tile with a picture in drawable ? ( for ex the name of image is “pic.png”) ?

Just copy paste the picture in the drawable, then load the image:

Sprite loaded_img = new Sprite(BitmapFactory.decodeResource(getResources(), R.drawable.pic), ScreenWidth() * 0.25f);

hi ; can i use admob ads on plz ?

yes, sure. The template already has interstitial and banner ads setup. you just need to put in your ad unit id.

Amazing work as always mate , keep it up

Thanks :)

Hi there, are you able to help associate mp3 notes which you’re providing with the corresponding musical notation of them?

notes in the Thanks, Jakub

Hi, Open maingame.java and in line 99 add the musical notes (sound files of piano keys):
    //list of notes recorded from piano
    int[] sound_effect_notes_ref = new int[] { R.raw.note1, R.raw.note2, R.raw.note3, R.raw.note4, R.raw.note5, R.raw.note6, R.raw.note7, R.raw.note8, R.raw.note9, R.raw.note10, R.raw.note11, R.raw.note12, R.raw.note13, R.raw.note14, R.raw.note15, R.raw.note16, R.raw.note17, R.raw.note18, R.raw.note19, R.raw.note20, R.raw.note21 };

Then in line 103, you have 3 songs which are called randomly when a game starts. A song is formed with notes played after each other. So to play ’note1’ put in 0, for ‘note2’ put in 1… It is like playing a piano.

//TODO: You may wish to play with the numbers to create your own song
    int[][] music_notes = new int[][]
    {
            { 8, 15, 10, 15, 12, 15, 12, 17, 12, 15, 12, 16, 12, 16, 12, 11, 12, 16, 12, 11, 12, 16, 12, 11, 12, 18, 12, 16, 12, 17, 12, 10, 12, 17, 12, 10, 12, 17, 12, 10, 17, 18, 12, 17, 12, 18, 13, 11, 18, 18, 13, 17, 13, 12, 11, 9, 11, 14, 11, 10, 9, 15, 12, 10, 12, 8 },
            { 8, 10, 12, 15, 9, 11, 13, 16, 11, 13, 15, 18, 15, 13, 11, 16, 13, 11, 9, 15, 12, 10 },
            { 10, 11, 12, 17, 15, 16, 15, 15, 14, 14, 9, 10, 11, 16, 14, 15, 14, 13, 12, 12, 10, 11, 12, 15, 16, 17, 16, 15, 13, 16, 17, 18, 17, 16, 12, 13, 12, 11 },

    };

How i create new songs??

The songs need to be created using the provided notes. When the entered notes are played one after the other the song will form. In other words you cannot import an mp3 file.

Sound files from 1 to 21, could you say that musical note is each? to create songs

I’m afraid I’m not sure about this, because I had hired someone to record the piano and produce the notes. However, If I remember correctly the 21 notes are the middle 3 octaves of the piano. So C3 (note 1) to B5 (note 21).

Hope this helps.

by
by
by
by
by
by