lundi 12 janvier 2015

Random Generating Images (Pipes) - Flappy Bird

So I'm making a flappy bird game, however, I'm having difficulty on knowing where to declare my random ints in the code. I'm a newbie, so I don't know much, but here are my global variables.



int appletsize_x = 800;
int appletsize_y = 500;

int x_pos = appletsize_x / 2; // x - Position of bird
int y_pos = appletsize_y / 2; // y - Position of bird

int x_pos2 = 100;
int y_pos2 = -50;

int x_pos6 = 100;
int y_pos6 = 350;

int radius = 20; // Radius of bird

int width, height;
int mx, my;
Image img;
MediaTracker tr;

int x_speed = 1;
int y_speed = 1;

int x_speed2 = 10;

int x_speed6 = 10;

Random r = new Random ();
;



Image bird;
int birdWidth, birdHeight;

Image background;
int backgroundWidth, backgroundHeight;

Image pipe;
int pipeWidth, pipeHeight;

Image pipe2;
int pipe2Width, pipe2Height;


Here's my paint method if it helps.



public void paint (Graphics g)
{
// Place the body of the drawing method here

// set color



g.drawImage (background, 0, 0, this);
g.drawImage (bird, x_pos, y_pos, 50, 50, null);
g.drawImage (pipe, x_pos2, y_pos2, 100, 300, null);

g.drawImage (pipe2, x_pos6, y_pos6, 100, 400, null);



//Font Set and placed
Font font = new Font ("Copperplate Gothic Bold", 0, 55);
g.setFont (font);
g.setColor (Color.BLACK);
g.drawString ("FLAPPY BIRD", 200, 100);

} // paint method




Aucun commentaire:

Enregistrer un commentaire