Discussion on Sea Defense - A Piranha killing Android Game

34 comments found.

One question. Can you update using Google Play Services instead of Admob SDK?

Hi, I will be updating the app with the new google play services ad sdk before the admob sdk is discontinued on august.

Translation Hi How can I make the game end after three times of object the bypass and the beach is not the first time?

Sorry because I do not speak English well and use Google to translate Thank you

Hi, You need to implement a life counter in maingame.java line330:
for (int i = 0; i < fishManager.Objects_live.size(); i++) {
    if (fishManager.Objects_live.get(i).x < 0) {
        if (!game_over) {
        game_over = true;

        if (sound_gameover != 0 && !sound_muted)
            sp.play(sound_gameover, 1, 1, 0, 0, 1);
    if (fishManager.Objects_live.get(i).y > ScreenHeight()) {

create a variable life and instead of game_over = true; call life = life -1. Then if(life<=0) game_over = true;

Hi Implemented the code as requested but still anything game ends the first jellyfish code:

if (fishManager.Objects_live.get(i).x < 0) { if (!game_over) { life = life -1; if(life<=0) game_over = true; if (sound_gameover != 0 && !sound_muted) sp.play(sound_gameover, 1, 1, 0, 0, 1); } } if (fishManager.Objects_live.get(i).y > ScreenHeight()) { fishManager.Objects_live.remove(i); } } } there a problem with code i typed thank you very much
I think the problem is that the fish still wouldn’t be destroyed when you reduce a life. Thus it will continue to reduce lives until gameover. Try to add:
right under life = life -1;

how i can game ends game over after then three of fish or jellyfish


Can I add two types of ads? both interstitial and banner?

Okay, thanks :)

One more question, how can I change the background? I have my own background design so I wanna replace it.

Hi, sorry that can’t be done easily, since the background is a solid color. A large image will be a bit hard on the memory

please add google leader board in this game then i will buy definatially.


Nice game, some question 1.) I dont want an animation for the fish. What do I have to change, that the project just load 1 graphic

2.) Some question like User “challanger”. Do you have a ready code, which I can just import?

1) from maingame.java line 255:
//Jelly fish
        fish[JELLYFISH] = new Instance(new Sprite(BitmapFactory.decodeResource(getResources(), R.drawable.jellyfish), (ScreenHeight() * 0.15f), 4, 4, 300), 500, 300, this, true, JELLYFISH);
        fish[JELLYFISH].speedx = -ScreenWidth() * 0.007f;
        fish[SPICKY] = new Instance(new Sprite(BitmapFactory.decodeResource(getResources(), R.drawable.spicky), (ScreenHeight() * 0.15f), 6, 6, 350), 500, 300, this, true, SPICKY);
        fish[SPICKY].speedx = -ScreenWidth() * 0.012f;
        fish[PIRANHA] = new Instance(new Sprite(BitmapFactory.decodeResource(getResources(), R.drawable.piranha), (ScreenHeight() * 0.15f), 8, 8, 350), 500, 300, this, true, PIRANHA);
        fish[PIRANHA].speedx = -ScreenWidth() * 0.015f;
        fish[SWORDY] = new Instance(new Sprite(BitmapFactory.decodeResource(getResources(), R.drawable.swordy), (ScreenHeight() * 0.20f), 5, 5, 380), 500, 300, this, true, SWORDY);
        fish[SWORDY].speedx = -ScreenWidth() * 0.018f;
        fish[SHARK] = new Instance(new Sprite(BitmapFactory.decodeResource(getResources(), R.drawable.shark), (ScreenHeight() * 0.40f), 6, 6, 340), 500, 300, this, true, SHARK);
        fish[SHARK].speedx = -ScreenWidth() * 0.023f;

just remove the (, 4, 4, 300), (, 6, 6, 350)...etc so that only one image is loaded.

2) sorry, I have no code for that.You would have to play a bit with the code to implement it.

hi, ND

sr for my bad english, i use google translate. I love your game, I have some question:

How can i:

1. remove images ?

2. resize images ?

3. change position of image ?


I figured it out. thank you!

Glad you figured it out.


I want to change advertising to Revmob or InMobi or MobFox or MoPub.

But I can not

Can you give me some help? Can I pay you to do?

Ok, I’m trying it but I can not.

Do you have updated game to google play services?

I will be updating the app to support the latest google play services ads :)


Have u updated the admob to google admob sdk?

Hi, I’m afraid not. I will however update the app now to support the latest Google Services Ads

I’d like to buy this game.. but I don’t like piranha.. could it be change to something?

Yea sure. You need to replace the spritesheets of the fish and put your own . It can be easily done in res/drawable folder

Is it possible to import to AndroidStudio? After import no files are present in project…

I installed Eclipse and imported the project no problem, however when I run the program from within eclipse i receive the following error:

“Your application contains errors, please fix errors before running.”

Hi, I haven’t tested any of my apps in Android studio yet. I installed it and am using it for other projects until its more stable and used by most developers. I’ll try to release the next app with a tutorial using Android studio.

What are the reported errors? Most probably its android api version problems

Is there a version that is compatible with Lollipop?

I haven’t tested any of my apps on lollipop yet, but I assume they all work. Have you tested it?

Hi , I want to change Background please Help me

Hi, the background is build in the game, its not an image. Im maingame.java line 801 you can change the following to change the background/ sand:

//Rendering of background
    public void renderBackground(Canvas canvas) {

        //TODO: you may wish to change background colors from here
        canvas.drawRect(0, 0, ScreenWidth(), ScreenHeight(), background_shader);
        //canvas.drawColor(Color.rgb(38, 148, 191));


    public void drawSand(Canvas canvas) {
        Path sand_path = new Path();
        sand_path.reset(); // only needed when reusing this path for a new build
        sand_path.moveTo(0, ScreenHeight() - dpToPx(sand_height)); // used for first point
        sand_path.lineTo(ScreenWidth(), ScreenHeight() - dpToPx(sand_height) * 0.7f);
        sand_path.lineTo(ScreenWidth(), ScreenHeight());
        sand_path.lineTo(0, ScreenHeight());
        canvas.drawPath(sand_path, Sand_shader);



When i am trying to see ads .. the logs says that “Ad finished loading.” but the banner & interstitial are empty.

what should i do?


Fixed it! Thanks.

Great to hear that! Thanks for the purchase!