Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (429)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (468)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Networking & Multiplayer / Allow to create game room. on: 2013-10-27 16:09:04
I would like to ask, how can I let players, to create game rooms.(Actually, not inside my web server, but inside their computer). For example, they connect to the website, create new room, but latency and other things depends on where host lives and etc. This is something like haxball.com or curvefever.com
2  Game Development / Networking & Multiplayer / I want to move my game from single player to MP on: 2013-10-09 16:56:34
Hello, I have created mini basketball. Actually, there is a player(oval) who moves around the basketball court, there is also a ball, player can pick the ball, pass it to the all directions, move around with it. I was keeping in mind, that I would like to publish this game on the internet. Now It is that time, I want to know few things, maybe you can give me the answer.

Does server can be created only with java?
I mean, I used to write mini chat programs. When Client is created with Java, and server also, is a java class which uses threads to communicate with clients. Is here the same situation?

If the answer to the first question is "yes", then what I need to put my server 24/7 available?
I was thinking about the idea, to let for players to download the client program and keep server inside somewhere. So, do I need to offer Virtual private server, or I can live on with hosting?

How should I run my server?
Do I need to upload server in the FTP? How should I make that server running? Does it is done with some commands?

Does the game logic should be in the server?
I have read, that client should just listen for inputs and updates the view. Is that mean that my all work is worthless? Because my game logic is inside client class.

Thank your for your answers.
3  Game Development / Game Play & Game Design / Re: Strange behaviour at the beginning of the game on: 2013-10-06 20:06:41
1. Do you change that SPEED variable somewhere?

2. i'm not quite sure why you do this:
1  
if(c == 'w' && player.getY()+-1*SPEED > 10)

this just checks if there is a collision at the beginning of the movement? so you could basically just run out of that rectangle you made up for collisions (if you don't stop when you touch it and just keep "w" pressed) cause it just gets checked when you press w and not everytime it changes the position.
No, I don't change it anywhere. Im trying to fix this maybe 7 hours. I tried a lot of things. What I discovered, is that this jump when I click the button very first time, I tried to block that first push, it worked, but then the movement looked very unnatural and the problem still occured when I pressed two buttons in a row(for example left + up). And the collision doesn't work too. Im so exhausted from this. I would really appreciate if you could help me to achieve what I want: Nice looking movement(I can achieve this) but without that first big jump, which destroys all collision detection.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
public Game(){
      initiateImages();
      startGame();
      addListeners();
   }
   
   public void startGame(){
      timer = new Timer(15,this);
      timer.start();
   }
   
   private void addListeners(){
      setFocusable(true);
      addKeyListener(new KeyListener(){

         @Override
         public void keyPressed(KeyEvent e) {
            pressed.add(e.getKeyChar());
            for(Character c : pressed){
               if(c == 'w'){
                  speedY = -SPEED;
               }else if(c == 's'){
                  speedY = SPEED;
               }else if(c == 'a'){
                  speedX = -SPEED;
               }else if(c == 'd'){
                  speedX = SPEED;
               }
            }
         }

         @Override
         public void keyReleased(KeyEvent e) {
            pressed.remove(e.getKeyChar());
            if(e.getKeyChar()== 'w' || e.getKeyChar() == 's'){
               speedY = 0;
            }
            if(e.getKeyChar()== 'a' || e.getKeyChar() == 'd'){
               speedX = 0;
            }
         }

         @Override
         public void keyTyped(KeyEvent arg0) {
            // TODO Auto-generated method stub
           
         }
         
      });
   }
   
   private void initiateImages(){
      court = new ImageIcon("images/court2.jpg").getImage();
      ball = new Ball();
      player = new Player();
   }
   
   private void update(){
      if(player.getX()+speedX>10 || player.getX()+speedX<1190){
         player.setX(player.getX()+speedX);
      }
      if(player.getY()+speedY>10 || player.getY()+speedY<640){
         player.setY(player.getY()+speedY);
      }
   }
   
   public void paintComponent(Graphics g){
      super.paintComponent(g);
     
      //Draws background image
     g.drawImage(court, 0, 0, null);
     
      // Creates graphics2D object for rendering hints
     Graphics2D g2d = (Graphics2D)g.create();
     
      // Sets rendering hints.
     g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
     
      // Draws results
     g2d.setFont(new Font("Serif",Font.BOLD, 36));
      g2d.setColor(Color.WHITE);
      g2d.drawString("Green 0 : 0 Yellow", 40, 40);
     
      // Draws ball and player
     g2d.setFont(new Font("Serif",Font.BOLD, 20));
      g2d.drawImage(ball.getBall(),ball.getX(), ball.getY(),null);
      g2d.drawImage(player.getPlayer(),player.getX(),player.getY(),null);
      g2d.drawString("13",player.getX()+10,player.getY()+25);
   }

   @Override
   public void actionPerformed(ActionEvent arg0) {
      update();
      repaint();
   }

}


This code achieves smooth moves, but that big jump at the beginning(probably because of delay in key presses) are ruining everything.
4  Game Development / Game Play & Game Design / Strange behaviour at the beginning of the game on: 2013-10-06 16:59:46
Hello, in my game, player doesn't start to move constantly. For example:
X coordinates:
100 (position before movement)
104 (start to move)
160  Huh
164
168
etc..

Why it suddenly jump from 104 to 160? Here is my code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
   
   private void addListeners(){
      setFocusable(true);
      addKeyListener(new KeyListener(){

         @Override
         public void keyPressed(KeyEvent e) {
            pressed.add(e.getKeyChar());
            System.out.println("KEY");
            if(isKeyDown == false){
               for(Character c : pressed){
                  //System.out.print("X : "+player.getX());
                 //System.out.println(" Y : "+player.getY());
                 
                  if(c == 'w' && player.getY()+-1*SPEED > 10){
                     speedY = -1*SPEED;
                  }if(c == 's' && player.getY()+SPEED < 640){
                     speedY = SPEED;
                  }if(c == 'a' && player.getX()+-1*SPEED > 10){
                     speedX = -1*SPEED;
                  }if(c == 'd' && player.getX()+SPEED < 1190){
                     speedX = SPEED;
                  }
                  isKeyDown = true;
               }
            }
           
         }

         @Override
         public void keyReleased(KeyEvent e) {
            pressed.remove(e.getKeyChar());
            int key = e.getKeyCode();
            if(key == KeyEvent.VK_W || key == KeyEvent.VK_S){
               speedY = 0;
            }
            if(key == KeyEvent.VK_A || key == KeyEvent.VK_D){
               speedX = 0;
            }
         }

         @Override
         public void keyTyped(KeyEvent arg0) {
            // TODO Auto-generated method stub
           
         }
         
      });
   }
   
   private void update(){
      System.out.println("UPDATE");
      player.setX(player.getX()+speedX);
      player.setY(player.getY()+speedY);
   }
   
//Timer 20ms
  @Override
   public void actionPerformed(ActionEvent arg0) {
      update();
      repaint();
      isKeyDown = false;
   }

Actually, in player movement, I don't see that jump. But coordinates jump at the beginning and that makes it impossible to make good collision detection. What's wrong here?
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (81 views)
2014-04-15 18:08:23

BurntPizza (73 views)
2014-04-15 03:46:01

UprightPath (84 views)
2014-04-14 17:39:50

UprightPath (67 views)
2014-04-14 17:35:47

Porlus (84 views)
2014-04-14 15:48:38

tom_mai78101 (107 views)
2014-04-10 04:04:31

BurntPizza (167 views)
2014-04-08 23:06:04

tom_mai78101 (263 views)
2014-04-05 13:34:39

trollwarrior1 (214 views)
2014-04-04 12:06:45

CJLetsGame (223 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!