Reusing the Pong engine
Feel free to copy and paste all the code in this section. It is nearly identical to the structure of the Pong game. What will vary is the other classes we will create (Bullet
and Bob
) as well as the way that we handle player input, timing, updating and drawing within the BulletHellGame
class.
As you proceed with this section glance over the code to notice subtle but important differences which I will also point out to you as we proceed.
Coding the BulletHellActivity
Paste and examine this code into the BulletHellActivity
class.
import android.app.Activity; import android.graphics.Point; import android.os.Bundle; import android.view.Display; // This class is almost exactly // the same as the Pong project public class BulletHellActivity extends Activity { // An instance of the main class of this project private BulletHellGame mBHGame; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ...