image width/height

Started by tntMaster, September 04, 2003, 22:42:21

Previous topic - Next topic

oNyx

You could also just do usual checks like this:

if(controls[KeyEvent.UP]==1)
//move the ship up


etc :)

If you are wondering about the "&0xff" in:
controls[ke.getKeyCode()&0xff]

It's for keeping only the last 8bits (0-255) because our array can only hold 256 numbers and there are some numbers wich have higher KeyCodes (special keys like german umlauts eg öäü).

Also you could use booleans to flag the keystates... but they are a bit slower and well numbers can be used directly (and if not... the "==1" doesnt really hurt does it? ;))