Gad Flailimbs

Greenhorn
+ Follow
since Mar 21, 2007
Merit badge: grant badges
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gad Flailimbs

I'm looking for a class that handles matrices / arrays with 2 (or more) dimensions. I took a quick look at the API and didn't see anything. Anyone know which one would have this built already?

Preferably this class would have support with collections.sort or something else for easy sorting.
15 years ago
I'm kinda new to this webservice stuff and I was just curious which is the most efficient? I'm working on a Java based game and I'm at the stage that I'm working on multiplayer stuff. I've tried sockets and RMI with a lot of hardship, I was thinking webservice would be great because it can be run with a web app that will lessen the strain on the database and have not have clients communicating directly with eachother.

Which would be the best for me? Is there anything I should keep in mind while designing it (e.g., simple methods? connectivity restrictions?). It being a game the clients will be constantly sending information and receiving the coordinates of all the other players I don't know the impact this will have when 10 people are all running it at the same time....
16 years ago
New Version 0.22
Hazaa! One self-contained Jar and less choppy movement.

Game Link

Now if anyone is interested you can help me solve the lag issues. Currently when the character moves he is compared to ever object on the screen to be certain he is able to move. I've got him in a vector along with all the items he is to be compared against. Now if I had thought this through in the beginning I would've made this a 2 dimensional array or something so only the necessary tiles would be loaded and he would be compared to the tile he was moving towards.

But this is how the game is and with school I don't have time for a major recode as of yet. Can anyone think of how I can determine whether he can move or not without iterating through the Vector and using compareTo's on everything with my current setup.

Note that the Vector is sorted by Y position then X position. Zero for Y being the top and the left side for X. If I keep track of his position I may be able to just check the elements around him but I don't know how accurate really would be.

Basically trying to do in a 1d environment what is natural in a 2d.
17 years ago
Thanks a ton. This worked great.

Here's a link to the self-contained game Jar if you're interested.

Game Link
17 years ago
Hello again. I managed to get all the images into the jar file using.

getClass().getResource("/" + imageName);

Now I'm trying to get the text files that are read in to build maps of areas using the images. I thought I would use the same but the File Class does not like URLs in its constructor. To solve this I appended a .getPath() to the end of the statement.

getClass().getResource("/" + textFile).getPath();

But the program does not seem to like this. I end up getting a path that looks something like the following:

/home/Users/Gad/Programming/Game/game.jar!/Maps/map.top

If I've tried removing the slash so it is:

/home/Users/Gad/Programming/Game/game.jar!Maps/map.top

As well as a number of other things to try to get this to work including removing the exclamation point but no luck on all fronts.

When the error is thrown it says approximately the following:

Cannot Find File:
File://home/Users/Gad/Programming/Game/game.jar!Maps/map.top

When I get another opportunity to work on it tonight I plain to toString() the image files that make it into the jar to see if they'll provide me a hint as to the directory structure of a jar.

Thanks for any help, sorry I posted again but no one replied to my last post in the other thread.
17 years ago
How about if I want to read in a text file from the jar? I've found that some constructors for Readers don't like reading from URLs that getClass().getResource("maps.txt") provide.

Would I use something like the following:
getClass().getResource("maps.txt").getPath(); ?

I think the class I'm using for reading files is the Scanner but I'll have to check on that.
17 years ago
To sum it up, you aren't having a problem because employee's parent class is the Object class You are ending up getting an Employee object in your return with the values equivalent to the clone of any attributes of the Object class.

It won't throw a ClassCastException because the clone method will return an Employee and the definition of an Employee envelops any parent classes (Like Object or if you were sneaky you might make a Person class, Object -> Person -> Employee).

I hope this makes sense.
17 years ago
I've looked around and read some stuff but I'm still confused on how to get my Jar file to be self-contained. I'm using Eclipse with separate Source and Class folders. I use about 40 different images while running my program and they're all in different folders.

I've tried:

getClass().getResource("Images/character.gif")

I've also read about some ClassLoader you can use to get a similar effect:

ClassLoader cldr = this.getClass().getClassLoader();
ImageIcon area2 = cldr.getResource("Maps/area2.png");

Neither of these seem to work. I've tried putting all the files in the source and bin folders. Regardless of all of this I still can't seem to get it to work properly. The Jar's just won't function without those folders near them even though I include the folders & files in the jar when I create it.

What do I need to do to get this to work?
17 years ago
Here's the code from back in the day when I was working on it:

public void send()
{
//Note there is a potential issue if the user hasn't moved
//and a new user gets into the server then it won't return
//its Entity
synchronized(this)
{
try
{
if (am.update == true)
{
//This could be outside the if statement but then
//there would be ceaseless and possible pointless
//communication with the server
myUser.setImage(myTrainer.getImage());
myUser.setX(myTrainer.getTrueX());
myUser.setY(myTrainer.getTrueY());
myUser.setTrueX(myTrainer.getTrueX());
myUser.setTrueY(myTrainer.getTrueY());
am.update = false;
out.writeObject(myUser);
}
}
catch(Exception ex)
{
System.out.println("Send Failed");
}
}
}

I eventually got to the point that I had to use:
out.writeObject(new Trainer(myTrainer.getImage() ... ));

And so it went. The flush command didn't help even though it seems like it should do something like what I want. Has anyone else had experience with this problem? Have you solved it?

flush:
Flushes the stream. This will write any buffered output bytes and flush through to the underlying stream.

You may notice that I am not closing the connection after it is output. I'd prefer to keep the connection open as there is almost always data being sent.
Thanks for the info. I was more curious for anyone who has had personal experience with an alternative on a similar scale.

With what you've just said it seems ImageIcon is probably best choice for animated character images and other stuff I'm looking at. Thanks again.
17 years ago
I'm not worried about getting sued. I'm much more concerned about my apathy towards getting schoolwork done.
17 years ago
I'm curious as the best Image object to use when you're tossing about 100+ images onto a JPanel at a time. I believe ImageIcon extends Image but is it pointless to use it on such a large scale?

Thanks for the info!
17 years ago
I've tried using sockets to pass an object accross to a server which then passes this object down to multiple clients accross the network. The problem I've run into is that the program starts chewing up memory and I believe this is because it remembers the object that was sent.

I've read that if the same object is sent accross a socket then a termination signal is sent instead. I was unable to have the object update and be sent to the clients unless I kept creating a new one to send accross. Now it is my assumption that all these objects are just piling up and that the way to solve it must be to clear the buffer of these saved objects (or ids of objects).

Have any of you had experience with this before? Is there a way to get around it? I tried running a clear command or something on the Socket but that didn't work, please let me know if you know how to fix this.

Either this or if you know a way of getting RMI client / server to work through a firewall.
Hello everyone.

I am currently making a java based game. Don't let the fact that it is a pokemon game fool you. I am merely choosing the concepts as a base idea for the game and I plan to make it my own. The handy part of using Pokemon is that all the tiles are widely available through screenshots and some are clipped.

So far I have a character moving accross an area, I have impassable objects like fences and bushes, there are movement tiles that make the character jump and others that make him change areas.

I have tested the online side using Sockets and RMI. The socket implementation failed because of the memory consumption that was used in the process of constantly sending and receiving (see the site below for more details). I was using Call Backs with RMI and apparently they don't work accross firewalls (but on my local network it ran amazingly).

I'm currently working on packaging all the images and text files into one jar file so people can run it easier. I've found people get confused about how to unzip stuff and double click a jar (if I can narrow it down to one step it is just better).

After I get a single jar then I'll hopefully get into a major recode I've been planning for a while now. I'm hoping to change from the current style of movement to a grid style. The reason is because I believe it would be a lot easier to run the game with the only tiles in memory being the ones on the screen instead of having an entire area loaded all at once. If you notice the gameplay is really choppy around objects like grass or fences. This choppyness leads to bugs with movement allowing you to get stuck in walls. Instead of comparing the character to everything on the screen I plan to compare him to the object in the position directly adjacent to him in the direction he is moving.

If any of you would like to take a look at my code I'll gladly post it. I have some models and some other problems I've had posted on the website. When the game gets to a usable point I think I'll make it open source so anything I post is up for grabs as long as you're respectful of it (if you could make money off of it tho I want a cut, haha).

Anyone willing to help is welcome, I can always use more coders and/or consultants. Below is a link to the site, thanks for checking it out.

Website Here.
[ March 21, 2007: Message edited by: Gad Flailimbs ]
17 years ago