Best way to code a side-scrolling game?

I have three questions about coding a side-scrolling game, which I hope that you guys might know the answers to.

1. When drawing the background to the buffer image (I am planning to use double buffering of course), how should I break up the background into several images? I can't have the whole background's image as one image, otherwise drawing the image all the time would be very inefficient. I am wondering how to break up the image into panels; should I break the image up so that each panel is the size of the screen? Half the screen size? I am wondering what the optimum background panel size is, without having to use any complicated calculations when drawing to the screen.

2. How would I regulate the game speed? For example, if the game runs at the correct speed on a 90MHz CPU, how do I make sure that it won't go out of control on a 3GHz CPU? A friend of mine suggested drawing to the offscreen buffered image at any speed, and then using some sort of timer to draw the the onscreen image a set number of times per second. Would I use a thread and the sleep method to do this, or would a javax Timer be better? Or is there a completely better solution?

3. Let's say I write an interface called Damageable with the method isHit() which will be implemented by an EnemySprite class. How do I trigger the EnemySprite's isHit() method when a Weapon's range touches the range of the EnemySprite?

Thanks in advance.

[1459 byte] By [RATiXa] at [2007-10-2 3:28:53]
# 1

As for #3, for the weapon to know it's within range of the sprite, don't you have a reference to both objects?

I'm thinking something like:

Weapon missle = new Weapon ();

EnemySprite meanie = new EnemySprite();

/*

a bunch of stuff happens

*/

if (missle.inRangeOfSprite (meanie)) {

meanie.isHit();

}

If you posted some of your code, it would be easier to answer.

I have answers for the other two questions locked in my head someplace, and need a book (that I have at home) to answer them.

The book I have at home is:

http://www.amazon.com/exec/obidos/tg/detail/-/1592730051/qid=1130445255/sr=8-1/ref=pd_bbs_1/102-1871867-7867364?v=glance&s=books&n=507846

This is a pretty good book for Java game stuff.

matthewa at 2007-7-15 22:38:31 > top of Java-index,Other Topics,Java Game Development...