Results 1 to 2 of 2

Thread: Using Random

  1. #1
    razmyasdfg is offline Member
    Join Date
    Jul 2008
    Location
    London (Kingsbury)
    Posts
    41
    Rep Power
    0

    Default Using Random

    using Random
    hi i need to use the random for set the position for a sprite
    this is my code if anyone knows plz help me

    here is my code

    x_enemySprite[0] = new Sprite(Image.createImage("/E4.png"));
    x_enemySprite[0].setPosition(0,27);
    x_enemyXSpeed[0] = -2;

    x_enemySprite[1] = new Sprite(Image.createImage("/E5.png"));
    x_enemySprite[1].setPosition(52,10);
    x_enemyXSpeed[1] = -2;

    x_enemySprite[2] = new Sprite(Image.createImage("/E6.png"));
    x_enemySprite[2].setPosition(30,20);
    x_enemyXSpeed[2] = -2;

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default

    Where in your code do you want it? what kind of random number? Is it in a range ie between 500 & 900?
    Have you read the API doc for the Random class?

Similar Threads

  1. Replies: 8
    Last Post: 04-19-2009, 05:50 PM
  2. random numbers without random class`
    By carlos123 in forum New To Java
    Replies: 4
    Last Post: 01-17-2008, 10:44 PM
  3. random numbers
    By carlos123 in forum New To Java
    Replies: 1
    Last Post: 12-22-2007, 02:56 AM
  4. Random Integers
    By www.kwalski.com in forum Java Applets
    Replies: 8
    Last Post: 12-09-2007, 05:49 PM
  5. Random Generator
    By padutch2 in forum New To Java
    Replies: 1
    Last Post: 12-03-2007, 06:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •