Results 1 to 7 of 7
Like Tree1Likes
  • 1 Post By Fubarable

Thread: Programming a simple ball game

  1. #1
    kez323 is offline Member
    Join Date
    May 2012
    Posts
    8
    Rep Power
    0

    Default Programming a simple ball game

    HEEEEY!

    okay ive been set as a task to make a "Basic Game" where you can move a ball around the screen with the arrow keys.

    does anyone have any good links to places/vidoes/ source-code examles that would help me?


    - Thanks..

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Programming a simple ball game

    You'll be better off in my experience to try to write your program, and then come on back with your code if you get stuck.
    DarrylBurke likes this.

  3. #3
    kez323 is offline Member
    Join Date
    May 2012
    Posts
    8
    Rep Power
    0

    Default Re: Programming a simple ball game

    Okay ive tried and im COMPLETLEY STUCK

    ive gotten a man to walk left and right.
    but i have no clue how to make the guy jump?
    this is that part of the code:

    package GamePackage;

    import java.awt.Image;
    import java.awt.event.KeyEvent;
    import javax.swing.ImageIcon;

    /**
    *
    * @author kezhall
    */
    public class Player {
    int x, dx, y;
    Image still;
    public Player(){
    ImageIcon i = new ImageIcon("/Users/kezhall/Desktop/Player.png");
    still = i.getImage();
    x = 10;
    y = 172;

    }
    public void move() {
    x = x + dx;
    }

    public int getX() {
    return x;
    }

    public int getY() {
    return y;
    }

    public Image getImage() {
    return still;
    }

    public void keyPressed(KeyEvent e) {
    int key = e.getKeyCode();
    if (key == KeyEvent.VK_LEFT)
    dx = -1;

    if (key == KeyEvent.VK_RIGHT)
    dx = 1;
    }

    public void keyReleased(KeyEvent e) {
    int key = e.getKeyCode();

    if (key == KeyEvent.VK_LEFT)
    dx = 0;

    if (key == KeyEvent.VK_RIGHT)
    dx = 0;
    }

    }

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,556
    Rep Power
    25

    Default Re: Programming a simple ball game

    how to make the guy jump?
    Describe what a "jump" would look like. Do it in terms of the guy's x,y locations and how they'd change over time.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    kez323 is offline Member
    Join Date
    May 2012
    Posts
    8
    Rep Power
    0

    Default Re: Programming a simple ball game

    im confused? :S

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,556
    Rep Power
    25

    Default Re: Programming a simple ball game

    You'll have to explain.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,404
    Rep Power
    20

    Default Re: Programming a simple ball game

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 10
    Last Post: 06-25-2012, 11:21 PM
  2. simple game programming help
    By b.m in forum New To Java
    Replies: 0
    Last Post: 11-25-2010, 05:16 PM
  3. Need help with a third ball in game.
    By vlan in forum Java Applets
    Replies: 2
    Last Post: 05-30-2010, 03:37 PM
  4. Problem deleting ball from bouncing ball app
    By adlb1300 in forum New To Java
    Replies: 2
    Last Post: 12-03-2007, 09:08 PM

Tags for this Thread

Posting Permissions

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