Author Topic: NaaLaa - MissileCommand  (Read 7479 times)

kevin

  • Guest
NaaLaa - MissileCommand
« on: January 04, 2013, 08:41:06 PM »
 Hi - this is a simple game based on the 1980's game Missile Command ..... I am working on an improved version now, which will probably include more missile bases and maybe some of the attacking missiles splitting into 2 randomly. This was really a test for me to make sure that I could get the mechanics of the game working properly (more or less).
 I'm happy to add the source code if anyone wants it, but at the moment it is embarrassingly  messy, so I'd like to clean it up first.
 Level 1 is really simple, aimed just for the player to get used to the controls - this is why I have added the options to start at higher levels to the front menu.
 This is my first real attempt at a full (simple) game, and I would really appreciate any feedback, particularly on things that I could look to improve on or add into the new version, if anyone has the time or desire to do so? ...I'm happy to accept criticism because I want to improve, so don't worry about upsetting me....Thanks

rem --------------------------------------------
rem -------------  thanks to   -----------------
rem ------  CVirus for the Menu system  --------
rem ---   JSM for the High Score Library  ------
rem -- and of course MOPZ for creating NaaLaa --
rem ------  and sharing it with us -------------
rem --------------------------------------------
rem ----- sound files from freesound.org -------
rem --------------------------------------------


****  updated zip file is on the second page *****
« Last Edit: February 12, 2013, 06:13:02 PM by kevin »

cvirus

  • Guest
Re: NaaLaa - MissileCommand
« Reply #1 on: January 05, 2013, 03:00:16 PM »
This is way cool.  ;D

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: NaaLaa - MissileCommand
« Reply #2 on: January 05, 2013, 03:23:02 PM »
Just a request: could you please add audirere.dll to the zip? I have always to search my HDD for it.

kevin

  • Guest
Re: NaaLaa - MissileCommand
« Reply #3 on: January 05, 2013, 03:34:27 PM »
thanks for the kind words cvirus.... I am having a lot of fun with NaaLaa....
Cyber - new zip is attached with the sound dll included....hope it works ok - I just added it into the 
folder, which I assume is where it needs to go?
« Last Edit: February 12, 2013, 06:11:52 PM by kevin »

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: NaaLaa - MissileCommand
« Reply #4 on: January 05, 2013, 09:23:27 PM »
Yes, thank you it works fine. Cool game which becomes really hard in the later levels.  8)

Mopz

  • Guest
Re: NaaLaa - MissileCommand
« Reply #5 on: January 10, 2013, 05:39:00 PM »
That's great fun :)

(Sorry for my late response, Christmas days are nightmare for game developers  ;) )

Can I have the honour of adding it to naalaa.com, it would make a nice Java applet?

kevin

  • Guest
Re: NaaLaa - MissileCommand
« Reply #6 on: January 10, 2013, 06:47:27 PM »
I'd be honoured Mopz ......... it's only set up as a Windows exe at the moment, but I'll happily amend the code - it'll be good practice for me as I've not done that before....shall I do that then after testing post the amended code here? Should have time at the weekend....

Mopz

  • Guest
Re: NaaLaa - MissileCommand
« Reply #7 on: January 11, 2013, 08:06:01 AM »
If you've got JDK installed and setup you probably won't have to send me any code, just compile to Java applet from the menu. But if you want I will gladly do it for you, because there are some things you've got to do in an applet, like calling the running() in "player controlled" loops to check if the game is still running or the user has left the page. When running() returns false, you must call 'end' and possibly stop music loops.

kevin

  • Guest
Re: NaaLaa - MissileCommand
« Reply #8 on: January 11, 2013, 09:05:13 AM »
Yes, I must admit that I had a quick look at the NaaLaa helpfile this morning and the applet creation is more complicated than I thought (I hadn't given it a second look before) - I'm at work at the moment, but when I get home I'll start by amending the code for the image files, and see where I go from there, but I suspect I may need to take up your kind offer of help.

kevin

  • Guest
Re: NaaLaa - MissileCommand
« Reply #9 on: January 12, 2013, 05:52:58 PM »
Hi Mopz.... I've amended the source to include .png images, which have been added to the data folder. It checks for "not running()" in the main game loop. It compiles to a Java class file locally, but I haven't been able to test the file..  so could I leave the files with you to check to see what I have missed? It would be really useful if you could let me know what further changes you  have had to make if you have time, but not a problem if not. Data folder and the source code is included in the attachment.....many thanks.
« Last Edit: February 12, 2013, 06:13:37 PM by kevin »

Mopz

  • Guest
Re: NaaLaa - MissileCommand
« Reply #10 on: January 12, 2013, 08:04:26 PM »
I did the following things to make it work:

* Added code for loading a font (courier.txt, courier.png, put in the data folder), because naalaa bitmap fonts can't be generated on the fly in applets

* Inserted a running check in the menu

* Added a text, "Loading ..." when the assets are being loaded, so that people knows something is going on.

* Put all the naalaa class files in the same folder as the program

* Embedded the applet in a html page

I've attached the result to this post. If it's fine with you I'll put it on naalaa.com, where nothing has happened for a long time ;)

Edit: For those of you who haven't tried the game yet, you can now test it online at http://www.naalaa.com/applets/MissileCommand/mc.html. Let's see if the high score works  :D  I'll add it to the online games section of the homepage shortly.
« Last Edit: January 13, 2013, 09:13:14 AM by Mopz »

kevin

  • Guest
Re: NaaLaa - MissileCommand
« Reply #11 on: January 12, 2013, 08:29:02 PM »
Hi mopz...thank you very much for the  detailed explanation.....And for the changes....please feel free to do anything with the code...one question though, when I click on the "Chrome HTML doc" in the attachment to run the game, it seems to run quite slowly compared to the .exe file?
edit - it seems to be when the explosions are called, everything runs slower on the on-line version.....?
« Last Edit: January 12, 2013, 08:33:31 PM by kevin »

Mopz

  • Guest
Re: NaaLaa - MissileCommand
« Reply #12 on: January 12, 2013, 08:44:22 PM »
I'll have a look at that :)  I'll start with replacing

   shouldDraw = SPD_HoldFrameDraw(60)

with

   proc SPD_HoldFrame 60

When you use SPD_HoldFrameDraw in your game loop you should do it like:

Code: [Select]
rem game loop.
shouldDraw = true
do
   rem do all game logic, update all positions, do collision tests etc.
   ...
   rem only draw if there's time for it.
   if shouldDraw
      rem draw everything.
      ...
   endif
   redraw
   shouldDraw = SPD_HoldFrameDraw(60)
loop

When you use the normal SPD_HoldFrame, both logic and drawing will slow down if the FPS (60) can't be kept. But when using SPD_HoldFrameDraw you keep on updating the game 60 times per second even if you can't draw 60 times per second. In your code you're not using the variable, shouldDraw, returned by SPD_HoldFrameDraw.


Mopz

  • Guest
Re: NaaLaa - MissileCommand
« Reply #13 on: January 12, 2013, 08:51:16 PM »
No, applets tend to slow down when you draw lots of colorized images (such as particles) :)  But if you use the value returned by SPD_HoldFrameDraw you can replace SP_DoParticles with SP_UpdateParticles and SP_DrawParticles. Put the SP_UpdateParticles with the other game logic and SP_DrawParticles in the "if shouldDraw" block as described above.

I can have a closer look at the source code tomorrow. What needs to be done is basically to separate the logic from the drawing and put all the drawing code within the "if shouldDraw" block. This only goes for the game loop.

kevin

  • Guest
Re: NaaLaa - MissileCommand
« Reply #14 on: January 12, 2013, 08:57:51 PM »
Thanks Mopz.....it's too late or me to look too closely unfortunately, but  i can see the logic in your responses, and I'll try to follow those suggestions in future examples - i think i had got lazy in the logic because it did not impact on the Windows version......
Another minor thing, i see that in the online version the mouse cursor is visible - is there an easy way for it to not be drawn, like in the .exe version, where we just use "set mouse off"?
« Last Edit: January 12, 2013, 09:03:01 PM by kevin »