Space Pirates 3D action/strategy shooter

That’s not how you’re supposed to do it…There’s good reason for the JComponent class (or Component, if you’re avoiding Swing).

Only about 5 lines of code to do the app version, and a further 5 for the applet version, of a java prog written as a (J)Component. No need to much about with creating new Frames. (PS this is one of the parts of swing/awt documentation that drivers me up the wall: Why has Sun never fully and carefully explained this? - there is a Sun mini-tutorial on it, but it is incomplete and only describes some scenarios. Surely one of the most frequently encountered problems…).

PS, it may not be affecting you now, but if you use any GUI widgets - ever! - I would very strongly suggest not bothering providing things that “work on JDK 1.1”; I’ve been trying to myself for years, and recently gave up. The reasoning is very sad and depressing - Sun has many outstanding AWT bugs that they allegedly never bothered fixing because “there’s a better version of that widget/component that comes with Swing; use that instead” (that’s the short summary). How accurate a reason this is is debatable, but the support for 1.1.x is not good in the GUI…

e.g. I noticed that some of the long-standing bugs (for many YEARS!) in TextArea only just got fixed (IIRC with 1.4.2 beta). This includes showstoppers that have caused projects I’ve worked on to have to write their own complete replacements for TextArea. Sigh.

e.g. The modulus operator in JDK 1.3.x is broken, and the bug has been marked “WONTFIX”, apparently merely because it was too hard for the engineer to fix (I logged the bug, he refused to fix it. Sigh).

I personally would prefer to control direction with my right hand, but then I can’t hit the space bar to fire… ::slight_smile:

But more importantly, don’t forget that not all keyboards have W, A, S and D in the same place. How does this game play on an AZERTY keyboard?

Have you considered mouse support? Rotate the ship in the direction of the mouse cursor each “tick”, left click to fire guns, right click to thrust. It might seem a little funny at first with thrust moving the ship forward, not toward the mouse (finite turning speed), but might be worth a try.

Naturally, Macs don’t have two buttons, so it wouldn’t work for them…

[quote][…]
all my games are frame-based because i run them as both applets and applications theres only one file about 20 lines of actual code that distinguish an applet from application
[…]
[/quote]
actually there hasn’t to be a difference between applications and applets. u can make a hybrid quite easily :slight_smile:


public class KeyMatrixHybrid extends JApplet
{
      public void init()
      {
            getContentPane().add(new KeyMatrix(this,getColorParameter()));
      }

      protected Color getColorParameter()
      {
            try
            {
                  String value=this.getParameter("background");
                  try      {return new Color(Integer.parseInt(value,16));}
                  catch(Exception e){return Color.gray;}
            }
            catch(NullPointerException npe)
            {
                  return Color.gray;
            }
      }

      public static void main(String[] args)
      {
            Frame frame = new Frame("oNyx::KeyMatrix");

            WindowListener l = new WindowAdapter()
            {
                  public void windowClosing(WindowEvent e) {System.exit(0);}
            };
            frame.addWindowListener(l);

            KeyMatrixHybrid applet = new KeyMatrixHybrid();
            frame.add("Center", applet);
            applet.init();
            frame.pack();
            frame.show();
      }
}

an applet will use the init function and an application will use the main function.

image loading is different in both cases but it’s easy to catch:


KeyboardGFX(JPanel p)
{
      //load keyboard graphics
      URL keyboardImagePath;
      keyboardImagePath = (new Object()).getClass().getResource("/gfx/keyboard.gif");
      System.out.println("<-(application)load:"+keyboardImagePath);

      if(keyboardImagePath==null) //running as applet. cheap selfref does the dirty trick :)
      {
            keyboardImagePath=selfRef.getClass().getResource("/gfx/keyboard.gif");
            System.out.println("<-(re)load:"+keyboardImagePath);
      }

      kb=getToolkit().getImage(keyboardImagePath);
}

/me spams src today :>

In general: It’s immense arrogance of any game designer to think that everyone else in the world should use their key-assignments and be happy - given the variance in hand sizes and shapes (e.g. console controllers have to be re-designed for different continents since even the nation-wide averages are very different!), and in things like keyboard layout, there’s plenty of reason not to constrain it. Since it’s so IMMENSELY easy to soft-code this, there seems to be no excuse not to.

In specific for your game: I’m right-handed. This is a simple example of the above, common to approx 75% of the population…my left hand is much less agile/controllable than my right.

Also, like many people (note: many long-time games players no longer have this problem - they have done mild permanent damage to their fingers/thumbs to achieve this positioning! It’s something you come across frequently when you meet enough people with keyboard-induced RSI), I cannot SIMULTANEOUSLY reach four keys arranged in an upside-down T shape without uncomfortable (and rapidly painful) contortions of my fingers and thumb. So, like the best tetris players, I try using two hands for the directional controls - only now it’s quite tricky to hit the spacebar (I’m having to use my wrist).

I don’t understand why you’d want to put users through silly hoops like this, when it costs you practically nothing to have redefinable keys?

Especially since it nearly always improves the game and simplifies bug-fixing (it’s pretty easy for you to fix the tab problem, but would be much much easier if you had soft-coded keys!).

wasd controls are pretty common and they’re becoming more common in fps games. its not that big of a problem because it well get done when i get to it, i don’t have a gui yet and applets don’t like to load editable files so how am i suppose to have modifiable keys?

you sound pretty offended by my keyboard layout

i am planning to use the mouse in the game, it will be used for aiming special weapons or for lasers

if i can integrate i want to add some rts elements to it by allowing the player to click on friendly units and command them with the mouse. It will be tricky to do and i don’t know if it has been done before but it will defineatly interesting to try

:slight_smile: I’m not offended :). But they are a complete b*tch for me to use, and I admit to being irritated that even so many years after Quake’s stroke of genius - a fully-configurable UI using the binding metaphor - there’s still so many many games that can’t do it.

Whilst I was at the GDC, playing on the xBox machines, I met quite a few people who had either gripes or praise for it’s choice of configurations - the gripes were only of “lots of options, but not quite enough; I want it to do this”, and similar comments have come up on discussions on game-dev about Super Metroid Prime’s control mechanism, which some people seriously hate.

An advantage of the PC is that the developer doesn’t have to bother spending lots of time thinking of 3 clever alternative control systems to keep everyone happy - you just soft-code it.

I just wish developers would make both themselves and the players happy! Everyone wins :).

[quote]i don’t have a gui yet and applets don’t like to load editable files so how am i suppose to have modifiable keys?
[/quote]
No reason not to start with soft-coded controls; then when you add the gui, it’s REALLY easy to make the controls configurable (you’ve already done the work of making them configurable, written the methods etc).

…especially since you’ve gone to the effort of making the program an app as well as an applet, so if someone downloads it and runs it locally, they could just edit the text file without problems.

See? Easy :slight_smile:

[quote]i am planning to use the mouse in the game, it will be used for aiming special weapons or for lasers
[/quote]
If you haven’t already, take a look at Cas’s AlienFlux (download links are in the topics in these forums entitled AlienFlux Alpha 1 to 9 :wink: and they tend to have LOTS of posts :)).

Sounds potentially very funky :slight_smile:

i haven’t decided how my io system is going to be setup because i’m too early in the design and development to commit to files (even my models and levels are hard-coded)

even if i did set a keyboard config file i’d have to make an io system which would only be temporary and end up being replaced by a completely different system

i played alien flux and its a very good gaming, but i want the relationship between keyboard aiming and mouse aiming to be more intertwined, essentially i want the player to always be using two different weapons aimed differently but intuitively.

ex Blaster fires in ship direction aimed with keyboard but a laser can fire in any direction

maybe its too complex, i dunno

argh stop spamming me! :slight_smile:

about the keys… the default setup is crap imho. make it configurable or define several predefined sets of keys.

no need to save the settings if you have say two predefined settings (wasd and arrow keys

[quote]i haven’t decided how my io system is going to be setup because i’m too early in the design and development to commit to files (even my models and levels are hard-coded)
[/quote]
(gasp) You’ve made a pseudo-3D action game, and you’re worried about your “io system”? It’s only six lines of code:


BufferedReader br = new BufferedReader( new InputStreamReader( new FileInputStream( inputFile ) ) );
String line = null;
Hashtable keys = new Hashtable();
while( (line = br.readLine()) != null )
{
   int equalsSign = line.indexOf( '=' );
   keys.put( line.substring( 0, equalsSign ), line.substring( equalsSign+1 ) );
}

…although obviously you can make it easier for you to use elsewhere if you also have get and set methods for key-name / int Key Constants pairs.

…which is precisely why Java has this funky thing called an interface. You code to an interface, and then if you want to modify the class later on, you can do so - even without recompiling. Well, you’ll have to recompile one class unless you’re being clever and using reflection.

If you want help on doing IO (which for this situation really is VERY simple in Java - only gets complex when you want to do big servers with many clients) then ask away in these forums. Even IO from applets is only two extra lines of code (one line, if you’re sensible and package everything in a JAR).

;D
Nice game. I like it!

i didn’t realize till now that i can load files with an applet via URLs. I don’t know why i never noticed it before. i added keybindings,resolution settings and i’m gonna add simple scripting for maps, models and game objects

i also added some new levels with team fights (15 vs 15) that actually play out quite nicely

unfortunately geocities is being a pain in the arse and i can’t upload them right now.