Loading...
Logo
Processing Forum
Processing is my home away from home.

After a month of work, I have finally finished the sequel to Target Defense. It features tons more things than the original did.

Though it can work as an applet, I've decided to only offer downloads, so that OpenGL can be used for the lighting Fx. 



You can download it, and the original, here:


I only have 32 bit versions available, because I don't have a 64 bit OS (outside of windows7, which plays 32 bit versions fine) to test on, but I hope to get those up soon.

I hope you all will enjoy this game, and I also hope that it helps motivate processing users to see processing as a serious development environment, and not only just a simple sketch maker.

I don't release my source code, because these games are a ton of work and I must find a way to profit from them. For now, I can help processing by adding it the startup screen for this game; To help spread the word about this wonderful tool.  In case you're wondering, this game contains 4,656 lines of code. If I can't make some money doing it, where will I find the time to code like that? I probably won't. :(

Features include: GL lighting Fx, Streamed playlist (45 min+ of music), Achievements system, 20 Maps, Custom map editor, tower stats shown in and after game, and user selectable resolutions, including fullscreen(at least on windows).

Thanks for the comments on my other games and all the views and downloads this community gave me for Target Defense 1. Comments, suggestions, and bug reports are all welcome.

Enjoy!

Replies(7)

Great! I can't wait to play it! I have played and downloaded the first one and it amazed me at what people could do in Processing.
Your first target defense game inspired me to learn processing and I haven't stopped learning since. I can't WAIT to download this new one. Great job on the series.

from an excited fan,

TheGamersHaven

Someone has been really busy! 

I am also an old fan of the original target defense, I played that quite a lot. 

Just tested the OS X version of Target Defense 2, for the moment just to see whether it runs. It does, and correctly switches screen resolutions etc. 

I just noticed two problems: 
  • the sound has a lot of glitches, probably related to the amount of action on the screen but I did not have time to check
  • the game froze suddenly, see screenshot below. The game just halted, as if I had paused it and the Java console did not show anything either. But I could not wake it up again.

Andreas


@Andreas

Thanks for the info, i'm glad to hear that the resolution switched ok.

Not sure on the sound problem, minim crackles in linux but only with a low buffer, so i increased it to 4096. Windows doesn't crackle no matter what the buffer, and i can see it's going to be hard to polish the mac version without access to a mac.

The freeze is most likely that the game is using too much memory. I've done a lot to lower the amount that it uses, but just that main window graphic uses a ton. (It's a PGraphics, with random tiles, the star background, and the path drawn into it, and uses like 50 mb). 

I still get that freeze error sometimes here on windows, but i am befuddled as the game is usually using about 150 mb at that time, and i still have plenty of ram free. But that is the only late-game glitch i get in processing; out of memory. (my processing is set to use 1024mb).

Note that so far the freeze only happens in larger resolution, so i'm pointing my finger at the PGraphics.  The game loads and resizes all the graphics to create the larger window, so more resolution means tons more memory.....


If anyone has any information on increasing the sound quality in Osx, please help out. I've got the audio great on all other platforms......

I don't know much about minim and use trial and error myself each time. In Black Hole Pong I got it to work without noise or crackle, on my Macbook at least. I think it helped to only using AudioPlayer and being careful about changing gains. I have attached my Sound class below. Nothing special but it gives you one data point for what might work on OS X.

Andreas

Copy code
  1. class Sound {

  2.   final static int maxsong=2; // don't change this!
  3.   final static int maxsample=8; // don't change this!
  4.   AudioPlayer[] song = new AudioPlayer[maxsong];
  5.   AudioPlayer[] samp = new AudioPlayer[maxsample];

  6.   int[] song_gain= { 
  7.     -25,-5
  8.   }; 

  9.   Sound () {
  10.   } 

  11.   void load_sounds() {

  12.     // load songs and music
  13.     song[0] = minim.loadFile("32274__genghis_attenborough__Flood_loop.wav",4096);
  14.     song[1] = minim.loadFile("34115__kwazi__Shaker_Woda_Conga_Bongo_Templeblock.wav", 2048);
  15.     song[0].setGain(-80.0);
  16.     song[0].play();
  17.     song[0].loop();
  18.     song[1].shiftGain(-80.0, song_gain[1], 1000);
  19.     song[1].play();
  20.     song[1].loop();

  21.     // sample for fast star
  22.     samp[0] = minim.loadFile("9088__tigersound__jetbike_flypast.aif",512);
  23.     samp[0].setGain(-10);
  24.     // sample for goal   
  25.     samp[1] = minim.loadFile("27568__suonho__MemoryMoon_space_blaster_plays.aiff",512);
  26.     samp[1].setGain(-15);
  27.     // bounce at border
  28.     samp[2] = minim.loadFile("7811__helitron__909_EH_kick2.wav",512);
  29.     samp[2].setGain(-20);
  30.     // star_birth
  31.     samp[3] = minim.loadFile("69219__meowtek__bitline4A.wav",512);
  32.     samp[3].setGain(-23);
  33.     // worm hole
  34.     samp[4] = minim.loadFile("1797__serkantemiz__supernova_fx.wav",512);
  35.     samp[4].setGain(-15);
  36.     // new worm 
  37.     samp[5] = minim.loadFile("9700__A43__A43_thudkick.aif",512);
  38.     samp[5].setGain(-15);
  39.     // game over
  40.     samp[6] = minim.loadFile("45137__DJ_Chronos__Dark_church_bell.wav",512);
  41.     samp[6].setGain(0);
  42.     // gravity boost
  43.     samp[7] = minim.loadFile("87557__DaveOfDefeat2248__gasmask_trim.wav",512);
  44.     samp[7].setGain(-17);
  45.   }

  46.   void play(SoundTypes sample, boolean single) {
  47.     int samplenr=0;
  48.     switch(sample) {
  49.     case  STARBIRTH:
  50.       samplenr=3;
  51.       break;
  52.     case   BOUNCE:
  53.       samplenr=2;
  54.       break;
  55.     case GOAL:
  56.       samplenr=1;
  57.       break;
  58.     case  WOOSH:
  59.       samplenr=0;
  60.       break;
  61.     case  WORMHOLE:
  62.       samplenr=4;
  63.       break;
  64.     case  NEWWORM:
  65.       samplenr=5;
  66.       break;
  67.     case GAMEOVER:
  68.       samplenr=6;
  69.       break;
  70.     case BOOST:
  71.       samplenr=7;
  72.       break;
  73.     }
  74.     if (Osound && !(samp[samplenr].isPlaying() && single)) {
  75.       samp[samplenr].play(0);
  76.     }
  77.   }

  78.   void intro() {
  79.     if (Omusic) {
  80.       song[0].shiftGain(song_gain[0], -80.0, 5000);
  81.       song[1].shiftGain(-80.0, song_gain[1], 2000);
  82.     }
  83.   }

  84.   void mute() {
  85.       song[0].setGain(-80);
  86.       song[1].setGain(-80);   
  87.   }

  88.   void unmute() {
  89.       song[1].shiftGain(-80.0, song_gain[1], 500);
  90.   }


  91.   void game() {
  92.     if (Omusic) {
  93.       song[0].shiftGain(-80.0, song_gain[0], 2000);
  94.       song[1].shiftGain(song_gain[1], -80.0, 5000);
  95.     }
  96.   }

  97.   void stop() {
  98.     // Stop the music
  99.     for (int i=0;i<maxsong;i++) {
  100.       if (song[i]!=null) {
  101.         song[i].close();
  102.       }
  103.     }
  104.     for (int i=0;i<maxsample;i++) {
  105.       if (samp[i]!=null) {
  106.         samp[i].close();
  107.       }
  108.     }
  109.     minim.stop();
  110.   }
  111. }

Thanks for the help A, although i can't really implement that code without mac to test on. Does anyone know if hackintosh is worth investigating for these purposes? Since i have a couple pc's, buying a copy of SL would be much cheaper than getting a whole mac. I would like to make this thing work well for mac users, as my games seem to be pretty popular among them.

Also, investigating the memory crash, i find that junk isn't being cleaned up properly in this game. I found what appears to be a solution:

1. Removed the noLoop(); from draw. I was using that for pausing purposes.
2. Added System.gc(); to the clickfunction every time you click an option button. 

Only by adding both of these, does the garbage cleanup finally work. 

The game is now using @140 mb to play in default 800x600 resolution. 
It's a really great game (like "Vector TD" series) but i've seen some bug, so in a constructive way these are :
00-Some lags when audio file is changing
01-Pressing escape on the statistic page : show pause menu with no effect
02-Damage chrono scale is not auto resized
03-Upgrade and sell costs are not centered when it's more than 999
04-Pause game and move window's game out off screen and move back ... blank white screen
05-Game freezing after playing all music file (!)
 
(IE9 - JRE 6u23 - Vista)
Thanks for the info!