Java-Gaming.org Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (574)
Games in Android Showcase (154)
games submitted by our members
Games in WIP (620)
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
1  Game Development / Newbie & Debugging Questions / Re: Changing animation of an AI on: 2015-04-19 23:11:38
It really is all a matter of if statements. However, if the sprite is moving diagonally (e.g.: up and left), you need to choose if it should show the up animation or the left animation.

I'm also assuming you don't want it to show the animation if the entity isn't moving, so you would need another if statement to check if the entity is even moving.

Example code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
if(vel.x != 0){
    if(vel.x < 0){
        // sprite is moving left
        setAnim(leftAnim);
    }else{
        // sprite is moving right
        setAnim(rightAnim);
    }
}

// the y-check statements are placed after the x-check so moving up/down has "priority" over left/right
// if you want it the other way around, place the y-checks before the x-checks
if(vel.y != 0){
    if(vel.y < 0){
        // sprite is moving up
        setAnim(leftAnim);
    }else{
        // down
        setAnim(rightAnim);
    }
}
2  Game Development / Networking & Multiplayer / Re: [solved] kryonet works on localhost, but not on different computers on: 2015-04-19 21:22:52
I solved it by updating kryonet to its newest build (2.22.0-RC1) which wasn't on the kryonet maven, but on the com.esotericsoftware repo. That was definitely a strange solution, but a solution nonetheless.

Thanks for all the help!
3  Game Development / Networking & Multiplayer / Re: Kryonet - client/server works on localhost, but not on different computers on: 2015-04-19 20:44:33
Removing
1  
main.client.start()
before attempting to connect also returns this same error every time. I'll keep looking into it.
4  Game Development / Networking & Multiplayer / Re: Kryonet - client/server works on localhost, but not on different computers on: 2015-04-19 19:14:28
I just remembered something. If I'm correct, for some modems (including mine), you cannot connect using public IP. Only computers outside the network are able to connect using public IP.

I'm using the computer's internal IP address (192.168.1.X). I can connect using the internal IP address to my own computer (running the server) but not to other computers.
5  Game Development / Networking & Multiplayer / Re: Kryonet - client/server works on localhost, but not on different computers on: 2015-04-19 17:52:12
I should've mentioned that the other computer I'm testing it on is also on my network. The ports were forwarded already.
6  Game Development / Networking & Multiplayer / [solved] kryonet works on localhost, but not on different computers on: 2015-04-19 17:10:51
I'm developing a small multiplayer game that uses kryonet. So far, it works great on the same machine (localhost), but when I tested it on another computer, the client did connect but failed to finish connecting, if that makes any sense. Poking around in the source code of kryonet shows that the client did not do anything about the TCP registration packet sent by the server, even though the client's thread has been started.

Error:
1  
2  
3  
4  
5  
java.net.SocketTimeoutException: Connected, but timed out during TCP registration.
Note: Client#update must be called in a separate thread during connect.
   at com.esotericsoftware.kryonet.Client.connect(Client.java:161)
   at com.esotericsoftware.kryonet.Client.connect(Client.java:110)
   at projectmp.client.ConnectingScreen$1.run(ConnectingScreen.java:28)


The connecting 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  
public void connectTo(final String host, final int port){
      setMessage("Closing client (if still connected)");
      main.client.stop();
      setMessage("Attempting to connect to " + host + ":" + port);
      main.client.start();
     
      Thread connector = new Thread(){
         
         @Override
         public void run(){
            try {
               main.client.connect(5000, host, port, port);
               Main.logger.info("Successfully connected to " + host + ":" + port);
               setMessage("Connected to server; sending handshake");
               
               PacketHandshake handshake = new PacketHandshake();
               handshake.username = Main.username + "";
               handshake.version = Main.version + "";
               main.client.sendTCP(handshake);
            } catch (Exception e) {
               e.printStackTrace();
               setMessage("");
               Main.ERRORMSG.setMessage("Failed to connect:\n" + e.toString());
               main.setScreen(Main.ERRORMSG);
            }
         }
         
      };
      connector.setDaemon(true);
      connector.start();
   }


The (kryonet) client IS being started before I attempt a connection. connectTo gets called when you click the connect button (on the GL thread).

Any help is appreciated! Thanks!
7  Game Development / Newbie & Debugging Questions / Re: Looking for Source Code Ressources on: 2015-04-18 22:34:41
The game I'm currently working on is open-source. Go ahead and poke around! https://github.com/chrislo27/ProjectMP

The game I last worked on is also open-source but I'm not really maintaining it anymore. https://github.com/chrislo27/Stray-core

Both games use libGDX.
8  Game Development / Newbie & Debugging Questions / Re: libgdx position of a body in relation of it´s plattform? on: 2015-04-18 19:26:03
Your question is vague. Do you want the enemy to move on the platform or do you want the platform to move with the enemy on it?
9  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Animation + Delta Time? on: 2015-04-15 02:42:11
For clarity, immutability isn't why you can't use == on Strings for equality. It's because string (and most datatypes) equivalence is not object identity (pointer equivalence).

Oops, I was thinking of something else. I have no idea where I got immutability (I was reading something on primitives earlier, maybe that bled in). Thanks for correcting me!
10  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Animation + Delta Time? on: 2015-04-15 00:11:49
I didn't pick this up earlier but you CANNOT compare strings with ==. They are immutable objects, and must be compared with <someStringObject>.equals(<anotherString>). You'll also want to rid the "else" from the first if statement to check the idle stances. If you're using Eclipse you can press Control+Shift+F to reformat all the code to look better and become more readable (this also annoyingly formats comments -- you can change this in the preferences if you'd like). Using a string for left and right stances is pretty slow when you're comparing the strings to determine what idle stance you want. You should use an Enum, integer, or even a boolean.

Modified update method:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
public void update(){
      if(Gdx.input.isKeyPressed(Keys.A)){
         CurrentAnimation = WalkLeftAnimation;
         directionString = "Left";
         
      }
      if(Gdx.input.isKeyPressed(Keys.D)){
          CurrentAnimation = WalkRightAnimation;
          directionString = "Right";
      }

       if(directionString == "Left"){
          CurrentAnimation = IdleLeftAnimation;
       }
       else if(directionString == "Right"){
          CurrentAnimation = IdleRightAnimation;
       }
     
   }
11  Game Development / Newbie & Debugging Questions / Re: [solved] [libgdx] Resize game window and/or enable/disable fullscreen on-the-fly on: 2015-04-14 03:10:07
Wow, sometimes I wonder how I miss things in the documentation...

Thank you so much!
12  Game Development / Newbie & Debugging Questions / [solved] [libgdx] Resize game window and/or enable/disable fullscreen on-the-fly on: 2015-04-14 02:57:30
Is there anyway to directly change the game resolution and/or toggle fullscreen on-the-fly? I'm using libgdx, and I'm assuming I can only do the mentioned things in the desktop source. I don't want to set the fullscreen and resolution when the game starts; I want to set it mid-game (e.g. settings menu and hitting the apply button).

This isn't exactly a problem, it's just been in the back of my head for some time and the documentation doesn't appear to say anything (that or I completely missed it).

Thanks!
13  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Animation + Delta Time? on: 2015-04-14 00:24:09
getDeltaTime returns a float (the number of seconds between frames, a very small number generally). Ints truncate it back to zero. Change frameDelta to a float.

EDIT: ints don't always truncate a float/double to zero. They will return it to the whole number. They do not round (2.9 float becomes 2 truncated to int).
14  Discussions / General Discussions / Re: Legality of Retro-Engineered clients on: 2015-04-13 14:47:12
Although I'm guessing a simple packet sniffer could probably make out most of the network communications from the game itself. Hmmmm, that's an idea there, I'll see if I can wireshark this out later at home.

There's also a website here called the Minecraft Coalition. It has an excellent overview of how Minecraft handles packets and what they send, etc.
15  Game Development / Newbie & Debugging Questions / Re: [Solved] Setting a boolean once in a infinite loop? on: 2015-04-13 03:06:36
I know it's solved already, but another option is to use Gdx.input.isKeyJustPressed(Keys.ESCAPE). It's meant for polling, but it's not preferred over an event listener.
16  Game Development / Newbie & Debugging Questions / Re: Making a Graph on a Cell of a Libgdx Table on: 2015-04-12 03:48:40
Your images aren't working (at least for me). You'll definitely have to fix them because the wording for this type of problem can make it quite ambiguous.
17  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-04-11 18:20:02
More work on the lighting engine:
18  Game Development / Newbie & Debugging Questions / Re: [LibGDX] Creating menu. Button madness? on: 2015-04-10 14:40:12
Yes, that is correct. An more common example is with threads, when you don't want to bother making an entire class and set up methods... you know what I mean.
1  
2  
3  
4  
5  
6  
7  
Thread t = new Thread(){

   @Override
   public void run(){
      // do the things
   }
}.start();


This also works with abstract classes and interfaces. You can instantiate an abstract class or interface as long as you implement the required methods in the constructor body.
1  
2  
3  
4  
5  
6  
7  
Runnable r = new Runnable(){

   @Override
   public void run(){
      // do the things
   }
}
19  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-04-10 14:25:37
I really like how the sprite moves in sub-pixels when the sprite is more pixelly. I really love that style of animation!
20  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-04-10 03:09:15
It helped a little bit, although the way I update lights (recursion, bleh) gives it a pattern where it "cuts in". Right now I'm more concerned over performance than correct light colours, but thanks for helping!
21  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-04-10 02:45:01
I realized that I wanted to finish only one part of Astrofirm: the lighting  Cranky. So I totally recreated the lighting system and improved upon upon it a bit.
First I made it in much less code and, I made lights able to change their intensity (yup couldn't do that on the old system). So in the end, not much has changed in the look, but I'm going to keep tweaking it until it.

Wow, that lighting looks really good (waaaay better than mine, haha). May I ask about how you mixed colours? I'm using libgdx and I had to use the lerp function to vaguely get the results I wanted. I tried the add function but it became white.
22  Discussions / Business and Project Management Discussions / Re: [PAID] Looking for Java consultant on: 2015-04-10 02:42:37
Your issues (concurrency and embedded JRE) seem simple enough to not have to pay people for assistance. Who doesn't NOT want to spend money?  Tongue

Like Rayvolution said, I highly suggest you ask around on the forums or even here.
23  Games Center / Showcase / Re: [LWJGL] Macy Mae's Eating Adventure (yet another Pac-Man clone) on: 2015-04-07 03:57:05
Maybe your blending can be fixed with
1  
2  
3  
4  
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// do rendering for sprites
glDisable(GL_BLEND);


I'm not great with barebones GL (I used to use slick and currently am using libgdx) but the blending function makes it so when you render more pixels on top of existing ones, it appears overlaid and not overwritten.

Good luck!
24  Games Center / Showcase / Re: [LWJGL] Macy Mae's Eating Adventure (yet another Pac-Man clone) on: 2015-04-07 03:24:19
Loaded the game, everything seemed fit for one certain resolution (that I can't change). It was like this the entire game.


After one death I couldn't move at all. I had to get a game over for it to reset the controls.

Sprites had this weird overlap (shown in picture below). I don't think this is intended I think you wanted the sprites to blend without overriding each other.


Overall, it needs some small polishing and a bugfix for that control glitch. I like the way the character moves, how he/she "slides" until he/she hits a wall. The AI for the "ghosts" feels pretty similar to Pac-Man and I really like that.

For a first completed game, this is good! Keep working on it and you'll go far  Wink
25  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-04-06 04:18:23
Terraria-like coloured lighting engine! I was not a happy man when I found out bytes were signed... Wasted a few hours of my time there.

26  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-04-05 16:53:00
OpenSimplex noise terrain and cave generation for a multiplayer game I have in progress!

27  Game Development / Newbie & Debugging Questions / Re: OpenSimplex Noise producing extremely noisy results on: 2015-04-03 20:56:37
Holy crap that was so much better!

(0.25 freq.)

Thank you!  Grin
28  Game Development / Newbie & Debugging Questions / [solved] OpenSimplex Noise producing extremely noisy results on: 2015-04-03 18:30:05
I recently came across OpenSimplex noise which looked like exactly what I wanted for some small procedurally generated game I'm making. However when I wrote the noise to a file (128x128 - the size of the world for now), it looked really... noisy, which reflected back into the terrain generation.

The colour is calculated as ((noise + 1) / 2) (I'm assuming the noise is in a range from -1 to 1). I am using the 2D method for noise.

The simplex noise implementation I'm using: https://gist.github.com/KdotJPG/b1270127455a94ac5d19
29  Games Center / WIP games, tools & toy projects / Re: Seeders - puzzle platformer [demo available] on: 2015-04-02 22:20:51
Dude, just define something like this:
1  
#define __MY_AWESOME_FLOAT_OF_VALUE_ONE 1.0

Then you can just use it like this
1  
float f =__MY_AWESOME_FLOAT_OF_VALUE_ONE;

And you won't have to type .0!!!  Grin


I think he means you can put "f" at the end of a number to make it a float (instead of an int, for example).
30  Game Development / Networking & Multiplayer / Re: KryoNet weird bug on: 2015-03-31 14:57:20
Some more code would be helpful, for example, what is the type of projectiles, what even is a RemoveProjectile? Kryonet has its own threads for sending packets, so maybe your synchronized block is affecting it? I would suggest to find a better way to store your projectiles (ArrayList, etc.) because Iterators aren't thread-safe (they need synchronized methods/blocks).

This question is kind of vague without more code, so I can't really answer it very well right now.
Pages: [1] 2 3
 
Riven (27 views)
2015-04-16 10:48:47

Duke0200 (42 views)
2015-04-16 01:59:01

Fairy Tailz (32 views)
2015-04-14 20:13:12

Riven (33 views)
2015-04-12 21:36:37

bus hotdog (49 views)
2015-04-10 02:39:32

CopyableCougar4 (51 views)
2015-04-10 00:51:04

BurntPizza (51 views)
2015-04-06 22:06:58

ags1 (53 views)
2015-04-02 10:58:48

Riven (52 views)
2015-04-01 18:27:05

ags1 (69 views)
2015-03-31 10:55:12
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

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27
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!