Java-Gaming.org Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (654)
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] 2 3 ... 20
1  Game Development / Networking & Multiplayer / Client-Server Communication Design? on: 2015-07-03 18:05:36
I am designing a chat app for android in order to learn some basic Android principals and use my prior knowledge of Kryonet as well. The app works fine when I have just one activity and the such but now I'm thinking that maybe I should have multiple "Client" connections open doing multiple things. So what I'm asking is should I have just one client connected to the server or multiple clients expecting different types of data?
2  Game Development / Networking & Multiplayer / Re: Android Kryonet client won't connect to my server on PC. (Well my MAC :P) on: 2015-06-18 04:16:17
I assume the server was running when you started the client?

Now I may ignorant, but I'm not brain dead. Yes, the server was running.
3  Game Development / Networking & Multiplayer / Re: Android Kryonet client won't connect to my server on PC. (Well my MAC :P) on: 2015-06-18 04:13:53
I see no server. I see two clients.

Ahh, it appears I copied the wrong source. That there is the PC version of the client. Anyhow, I replaced it with my actual server code.
4  Game Development / Networking & Multiplayer / Android Kryonet client won't connect to my server on PC. (Well, my MAC :P) on: 2015-06-18 03:53:36
 made a basic server in eclipse:

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  
Server server;
   int tcp = 8885, udp = 8885;
   
   public ServerMain() {
      server = new Server();
      server.addListener(new Listener() {
         public void connected(Connection c) {
            System.out.println("Connection made");
         }
         
         public void received(Connection c, Object p) {
           
         }
         
         public void disconnected(Connection c) {
            System.out.println("Disconnection made");
         }
      });
      server.start();
      try {
         server.bind(tcp, udp);
      } catch (IOException e) {
         e.printStackTrace();
      }
   }
   
   public static void main(String[] args) {
      new ServerMain();
   }


Then I created my client in android studio. I installed the library correctly. (According to google) I put the Kryonet jar into the libs folder and then rebuilt the project. I could then use Kryonet classes. Here is my code for my client:

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  
Client client;
String ip = "MY.IP.ADDRESS";
int tcp = 8885, udp = 8885;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Log.i(TAG, "Start");

    client = new Client();
    client.addListener(new Listener() {
        public void received(Connection c, Object p) {

        }
    });
    client.start();
    try {
        client.connect(5000, ip, tcp, udp);
        Log.i(TAG, "conected");
    } catch(IOException e) {

        Log.i(TAG, "Error: " + e.getMessage());

    }
}


It's the exact same code I would use in a normal Java client except now it's running directly from my android device. I get this error:

1  
Error: Unable to connect to: /MY.IP.ADDRESS:8885


It cannot connect to my IP even though I port forwarded it and all. Why won't it connect? I have read online to add in this to my manifest file:

1  
2  
3  
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />

So, I did:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
<?xml version="1.0" encoding="utf-8"?>
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

Still to absolutely no avail. What am I doing wrong? (P.S. I have tried with both my network IP, and my public IP. I have no idea what I'm doing wrong, everything works fine with a normal Java program, but with an android app it bugs out.)
5  Discussions / Miscellaneous Topics / Re: What kind of keyboard do you code on? on: 2015-06-07 18:19:40
I have a Razer Blackwidow Ultimate 2013 Smiley I love mechanical keyboards

I also have that model. Very nice keyboard. I like the green backlight.
6  Discussions / Miscellaneous Topics / Re: What's your favorite OS and why? on: 2015-06-06 03:53:57
I love Windows because it isn't Mac.

Why I ever thought iOS Development was worth the suffering of a mac is beyond me.
7  Game Development / Newbie & Debugging Questions / Re: Trying to stop planets from spawning on top of each other on: 2015-06-04 00:20:47
In this if statement:
1  
if((((x >= temp.x) && (x <= temp.x + temp.getWidth()+32) && ((y >= temp.y) && (y <= temp.y + temp.getHeight()))))) {


You're checking if the planet is INSIDE the planet. You're not checking if it touches/overlaps slightly.

I don't see a question in your post. Do you want the planet to move after detecting a collision, do you want to fix the collision code, etc.

Just a side thing: don't make new Random instances for each call of nextInt. Just store one locally and call from that one.

Ahhh, I get it now. Thanks for the help. I have to add the size of both planets to the coords, not just the planet your checking against. I would've never caught that. Thanks.
8  Game Development / Newbie & Debugging Questions / Trying to stop planets from spawning on top of each other on: 2015-06-03 23:57:26
I'm currently co-oping a space game with a friend of mine. This game will have the random spawning of planets in the galaxy. It would look rather weird in a top down world to have planets on top of eachother, so I tried to write this bit of code to make it so planets would stay atleast 32 pixels away from another planet. However, planets realize that they are inside of other planets, but never change their position. At least, from a bit of debugging thats what I've concluded. (I very well could be inaccurate.) The code below is the exact code in the game. Could you review it? I feel like fresh eyes could help me solve the problem as I can't seem to figure it out. Or maybe I'm going about this wrong. Here is my diagram of how the code below is supposed to look through each planet.

  • Generates a random set of coords
  • Checks those coords to see if they fall inside another planet
    • If so, regenerate coords and re-loop through all the planets
    • Repeat infinitely until a non-offending pair of coords are found
  • Generate a planet with the non-offending set of coords

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
      int x;
      int y;
      for(int i = 0; i < numberOfPlanets; i++) {
         x = new Random().nextInt(640-32);
         y = new Random().nextInt(480-32);
         for(int ii = 0; ii < planets.size(); ii++) {
            temp = planets.get(ii);
            if((((x >= temp.x) && (x <= temp.x + temp.getWidth()+32) && ((y >= temp.y) && (y <= temp.y + temp.getHeight()))))) {
               x = new Random().nextInt(640-32);
               y = new Random().nextInt(480-32);
               ii=0;
               System.out.println(x + ", " + y + " || " + temp.getX() + ", " + temp.getY());
            }
         }
         addPlanet(new TestPlanet(x, y, Game.NONE));
      }
9  Discussions / General Discussions / Re: How many projects do you go through? on: 2015-05-28 20:59:40
Depends on the project really. Sometimes I get de-motivated because I want to achieve something but I believe it's beyond my skill; which is when I give up. I've had projects that lasted a week or so and 1 project that lasted half a day before I got bored of it.

If I can find something I really want to do then I usually stick to it. My current game beyond anything that I've done before and though I've had to take some shortcuts here and there, i'm hoping that on my next project I can fix those shortcuts Pointing

I'm with you Sauron, I think something is beyond my skill. Then I try to study up on learning it. And realize that learning it is beyond my skill. So I go back to making pong clones. Tongue
10  Discussions / Miscellaneous Topics / Re: What is your opinion about ... on: 2015-05-28 14:23:51
I don't use debuggers, I'm perfect.  Wink

     *Sweeps NullPointerException under the rug*
11  Discussions / General Discussions / Re: Rayvolution's JGO Appreciation Thread (AKA: Free copies of Retro-Pixel Castles!) on: 2015-05-27 18:42:16
Hey Ray!

Congrats on RPC doing well. I'd love a key! Thanks man.
12  Java Game APIs & Engines / Java 2D / Re: [2D] First Game on: 2015-05-21 00:36:46
Nice Job Man! Grin

For a first project this is awesome. U put a lot of time into that GUI. I'd love to see you put your own art style into it. Keep up the hard work!
13  Game Development / Newbie & Debugging Questions / Re: LibGDX Draw item in players hand (2D top down view) on: 2015-05-21 00:33:04
The easy/cheating way to do this would be to draw the character in gimp, and on a separate layer draw the weapon in his hand. Then save the character as an image and the weapon layer as a separate image as well.

Each image should be the same size so the centers of both images would be the exact same.
Then all you gotta do in your code is draw the weapon, and then the character onto that.
Then just rotate both sprites the same, as if they were one image in the code.

And bam, Bob's your uncle.
14  Discussions / General Discussions / why doesn't anyone use PlayN? on: 2014-12-28 17:29:06
I was browsing the Web when I found a pretty neat library built on lwjgl. It's called PlayN. It exports to HTML Desktop Android and iOS and all that stuff.  But no one uses it. Why not?
15  Game Development / Newbie & Debugging Questions / Re: Slick2d - how many game states do you create ? on: 2014-12-26 17:05:10
The amount of states relies completely on your project and what it calls for. Normally I start a project by making a Menu State and a Game State and when I Pause and Resume I just make it a boolean and put it in the render method like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
boolean isPaused = true;

public void render(Graphics g) {
     if(isPaused) {
          // Draw paused Stuff
     }else{
          // Draw Game
     }
}

public void update() {
     if(isPaused) {
          // Update paused Stuff
     }else{
          // Update Game
     }
}
16  Games Center / Contests / Re: TAFSJ - The Actually Finish Something Jam on: 2014-12-24 01:50:11
I haven't even started, I make the prototype, run into a wall, stop and restart...
17  Games Center / Contests / Re: TAFSJ - The Actually Finish Something Jam on: 2014-12-23 22:15:08
So will winners and losers be chosen?
18  Discussions / General Discussions / Re: Bring back 1HGJ? on: 2014-12-23 19:23:01
Votes are tied. 5 votes yes, 5 votes no!
19  Discussions / General Discussions / Re: Bring back 1HGJ? on: 2014-12-23 18:45:58
There isn't a lot you can really learn in one hour of hacking stuff up.
At that point you're just programming old concepts from memory.

- Jev

Well I'll give you that, but you competed once. Don't act like it wasn't fun. You are right about learning to an extent, but It does teach you a lot of time saving techniques.

EDIT: Currently (YES) is winning.
20  Discussions / General Discussions / Re: Bring back 1HGJ? on: 2014-12-23 18:42:22
Doesn't the world have enough game jams? They're great to get people interested and as a once-in-a-while thing, but I feel like a lot of people focus too much on throwaway games and not enough on "real" projects.

Very well said my friend. But it is a great learning experience.
21  Discussions / General Discussions / Bring back 1HGJ? on: 2014-12-23 18:39:56
Does anyone remember the 1 Hour Game Jam? Recently I've been thinking about it and I kinda want to start it up again, but whats the point of a game jam If no one else wants to compete right? So I created a straw poll! Voting ends in 5 hours! Timer starts now:

Vote

If you haven't ever heard of the 1HGJ, It's a game jam where pretty much your only goal is to finish a game in 1 hour! The rules will be explained more if the jam is voted back into existence. Happy voting guys!
22  Java Game APIs & Engines / Java 2D / Re: Firing bullet from gun's current position to mouse x & y position on: 2014-12-23 17:37:45
This should actually be in the Newbie & Debugging board. Now what VIrtueeL works great but if you know anything of vector math, you can get the job done a lot easier like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
public class Bullet {

     Vector2d pos;
     Vector2d dir;

     public Bullet(int x, int y) {
          pos = new Vector2d(x, y);
          dir = new Vector2d(new Vector2d(mousex, mousey).sub(pos).normalise());
     }

     public void render() {
          // Render bullet at pos.x and pos.y
     }

     public void update() {
          pos.add(dir); // Moves position to direction aka mouse. To have the bullet follow the mouse like a homing missle you would have to constantly keep updating the dir vector
     }

}


That should do it. By the way, I used to use Java2D. I actually made a complete game out of it, however, I wouldn't recommend it in the long term. It's just not made for games IMO. I'm sure your mind set is if I use a library I'm cheating, right? Well I'm here to tell you, all of us on this forum use libraries. It's not cheating, It's just being efficient. So I recommend you go and check out these 2 great libraries:

Slick2D: (This is where I went to after leaving J2D and still use it now)
Download
Beginner Tutorials

LibGDX: (Cross-platform support and apparently super easy (I find it confusing but I'm an idiot so Roll Eyes ))
Download
Beginner Tutorials

Good luck! Choose wisely! Wink
23  Games Center / Contests / Re: TAFSJ - The Actually Finish Something Jam on: 2014-12-23 17:02:09
All night I layed awake thinking up a storm and early this morning I think I may have it. You will be hearing from me shortly. Muhuhahaha (Imagine that in a deep voice, not like, you know, a 14 year old's voice)  persecutioncomplex
24  Games Center / Contests / Re: TAFSJ - The Actually Finish Something Jam on: 2014-12-23 04:42:00
Sweet! Im in! I'll do top down but probably not a shooter.
25  Game Development / Newbie & Debugging Questions / Re: Slick2D Image.getColor crash on: 2014-12-22 20:23:15
A quick google revealed this:

1  
2  
BufferedImage image = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
ImageIO.write(image, "png", new File("/screenshot.png"));


https://stackoverflow.com/questions/4490454/how-to-take-a-screenshot-in-java
26  Game Development / Game Play & Game Design / Re: Old 3d graphics on: 2014-12-22 20:00:05
Got back to programming and started looking what kind of style I'm going with this project.

Probably going this way Smiley

Whoa, what game is that? That is beautiful.
27  Discussions / General Discussions / How do you feel about selling out? on: 2014-12-22 05:13:10
So recently I heard that Notch sold Minecraft and he is getting a lot of hate for it. I was wondering why its such a bad thing to sell you game.

I feel like I would never sell my game to anyone, it's my baby, it's my identity. But for 2.5 billion dollars I think we could make a deal.

So would you guys sell out and if so, for how much?
28  Games Center / Featured Games / Re: Minecraft on: 2014-12-22 03:46:05
It's not that it's shameful, it's just that it's common forum etiquette to not bring back very old threads just to add nothing to the conversation beyond "Hey this is neat."

Well, putting it in that context, then it does seem a bit wrong.
29  Games Center / Featured Games / Re: Minecraft on: 2014-12-22 03:41:47
I don't see why it's such a shameful thing to bring this thread back. It's not like JGO should be ashamed of a thread of this magnitude. I mean come one, this is where Minecraft began. I don't see how if someone posts in it and this thread becomes alive again would mean anything bad.

EDIT: If you don't like the content in this thread don't read it, honestly.
30  Game Development / Networking & Multiplayer / Re: Books on Multiplayer Games? on: 2014-12-22 01:47:03
That doesn't exactly answer my question, honestly. I was looking more so for a specific book recommendation as I am already using Kryonet and know how to make a basic game. I'm trying to more-so find a way to host multiple player sessions on a single server. (Matches) Which in theory is simple, make a match class and have it have 2 players in it. Iterate through matches on server, update them. But what I have trouble with is distinguishing between clients on the server. Knowing which client to send the correct game data to. So that's why I wanted to read a book. Learn a bit more about how a game server should be set up.
Pages: [1] 2 3 ... 20
 
bilznatch (24 views)
2015-08-04 11:03:17

SHC (40 views)
2015-08-01 03:58:20

Jesse (24 views)
2015-07-29 04:35:27

Riven (47 views)
2015-07-27 16:38:00

Riven (25 views)
2015-07-27 15:35:20

Riven (27 views)
2015-07-27 12:26:13

Riven (18 views)
2015-07-27 12:23:39

BurntPizza (41 views)
2015-07-25 00:14:37

BurntPizza (55 views)
2015-07-24 22:06:39

BurntPizza (34 views)
2015-07-24 06:06:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21
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!