Results 1 to 7 of 7

Thread: Java Game

  1. #1
    thc
    thc is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default Java Game

    Hello to all.
    I'm new to this forum and for the first I want to wish you, Happy New Year. :)
    I'm new Java user, and I have to do a project for the faculty, a race game.
    Can you tell me or give me some tutorials where I can learn? I need the tutorials to be closer of making my game, not general ones.
    The game propose:
    1. The player, must construct their own road with some basic road type(Curves, Straight Road etc). After that, they press GO and the race begin.
    2. The race is with opponents. Other features like score, and some road obstacles, I think that are easy to implement.
    3. The graphics isn't so important. It's 2D and aerial view
    Here's a little sketch how the game should be.
    http://img715.imageshack.us/i/gamei.jpg/
    I'm looking forward for your answers. Thank you!

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

    Default

    Your question is quite broad, and so the answers will likely be as well. For decent Swing tutorials (since I believe you'll code your game in Swing), please check here: Lesson: Using Swing Components (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    If you have more specific questions, please ask them. For help on making sure your question is answerable, please check out the 2nd link in my signature links.

    Best of luck!

  3. #3
    thc
    thc is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default

    Thank you for your answer Fubarable. The link is useful.
    I have found a link, something similar with I have to do.
    Creating 2D Action Games with the Game API
    Can this be converted for running PC platform. I'm saying that is similar because, there is a road constructed by a matrix, which i can transform it to a ROAD editor, and the tank can be the car. Thank you.

  4. #4
    thc
    thc is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default

    I have modified the game a little bit. Now I have some questions for this. How can I implement an ACCELERATION method for the player's car.

    Java Code:
      public void keyPressed(KeyEvent e) {
    
            int key = e.getKeyCode();
    
            if (key == KeyEvent.VK_RIGHT) {
                dx = 4; //here the car is moving and i need to implement some acceleration to this.
            }
    How can I do this??? If a press RIGHT key for 2 seconds, for example, the car is must keep going for a while, and same for the continuous running until the car reaches the top speed.

    2. Another problem is that the game have a opponent which is following the player, to put bombs around him and in the end to kill it ( same for the player ). I must modify the Enemy constructor for transferring the parameters which is the Player.
    in public void move() in Enemy class i must do this algorithm and I don't know how to do this.

    Thank you!
    Have a nice day!

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,516
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by thc View Post
    I have modified the game a little bit. Now I have some questions for this. How can I implement an ACCELERATION method for the player's car.

    Java Code:
      public void keyPressed(KeyEvent e) {
    
            int key = e.getKeyCode();
    
            if (key == KeyEvent.VK_RIGHT) {
                dx = 4; //here the car is moving and i need to implement some acceleration to this.
            }
    How can I do this??? If a press RIGHT key for 2 seconds, for example, the car is must keep going for a while, and same for the continuous running until the car reaches the top speed.

    2. Another problem is that the game have a opponent which is following the player, to put bombs around him and in the end to kill it ( same for the player ). I must modify the Enemy constructor for transferring the parameters which is the Player.
    in public void move() in Enemy class i must do this algorithm and I don't know how to do this.

    Thank you!
    Have a nice day!
    Accelleration means that the change in coordinate (dx) changes as well. You could try to change the above line to: 'dx+= 4' and see your car go voooom disappear from the screen. You need a bit more code, i.e. if dx has reached a maximum value don't increase it anymore. You have to carefully tune the change of dx value.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    thc
    thc is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default

    Something like this but this goes too fast, and it must be in the screen size. The game stage is fixed, and the cars are fighting in the stage. Here's an example Motion with constant acceleration . Car moves slowly, implementation I think must be with some Math functions. Thank you

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,516
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by thc View Post
    Something like this but this goes too fast, and it must be in the screen size. The game stage is fixed, and the cars are fighting in the stage. Here's an example Motion with constant acceleration . Car moves slowly, implementation I think must be with some Math functions. Thank you
    That's why I wrote that you have to carefully tune the change of that dx value.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. java 2d game
    By zombie000 in forum Java Software
    Replies: 2
    Last Post: 02-07-2011, 01:13 AM
  2. help Java game
    By rawan in forum JCreator
    Replies: 1
    Last Post: 12-25-2009, 06:43 PM
  3. Java Game
    By MuslimCoder in forum New To Java
    Replies: 6
    Last Post: 11-12-2009, 10:38 AM
  4. Java 2d game
    By Mr.Beans in forum Java 2D
    Replies: 0
    Last Post: 08-05-2009, 09:27 PM
  5. Help with my game in java
    By lenny in forum New To Java
    Replies: 1
    Last Post: 07-23-2007, 04:40 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
  •