File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Space Invaders: Need some help with our program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Space Invaders: Need some help with our program" Watch "Space Invaders: Need some help with our program" New topic
Author

Space Invaders: Need some help with our program

Robel Bayisa
Greenhorn

Joined: Dec 16, 2012
Posts: 6
Hey guys, it's me again!

My friend and I have started a project together that will be evaluated in our final exams in early May. We've decided to create a simple Space-Invaders-inspired little game.
We've done a bit of coding (and I should inform you now that we're not allowed to use any special programs or functions in our code; only what is supplied by a certain Java file given to the class, containing simple scanners and basic maths functions, among other tools).

That "certain" Java file I was talking about, however, as well as our latest code for the game in a Java file, can't be attached here for some reason so I've made a Google Doc of both codes in one, which you can check out through this link -- https://docs.google.com/document/d/1_btU3drkAdRx-gUv0JUDFFuvsG4wWW9yASXOYOBDF-M/pub -- but hopefully you may understand what's happening!

Now the main issue we've been facing was the inability to move our ship while shooting; we knew this was probably because we didn't put in a "while" loop anywhere in the code which meant that the game would only process one sub-program at a time. So basically if the shooting sub-program was running then the moving sub-program would be muted. We found a rather 'makeshift' solution to the problem by increasing the speed of the projectile so that the player wouldn't be bothered by waiting for the projectile to disappear. However our aim is to have this fixed but we simply don't know what to do!

We also want to eventually get the enemy aliens (on top) to move; with the program we have now, we'd have to mute absolutely everything else while the enemy aliens moved around. Is there any way we could resolve this?

Thanks in advance for your timely replies!
Robel
Stuart A. Burkett
Ranch Hand

Joined: May 30, 2012
Posts: 679
The standard way to make multiple things (appear to) happen simultaneously in your program is to make your program multithreaded and have each action performed by a separate thread.

It might be possible to simulate this in a single thread by having a class for each action that maintains the state of the action and then have a loop that calls each class in turn to perform a short piece of each action, but i think this would be more complex than using threads.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Space Invaders: Need some help with our program