Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (589)
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
1  Java Game APIs & Engines / Engines, Libraries and Tools / [libGDX] - Chat Bubble Recommendations? on: 2014-03-06 04:12:18
I am planning to implement chat bubbles above the heads of my actors. I could start hacking away and come up with a solution but wanted to gather some thoughts from others who may have implemented something similar with libGDX and get some recommendations on the best approach.

#1 - Use a custom draw method that autosizes itself and appears on screen using offsets from the player character and/or npc who is speaking. This would be easy to hack together, but could be challenging coming up with custom text wrapping and would take extra work to make the bubble actually look good.

#2 - Use a label widget from scene2d. I could add a label to the scene table that remains above the player's head but is invisible until text is ready to be shown. A timer could easily hide the box again after a few seconds. This seems reasonable for the player character but may not work for other non player characters on the screen. If you had one other NPC on screen who is speaking you could find his location and set the position of the label prior to unhiding it. However, what if you had 10 NPCs on screen who are talking? You would need 10 hidden labels just sitting around and whenever text needs to be shown iterate over the list of labels, grab the first unused label, set its position and text, then hide and release it when finished.

#3 - Similar to approach #2 but dynamically create and destroy a label for every message. This seems to make the most sense in theory but I'm not sure if creating and destroying labels frequently is an intended use of scene2d widgets.

Regardless of the approach another consideration would be the ability to move the chat bubble as an actor moves (like chat bubbles did in Ultima Online). With this in mind it seems like I should create a new label widget within the scope of my actor class where I can retain both the position of the actor and where the label should be at any given time.

From the scene2d wiki:
"Widgets can be used as simple actors in scene2d, without using tables or the rest of scene2d.ui. Widgets have a default size and can be positioned absolutely, the same as any actor."


Thoughts or recommendations? Smiley
2  Games Center / Archived Projects / Re: Ruins of Revenge on: 2013-06-18 16:01:12
I was curious to see if I could get this working. I deleted the project and downloaded the latest from github and it worked! I'm not sure what has changed since the last build (if anything) but for some reason it seems good now. I was able to start the server and connect multiple clients and see them update on both sides.

A couple things I noticed (which I'm sure you already know about)
1) Once you hit enter and type in a chat message, you lose the ability to regain focus and move your character around again
2) The entered chat message doesn't seem to go anywhere
3) Entering a chat message causes your character to disappear to the other connected client
4) Entering a chat message causes the other connected client to no longer be able to move

I really appreciate the overall direction of this project, including the way you have your code organized. Now that I have a build running I'll also see what I can do to contribute.
3  Games Center / Archived Projects / Re: Ruins of Revenge on: 2013-05-01 04:58:51
In ClientConnector.java

public ClientConnector(ClientMaster master, String host) throws IOException {
      this.master = master;
      this.client = new Client();
      this.queue = new LinkedBlockingQueue<>();
      this.newestInput = new Input();

      Register.registerAll(client.getKryo());
      client.start();
      client.connect(5000, InetAddress.getByName(host), ServerMaster.PORT);
      client.addListener(new QueuedListener(this) {
         @Override
         protected void queue(Runnable runnable) {            
            queue.add(runnable);
         }
      });
      
   
      
   }

I confirmed that queue.add(runnable) keeps getting called over and over. I assume on a normal connect this should just get called a single time. I added "System.out.println(queue.peek());" just before queue.add to see what was happening and got a dump like:

com.esotericsoftware.kryonet.Listener$QueuedListener$4@37b2cb94
null
com.esotericsoftware.kryonet.Listener$QueuedListener$4@5781ab44
com.esotericsoftware.kryonet.Listener$QueuedListener$4@5781ab44
com.esotericsoftware.kryonet.Listener$QueuedListener$4@5781ab44
com.esotericsoftware.kryonet.Listener$QueuedListener$4@5781ab44
com.esotericsoftware.kryonet.Listener$QueuedListener$4@5781ab44
com.esotericsoftware.kryonet.Listener$QueuedListener$4@5781ab44
com.esotericsoftware.kryonet.Listener$QueuedListener$4@5781ab44
com.esotericsoftware.kryonet.Listener$QueuedListener$4@5781ab44
com.esotericsoftware.kryonet.Listener$QueuedListener$4@5781ab44
null
com.esotericsoftware.kryonet.Listener$QueuedListener$3@38882d9a
null
com.esotericsoftware.kryonet.Listener$QueuedListener$3@644a5ddd
null

This seems to indicate that not only is the list getting added to multiple times (from a single connection attempt) but that occasionally the list is emptied and results in those null lines. In other words a listener is added, something happens and it gets removed from the list, next time through we see a null line, and then the next time a new listener is created. It seems to go on like this indefinitely.

Hopefully I'm on the right track now. I am curious if anyone else running this demo were to insert this line if they would see the same output.


Thanks for taking the time to update github with the correct .classpath for eclipse. Unfortunately, I'm still having trouble getting the connect to work. I'm determined to resolve the problem at this point so I'll post details in the event it helps others.

1) I can compile and connect the kryonet examples on my local pc (and use the same ports as used for ror).
2) I can compile and run the ror server and ror client with no issue. After clicking connect the map loads and I actually see the character entity created (but he is unable to move). Enter, F8 and esc keys are accepted as those see to be client side only.
3) From what I can tell ClientConnector.java has a few overriden methods and I see that the received method gets called but the connected method is never reached. I know this because you have a print statement that would get output to the console if it was reached. I don't know kryonet very well but I would have thought that connected should execute before received?
4) I looked into one possible solution on the kryonet discussion group but it didn't seem to work --> https://groups.google.com/forum/?fromgroups=#!topic/kryonet-users/QTHiVmqljgE

I've been trying to insert some various sleeps on threads to help pinpoint the problem but no luck. My prior post regarding a TCP registration error seems to no longer be a problem (it was a side effect of debugging code I had in place). I'm currently trying to break down the timing of the connect and update thread to see if somehow data is being sent before the connection is established.


4  Games Center / Archived Projects / Re: Ruins of Revenge on: 2013-04-30 23:51:48
Thanks for taking the time to update github with the correct .classpath for eclipse. Unfortunately, I'm still having trouble getting the connect to work. I'm determined to resolve the problem at this point so I'll post details in the event it helps others.

1) I can compile and connect the kryonet examples on my local pc (and use the same ports as used for ror).
2) I can compile and run the ror server and ror client with no issue. After clicking connect the map loads and I actually see the character entity created (but he is unable to move). Enter, F8 and esc keys are accepted as those see to be client side only.
3) From what I can tell ClientConnector.java has a few overriden methods and I see that the received method gets called but the connected method is never reached. I know this because you have a print statement that would get output to the console if it was reached. I don't know kryonet very well but I would have thought that connected should execute before received?
4) I looked into one possible solution on the kryonet discussion group but it didn't seem to work --> https://groups.google.com/forum/?fromgroups=#!topic/kryonet-users/QTHiVmqljgE

I've been trying to insert some various sleeps on threads to help pinpoint the problem but no luck. My prior post regarding a TCP registration error seems to no longer be a problem (it was a side effect of debugging code I had in place). I'm currently trying to break down the timing of the connect and update thread to see if somehow data is being sent before the connection is established.

5  Games Center / Archived Projects / Re: Ruins of Revenge on: 2013-04-27 14:45:16
Hey matheus23,

Any chance you could try reuploading to github? If you look at the .classpath file you'll see that it's pointing to .jars in a path where they don't exist. I'm wondering if the .classpath is out of sync then maybe there is something else out of sync in github vs. your local pc. Just a random thought since I'm out of ideas Smiley
6  Games Center / Archived Projects / Re: Ruins of Revenge on: 2013-04-26 21:59:00
Bummer, still stuck. I've been reading the Kryonet discussion group and some other users indicated having issues on the latest kryonet build. I've tried 3 or 4 different versions though and none seem to change anything.

If anyone else pulls down and connects successfully let me know Smiley. Inserting breakpoints into this project hasn't seemed to help me debug. Next step would be to insert breakpoints into kryonet code and recompile it from source, but not sure I have the energy to tackle that Smiley.
7  Games Center / Archived Projects / Re: Ruins of Revenge on: 2013-04-25 20:36:00
Not trying to be spammy, just posting debugging progression here in case other users hit a similar issue. I have the stack trace printing to the console during the client connect. Note the bolded lines below. I'll do some more digging any hopefully find the root issue.

Reading config.
00:00 TRACE: [kryo] Register class ID 14: org.matheusdev.ror.net.packages.CreateEntity (com.esotericsoftware.kryo.serializers.FieldSerializer)
00:00 TRACE: [kryo] Register class ID 15: org.matheusdev.ror.net.packages.EntityState (com.esotericsoftware.kryo.serializers.FieldSerializer)
00:00 TRACE: [kryo] Register class ID 16: org.matheusdev.ror.net.packages.NetPackage (com.esotericsoftware.kryo.serializers.FieldSerializer)
00:00 TRACE: [kryo] Register class ID 17: org.matheusdev.ror.net.packages.Input (com.esotericsoftware.kryo.serializers.FieldSerializer)
00:00 TRACE: [kryo] Register class ID 18: org.matheusdev.ror.net.packages.FetchEntities (com.esotericsoftware.kryo.serializers.FieldSerializer)
00:00 TRACE: [kryo] Register class ID 19: org.matheusdev.ror.net.packages.CreateEntity[] (com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer)
00:00 TRACE: [kryo] Register class ID 20: org.matheusdev.ror.net.packages.DeleteEntity (com.esotericsoftware.kryo.serializers.FieldSerializer)
00:00 TRACE: [kryonet] Client thread started.
00:00  INFO: Connecting: localhost/127.0.0.1:5455
00:00 DEBUG: [kryonet] Port 9124/TCP connected to: localhost/127.0.0.1:5455
00:00 TRACE: [kryo] Read class 9: com.esotericsoftware.kryonet.FrameworkMessage$RegisterTCP
00:00 TRACE: [kryo] Read field: connectionID (com.esotericsoftware.kryonet.FrameworkMessage$RegisterTCP)
00:00 TRACE: [kryo] Read: 6
00:00 DEBUG: [kryo] Read: com.esotericsoftware.kryonet.FrameworkMessage$RegisterTCP
00:00 TRACE: [kryo] Object graph complete.
00:00 TRACE: [kryonet] Connection 6 received TCP: RegisterTCP
00:00  INFO: [kryonet] Connection 6 connected: localhost/127.0.0.1
00:00  INFO: [kryonet] Connection 6 disconnected.
00:00  INFO: Connecting: localhost/127.0.0.1:5455
00:00 DEBUG: [kryonet] Port 9127/TCP connected to: localhost/127.0.0.1:5455
00:00 TRACE: [kryonet] Unable to update connection.
java.net.SocketException: Connection is closed.
   at com.esotericsoftware.kryonet.TcpConnection.readObject(TcpConnection.java:100)
   at com.esotericsoftware.kryonet.Client.update(Client.java:239)
   at com.esotericsoftware.kryonet.Client.run(Client.java:317)
   at java.lang.Thread.run(Unknown Source)
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:159)
   at com.esotericsoftware.kryonet.Client.connect(Client.java:114)
   at org.matheusdev.ror.client.ClientConnector.<init>(ClientConnector.java:63)
   at org.matheusdev.ror.client.ClientMaster.createConnection(ClientMaster.java:131)
   at org.matheusdev.ror.client.ClientMaster.<init>(ClientMaster.java:80)
   at org.matheusdev.ror.screens.ScreenConnect.tryConnect(ScreenConnect.java:92)
   at org.matheusdev.ror.screens.ScreenConnect.access$0(ScreenConnect.java:89)
   at org.matheusdev.ror.screens.ScreenConnect$3.touchUp(ScreenConnect.java:70)
   at com.badlogic.gdx.scenes.scene2d.InputListener.handle(InputListener.java:58)
   at com.badlogic.gdx.scenes.scene2d.Stage.touchUp(Stage.java:317)
   at org.matheusdev.ror.screens.AbstractScreen.touchUp(AbstractScreen.java:85)
   at org.matheusdev.ror.RuinsOfRevenge.touchUp(RuinsOfRevenge.java:168)
   at com.badlogic.gdx.backends.lwjgl.LwjglInput.processEvents(LwjglInput.java:297)
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:186)
   at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:110)
Saving up = W
Saving down = S
Saving left = A
Saving right = D
Saving debugDraw = F8
Saving escape = ESCAPE
Saving chat = ENTER
Config written.
AL lib: alc_cleanup: 1 device not closed
8  Games Center / Archived Projects / Re: Ruins of Revenge on: 2013-04-25 19:37:02
Compiled using Intellij IDEA just to compare and hit the same problem.

Someone posted an issue for Kryonet in Feb. regarding a connection and immediate disconnection issue but there is no further discussion --> https://code.google.com/p/kryonet/issues/detail?id=32

I'm using Win 7 64 bit. I disabled the windows firewall. Here is the client side console output with tracing turned on:

Reading config.
00:00 TRACE: [kryo] Register class ID 14: org.matheusdev.ror.net.packages.CreateEntity (com.esotericsoftware.kryo.serializers.FieldSerializer)
00:00 TRACE: [kryo] Register class ID 15: org.matheusdev.ror.net.packages.EntityState (com.esotericsoftware.kryo.serializers.FieldSerializer)
00:00 TRACE: [kryo] Register class ID 16: org.matheusdev.ror.net.packages.NetPackage (com.esotericsoftware.kryo.serializers.FieldSerializer)
00:00 TRACE: [kryo] Register class ID 17: org.matheusdev.ror.net.packages.Input (com.esotericsoftware.kryo.serializers.FieldSerializer)
00:00 TRACE: [kryo] Register class ID 18: org.matheusdev.ror.net.packages.FetchEntities (com.esotericsoftware.kryo.serializers.FieldSerializer)
00:00 TRACE: [kryo] Register class ID 19: org.matheusdev.ror.net.packages.CreateEntity[] (com.esotericsoftware.kryo.serializers.DefaultArraySerializers$ObjectArraySerializer)
00:00 TRACE: [kryo] Register class ID 20: org.matheusdev.ror.net.packages.DeleteEntity (com.esotericsoftware.kryo.serializers.FieldSerializer)
00:00 TRACE: [kryonet] Client thread started.
00:00  INFO: Connecting: localhost/127.0.0.1:5455
00:00 DEBUG: [kryonet] Port 8510/TCP connected to: localhost/127.0.0.1:5455
00:00 TRACE: [kryo] Read class 9: com.esotericsoftware.kryonet.FrameworkMessage$RegisterTCP
00:00 TRACE: [kryo] Read field: connectionID (com.esotericsoftware.kryonet.FrameworkMessage$RegisterTCP)
00:00 TRACE: [kryo] Read int: 10
00:00 DEBUG: [kryo] Read: com.esotericsoftware.kryonet.FrameworkMessage$RegisterTCP
00:00 TRACE: [kryo] Object graph complete.
00:00 TRACE: [kryonet] Connection 10 received TCP: RegisterTCP
00:00  INFO: [kryonet] Connection 10 connected: localhost/127.0.0.1
00:00 TRACE: [kryonet] Connection listener added: org.matheusdev.ror.client.ClientConnector$1
00:00 TRACE: [kryonet] Client listener added.



On a side note regarding the gamepad. This is the console error I was getting:
Controllers: added manager for application, 1 managers active
Couldn't find controller for name "..."

It may be a non issue though, I just noticed it was red in the console due to the print statement used.
9  Games Center / Archived Projects / Re: Ruins of Revenge on: 2013-04-25 15:25:31
Still debugging ... I turned on trace level logging for kryonet on the client. It looks like it's attempting to connect over and over again but using a different port each time.

00:11  INFO: [kryonet] Connection 1 connected: /127.0.0.1
[SERVER]: Client /127.0.0.1:4708 connected.
ControllerPlayer initializing: [Entity]:
   type: player
   id: 1
   connection: 1   pos: [23.0:25.0]
   rot: 0.00000
   vel: [0.0:0.0]
   rot-vel: 0.00000
00:23  INFO: [kryonet] Connection 1 disconnected.
[SERVER]: Client null disconnected.
ControllerPlayer dying
00:29  INFO: [kryonet] Connection 2 connected: /127.0.0.1
[SERVER]: Client /127.0.0.1:4713 connected.
ControllerPlayer initializing: [Entity]:
   type: player
   id: 2
   connection: 2   pos: [23.0:25.0]
   rot: 0.00000
   vel: [0.0:0.0]
   rot-vel: 0.00000
00:41  INFO: [kryonet] Connection 2 disconnected.
[SERVER]: Client null disconnected.
ControllerPlayer dying
41:06  INFO: [kryonet] Connection 3 connected: /127.0.0.1
[SERVER]: Client /127.0.0.1:4782 connected.
ControllerPlayer initializing: [Entity]:
   type: player
   id: 3
   connection: 3   pos: [23.0:25.0]
   rot: 0.00000
   vel: [0.0:0.0]
   rot-vel: 0.00000
41:18  INFO: [kryonet] Connection 3 disconnected.
[SERVER]: Client null disconnected.
ControllerPlayer dying
10  Games Center / Archived Projects / Re: Ruins of Revenge on: 2013-04-25 15:14:50
I ruled out the gamepad as being the problem. I noticed that the server prints to the console that a connection was made. However, I don't see the corresponding client connection being printed.

Console Output:
[SERVER]: Client /127.0.0.1:5351 connected.
ControllerPlayer initializing: [Entity]:
   type: player
   id: 10
   connection: 10   pos: [23.0:25.0]
   rot: 0.00000
   vel: [0.0:0.0]
   rot-vel: 0.00000
103:22  INFO: [kryonet] Connection 10 disconnected.
[SERVER]: Client null disconnected.
ControllerPlayer dying



Per clientconnector.java I would have expected to see this get dumped at some point:

public void connected(Connection connection) {
      System.out.println("[CLIENT]: connected to " + connection.getRemoteAddressTCP());
   }
11  Games Center / Archived Projects / Re: Ruins of Revenge on: 2013-04-25 05:10:22
On to the next problem Smiley

I have the client connecting to the server successfully now. However, the connection is dropped after 5 seconds. Also it doesn't seem that any keyboard commands are being accepted except F8 and Esc.

I don't have a gamepad plugged in and am wondering if this is the problem. From what I can tell I'd say the connection is set to timeout quickly and no keyboard input is being sent to the server.
12  Games Center / Archived Projects / Re: Ruins of Revenge on: 2013-04-25 03:34:43
My problem was resolved simply by downloading the latest version of eclipse. The version I was on would not compile with 1.7 even though I had the 1.7 JDK installed.
13  Games Center / Archived Projects / Re: Ruins of Revenge on: 2013-04-24 20:51:00
Was trying to compile and hit some errors. The classpath was missing the tiled preprocessor jar so I simply downloaded and added it.

However, after fixing that I'm seeing errors in eclipse across the board around instantiation.

Example:

public class Master {

   private final ObjectMap<String, JsonObject> entityTypePool = new ObjectMap<>();
   private final String basePath;

Description   Resource   Path   Location   Type
Syntax error on token "<", ? expected after this token   Master.java   /RuinsOfRevenge/src/org/matheusdev/ror   line 39   Java Problem


Am I the only one getting these errors?
14  Java Game APIs & Engines / Java 2D / Re: Drawing Large Image: Out of Memory on: 2005-02-16 03:06:56
With a slight change in the calculation you provided I got the dragging working. Here is the code I'm using in its fully functioning entirety. Thanks for your help


public void mouseDragged(java.awt.event.MouseEvent e) {
     Point pt = e.getPoint();
     int dpx2 = pt.x;
     int dpy2 = pt.y;
                             
     changeX = dpx - dpx2;
     changeY = dpy - dpy2;
     System.out.println("chg: "+changeX+" "+changeY);
                             
     int scrollToX = getXScroll() + changeX;
     int scrollToY = getYScroll() + changeY;
                                               
     if (scrollToX>5000) scrollToX = 5000;
     if (scrollToY>3000) scrollToY = 3000;
     if (scrollToX<0) scrollToX=0;
     if (scrollToY<0) scrollToY=0;
                       
     dragPoint.setLocation(scrollToX,scrollToY);

     jLabel5.setText("px: "+scrollToX+", "+scrollToY);
     jScrollPane.getViewport().setViewPosition(dragPoint);
}

public void mousePressed(java.awt.event.MouseEvent e) {
     Point pt = e.getPoint();
     dpx = (int)pt.getX();
     dpy = (int)pt.getY();
     System.out.println("mousePressed("+dpx+":"+dpy+")"); // TODO Auto-generated stub mousePressed()
}
15  Java Game APIs & Engines / Java 2D / Re: Struct Problem on: 2005-02-16 02:03:30
I'd need someone to verify if this is correct or not but ...

You don't have to specify absolute paths in your code. If you used:

Image img = getToolkit().getImage("background.png");

that would look in the current directory for background.png. If you have something in a package you would use "mypackage/background.png" or maybe "mypackage.background.png" (im not certain on the syntax)
16  Java Game APIs & Engines / Java 2D / Re: Tilesets and Sprites on: 2005-02-14 20:58:54
What are all these websites that have isometric tiles? I've checked out molotov but haven't seen any other sources of iso tiles.

As for your top down background tiles you can do pretty well searching for tileable textures. There are a lot of free textures available out there (usually for 3d games) but they can be just as easily used for a 2d top down game.
17  Java Game APIs & Engines / Java 2D / Re: a different tile technique on: 2005-02-13 23:01:01
All you need is a map class that holds the information you want:

public class Map {
int sizeX; // map size
int sizeY; // map size

int[][] tileID; // tile id you use to lookup what tile to draw

string[][] description; // this is your tile description
int[][] food; // stores the food value
int[][] wood; // etc
int [][] iron; // etc

...

And maybe I'm misunderstanding what you're asking, but you shouldn't be trying to draw tiles using buttons or jpanels.  Assuming that youre using Java2d you should be loading Image objects through ImageIO. After you have some tiles loaded you could then draw them to your jpanel or jframe.

It sounds like you should start with getting a handle on how a tile based structure works. I'd recommend going to gamedev.net and checking under the articles/tile based graphics sections.
18  Java Game APIs & Engines / Java 2D / Re: Drawing Large Image: Out of Memory on: 2005-02-10 03:51:53
Looks like I'm going to need help on this dragging stuff. I almost have it working ... For some reason when I am holding the mouse down and start to drag back in the opposite direction it doesn't start shifting back that way immediately. Instead it won't start shifting back until it "overcomes" whatever distance I just made it drag the opposite way. This seems absolutely bizarre to me. I determined the dpx and dpy below is the culprit. These are derived straight from the mouse pointer yet will continue to increase even when I begin moving back in the negative direction. This makes me think its not a calculation problem so much as it is how the logic is structured.

Any help would be much appreciated. I'm stuck ...

jPanel1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {  
public void mouseDragged(java.awt.event.MouseEvent e) {
// grab and store current mouse coords
Point pt = e.getPoint();
dpx = pt.x;
dpy = pt.y;
                             
// this is the change in mouse position
changeX = dpx - lastDPX;
changeY = dpy - lastDPY;

// store current mouse coords for next run through
lastDPX = dpx;
lastDPY = dpy;

// add the mouse change to the scroll position of the panel
int scrollToX = getXScroll() + changeX;
int scrollToY = getYScroll() + changeY;
                                               
// some bounding stuff - ignore
if (scrollToX>5000) scrollToX = 5000;
if (scrollToY>3000) scrollToY = 3000;
if (scrollToX<0) scrollToX=0;
if (scrollToY<0) scrollToY=0;
                       
// put the new mouse coords into Point component
dragPoint.setLocation(scrollToX,scrollToY);

// update view position
jScrollPane.getViewport().setViewPosition(dragPoint);

// for debugging
jLabel5.setText("px: "+dpx+", "+dpy);
                             
}
19  Java Game APIs & Engines / Java 2D / Re: sprite movement (paths) on: 2005-02-10 02:41:03
Sounds like the concept of states would be a great way to go. I haven't really worked with that idea before but you could put together a wide variety of scripts. At some point in time you tell that enemy to begin script x,y, or z.

So you'd have scripts like:
Suicide run,
Shoot then Dive,
Shoot and move on,
Enclose (fly next to but not into player),
Random flight,
etc

This would be a lot easier to design than giving ships ai. And you wouldn't need to create precalculated flight paths since each script is more or less the instructions of what to do.

I'm not sure how that FORMATION state would work. I'm guessing it's something like if the ship is in formation spot 3 then fly the same flight path as the ship in formation spot 2 and so on.
20  Java Game APIs & Engines / Java 2D / Re: sprite movement (paths) on: 2005-02-10 00:16:51
Is this a top down scroller where the enemy ships will fly on past you if not destroyed? Can the ships turn around? Do you want to program preplanned flight paths, randomize it, or give them some ai?

A lot of games will give an enemy some kind of velocity factor and then adjust the left/right movement as it travels. It could make those more interesting if you threw some trig in there, but I wouldn't think it would be necessary. Assuming the ships have a constant velocity you could slide it right +1 for 10 frames then slide it back -1 for the next 10 frames and so on.

A couple other random thoughts: You could try giving each type of a ship an aggression level and then use that to determine how close the ship will attempt to fly to the player. It's also pretty common to see ships paired up where one fly downs on one side and the other uses a similar inverted path on the other side.

(But now I'm talking ships and youre talking aliens so maybe I didn't catch the drift of your game)
21  Java Game APIs & Engines / Java 2D / Re: Isometric scrolling woes on: 2005-02-10 00:00:47
Sounds like he was just testing out the idea of drawing an iso map. Don't think he was concerned with clipping.
22  Java Game APIs & Engines / Java 2D / Re: Isometric scrolling woes on: 2005-02-09 22:46:33
Nice tech demo ...

23  Java Game APIs & Engines / Java 2D / Re: Drawing Large Image: Out of Memory on: 2005-02-09 22:45:58
You're definitely right about creating map restrictions. In the end I won't be hard coding those values.

And after thinking more about the mouse freezing idea I realized it didn't make sense. For some reason I was thinking that was the standard approach that many apps used.

Still having problems getting the dragging to work. It should be really easy, so I must be overlooking something. I'll post some code when I get it working.

Thanks
24  Java Game APIs & Engines / Java 2D / Re: Drawing Large Image: Out of Memory on: 2005-02-09 02:47:29
On the topic of screen dragging ....

Has anyone implemented this in an editor? I've got the methods to grab the mouse coordinates and the current scroll position on the map. My code sort of works in that while the mouse button is held down I can drag in any direction. But when I let go and press again to drag the map always jumps back to the top left corner.

The basic idea I'm trying to use is subtract the last mouse coordinates from the current mouse coordinates ... I believe the problem is that mouse coordinates are measured in screen space while the map coordinates (also measured in pixels) are much larger. Somehow this needs to be accounted for ...

--------------
public void mouseDragged(java.awt.event.MouseEvent e) {
dragPoint = e.getPoint();

int dpx = (int)dragPoint.getX() - (int)lastDragPoint.getX();
int dpy = (int)dragPoint.getY() - (int)lastDragPoint.getY();
                             
if (dpx>5000) dpx = 5000;
if (dpy>3000) dpy = 3000;
if (dpx<0) dpx=0;
if (dpy<0) dpy=0;
                       
dragPoint.setLocation(dpx,dpy);
System.out.println("DPX: "+dpx+", DPY: "+dpy);

                             jScrollPane.getViewport().setViewPosition(dragPoint);
lastDragPoint.setLocation(dragPoint);  
}
------------

I'd also like to freeze mouse movement while dragging, which if accomplished would change the way I need to calculate screen dragging.

An old C library I use to use (Allegro) had something called mouse "mickeys" I believe. They tracked the positive/negative movement of the mouse since the last time the function was called.

Any ideas?
25  Java Game APIs & Engines / Java 2D / Re: Drawing Large Image: Out of Memory on: 2005-02-09 00:37:37
I definately like the idea of a draggable window and was planning on adding that in sometime in the future. But since you brought it up, now seems like as good as time as any.

I'm going to opt for the hold down control and left mouse button to drag. This is ala Quark (and probably many other programs)

The 128/256 flag for memory isn't a requirement for the editor by any means. I just wanted to set a high boundary so I wouldn't have to bother with it later. But out of curiosity, what would you consider a reasonable amount of mem to be using for a 2d editor?
26  Java Game APIs & Engines / Java 2D / Re: Isometric Tiling on: 2005-02-08 10:29:19
Probably because our 3d coding knowledge is limited. I could easily grab a 3d engine rotate the camera and be on my way. Then I would run into problems on how to translate mouse coordinates, detect collision, etc.

The project I'm building is intended to be more along the lines of the infinity engine used in BG. I'm using a massive gif as the bottom layer and then building on top of it. Not sure how well 3d would handle rendering a 5000x3000 texture.

I'm also skeptical of using a 3D engine for a top down or isometric engine. I thought the NWN night engine was horrid from that standpoint. In the 3d engine you lose so much focus on the minor details.

The 2D/3D question is more of a design question on how you want to present your world. I don't think 3D is just flat out the best way to always go.
27  Java Game APIs & Engines / Java 2D / Re: Isometric scrolling woes on: 2005-02-07 18:56:40
Did you get this working?

If not can you post your code for drawTile()? I'm not sure whats going on in there but you shouldn't have to be using a modulus more than once to make the calculation.

I just made a similar reply to another isometric topic and gave this code:

plotx = i * TILE_WIDTH + (j & 1) * (TILE_WIDTH/2);
ploty = j * (TILE_HEIGHT/2);

This is the fundamental code to stagger your iso tiles correctly without taking into consideration scrolling or odd sized tiles.
28  Java Game APIs & Engines / Java 2D / Re: Isometric Tiling on: 2005-02-07 18:45:21
If it's really necessary to create a diamond shaped map then this won't be very useful to you...

For my isometric engine I completely fill the screen. The only difference between drawing a standard tile based map and an isometric one is that you draw double the amount of horizontal rows and stagger every other row.

In my rendering loop the code looks something like this:

     plotx = i * TILE_WIDTH + (j & 1) * (TILE_WIDTH/2);
     ploty = j * (TILE_HEIGHT/2);
     
plotx and ploty represent the pixel coordinate that you will be drawing your tile. I and J are the counters your loop is cycling through. Basically the code is staggering the x coordinate on every other row.

Make sense?
29  Java Game APIs & Engines / Java 2D / Re: Drawing Large Image: Out of Memory on: 2005-02-07 03:03:19
Here's just a follow up on this issue:

Turns out increasing the heap size did resolve the problem. I'm building my app in websphere and was adding the "-Xms128M -Xmx256M" flags to the Program Arguments instead of the VM Arguments.

Just FYI in case anyone else runs into this.
30  Java Game APIs & Engines / Java 2D / Re: Drawing Large Image: Out of Memory on: 2005-02-06 20:06:01
I'm already overriding the paintComponent on the jPanel for all my rendering. However, whether I actually draw an image to the screen or not, as soon as I try to create a jPanel much larger than 2500,3000 I start getting memory errors. At some large sizes the memory error will go away and instead the scroll bars will disappear entirely (whether they are set to always display or not)

The code is simple:
---
int h = background.getHeight(null);
int w = background.getWidth(null);
System.out.println("w:"+w+" h:"+h);
jPanel1.setPreferredSize(new java.awt.Dimension(w,h));
---

The width,height = 5000, 3000.

You have been able to use large jPanels without any problems? Were you using a scrollpane on top of it?
Pages: [1] 2
 

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

The first screenshot will be displayed as a thumbnail.

xFryIx (62 views)
2014-11-13 12:34:49

digdugdiggy (41 views)
2014-11-12 21:11:50

digdugdiggy (34 views)
2014-11-12 21:10:15

digdugdiggy (30 views)
2014-11-12 21:09:33

kovacsa (52 views)
2014-11-07 19:57:14

TehJavaDev (56 views)
2014-11-03 22:04:50

BurntPizza (55 views)
2014-11-03 18:54:52

moogie (70 views)
2014-11-03 06:22:04

CopyableCougar4 (70 views)
2014-11-01 23:36:41

DarkCart (156 views)
2014-11-01 14:51:03
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

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!