Joe Thatcher

Greenhorn
+ Follow
since Jun 24, 2014
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
6
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Joe Thatcher

Campbell Ritchie wrote:Why are you using string tokenizer, which has been regarded as legacy code for about 13 years?


Could you post a source for this? Everybody I know uses Strings, and I have never had an issue with them. What is so bad about using them, and since when where they legacy?
5 years ago
As said in the above post, you are modifying and reading the HashMap at the same time.

If you wish to avoid this, then do not read and write at the same time.

Or, if you really want to read and write at the same time, use a ConcurrentHashMap which will allow you to both read and write at the same time, but in my experience can use slightly more CPU.
5 years ago

Darryl Burke wrote:http://docs.oracle.com/javase/8/javafx/get-started-tutorial/index.html
https://coderanch.com/forums/f-98/JavaFX


*Sighs*. I guess I will do my own research on the subject.

Many thanks for pointing me in the right direction! Looks like JavaFX is far better than JFrames and stuff .
5 years ago

Darryl Burke wrote:Ina (non-)word: JavaFX


What is this JavaFX, and how do I use it?

I don't want to be spoonfed, but an answer linking to an informative source or tutorial, or explaining what said thing does, would be greatly appreciated.
5 years ago
Hi!

I am looking for a good library to help me make start screens. I am currently using the java swing methods, but I cannot make the start screen as fancy or as advanced as I would like.

I would also like to have it have the option of multiple buttons with text under them to create a shop, a bit like this:

Obviously that image was quickly photoshopped and created quickly, but you get the general idea that I would like an image, and then text under the image, and then the ability to click on the image and to have a pop up saying something like "Do you really want to buy this ship?" and then obviously the option of "Yes" or "no".

Really, it is a lot to ask, but currently the java swing methods are simply not good enough for me to create a good-looking start screen.

My current start screen (Actually not horrendous, just doesn't have the functionality for fanciness I would like):

Which just isnt good enough.

So can anyone recommend a good library for start screens?

Thanks!
5 years ago

Campbell Ritchie wrote:So the slopes appear 8× as steep on the smaller map? That part explains the 8 1 8. Don't know about the other things, I am afraid.
Shall try duplicating the question in the games forum.


Each map if rendered is the exact same.

However, one of them is a full-scale map of 2000px x 2000px. The other one is a 250px x 250px - This one is timsed by 8 when rendering. Effectively, it gives the same image but less vertices.
Decreasing the detail of the map would not work because it is the amount of vertices rendered that is the issue here, not detail. I have as much detail as 250 x 8 will allow.
5 years ago

Campbell Ritchie wrote:Please explain more about what height map is; I am not familiar with it, and maybe other poeple won't be familiar with it.
In the scale method, I can see that 250→2000 is 8, but why are you using 8 1 8?


While my code is not directly from there, there is a good tutorial about heightmaps at https://www.youtube.com/watch?v=nFrBwkaReJE. Pretty much explains what a HeightMap is in the first minute.

Or, if you're not willing to watch Youtube, it is an image which sets the height of a coordinate of a certain location, meaning that it is a simple and easy way to store a map file. The drawbacks are that I cannot have tunnels, overhangs, etc.

glScalef(8, 1, 8) - glScalef(x, y, z). Both heightmaps have got the exact same height (y). The smaller one just has the X and Z at 8 times less than what they actually are, which is why I only scale those ones up.
If I scaled the Y, not only would it not be accurate with the collision heightmap, but also I would have massive cliffs/peaks instead of small/medium hills.
I am scaling it up because rendering that massive amount of vertices in a display list is impossible without dropping to <10 FPS. Eventually, I will have a chunk mechanism where it scales it less and less and gives a more and more accurate heightmap the closer you get to it, however that will be a while in coming and won't actually solve the 'now' problem.
5 years ago
Hi! I have another problem which I cannot seem to solve. While related to my ship rotation issue, it technically has nothing to do with it, which is why I am posting here.
I did also ask on Stack Overflow (http://stackoverflow.com/questions/24431328/heightmap-glscalef-not-accurate-with-a-larger-heightmap), however that question has got few (6) views and I doubt it will be answered any time soon (Will edit this question if issue is solved elsewhere).

So, to quote the Stack Overflow page:

I have got two HeightMaps. One is of size 250, the other is of size 2000.

The HeightMap with the size 2000 is stored into memory and used to detect if the player is in collision (i.e. if (player.y() < heightmap.y()) do collision stuff).

The HeightMap with the size of 250 is stored into a DisplayList and is rendered.

Before rendering (glCallList()) the 250 Heightmap, I glScalef(8, 1, 8).

It is fairly accurate. However, there seems to be a slight offset. If I move to one side of the map, I seem to collide slightly before I actually hit the land.
If I travel to the other side of the map, I seem to collide slightly after I actually hit the land.

This is a pretty big problem, because players are colliding and taking damage when graphically there is nothing to hit, and then at other times they are sinking into the map where they should be taking damage.

What is wrong? Is there anything wrong with glScalef() that I do not understand?



If I have an island, a player (the ship) coming at it from 1 angle will collide with it before graphically colliding with it. The person on the other side will actually go slightly into the island before any collision is detected.

Is there something to do with glScalef() that I do not understand?

Thanks!
5 years ago
Problem has been fixed now with an entire code rewrite.

The help from this forum has been crucial to fixing this issue, so thank you all for spending your time to help me. This is the first forum focused on game development which has been friendly and inviting, so I should hopefully stick around for a while.

Thanks!

Campbell Ritchie wrote:

Joe Thatcher wrote: . . . P.S. I tried both StackExchange and GameDev for this question. Very unfriendly & unhelpful. . . .

I have seen one of the discussions and I did not perceive any unfriendliness myself.


They heavily downvote and give no reason, and it and locked it with an invalid reason. IMO, that is unfriendly. The most amusing thing is that when asking on GameDev, they actually said I should go to StackOverflow, even though when I asked there I got downvoted and locked!!
5 years ago
What? This SSCCE page simply is telling me how to format code so others can understand it.
5 years ago
Here is some code you should potentially be able to put directly into your IDE without classes you do not understand.

5 years ago
Thanks for the great replies . This has currently been the only site that has actually give me friendly, helpful replies.

I currently have the following code, but it still isn't working:

This does still not work, and returns something like 62. I am probably still doing something obviously stupid/wrong, but I can't seem to find it now. I think that the distance and the rotation thing is now fixed, though I am somewhat confused about this Radians business. Which methods actually are requiring Radians? How can I find out?

While not directly ontopic for this thread, I also fixed an error where the graphical world was a slightly different size than the collision world, making irregularities.

*About 10 minutes of testing later*

It varies between about 59 and 66. I still cannot find out what the actual issue is.

As you can see, it isn't very realistic-looking currently.

5 years ago
In regards to your edit about me posting on multiple sites, that topic had already been put on hold before posting on here. I usually do not post on two sites at the same time unless one answer has either not been answered in 2 days or unless people are unable to answer from that site.
5 years ago
Could you please tell me what specifically is wrong? I am getting so many confusing/conflicting answers from so many different sites that I am no longer sure what is actually correct any more.

The "weird sine stuff" is just me getting a location in front of the ship. It is not part of the mathematical equstion.

cl is just a Client/Player. I can give you the entire application if you want, but I don't think you want to sift through 2000+ lines of code...
The terrible variable names is because I was getting the names from the mathematics forum. I should fix that.
I get your point about getXXX. Again, I should probably implement that, however it is not how I was taught to use code, and so stuff like that is often neglected out of habit.

The exception is because I can get an ArrayIndexOutOfBoundsException when the ship goes off the map, which is possible to happen. If one player somehow managed it, I would not want it to crash the server.

So, how exactly have I not done the equation correctly? I can't seem to work it out.

Thanks for the help!

5 years ago
I currently have this code:


The aim of this code is to correctly find the angle in degrees from a central point to the outside of the point. You can find more on the question here: http://math.stackexchange.com/questions/845063/how-to-calculate-the-rotation-between-2-coordinates

That question I linked you to has got a perfectly good mathematical answer, and I believe that is what I have implemented into my code, however it ALWAYS seems to be returning 1.5 no matter what I do? I could have potentially translated the math incorrectly into java code, or just got entirely the wrong thing.

Either way, this is specifically a programming issue as it is either an issue with turning a mathematical function into code or fixing code logic, which is why I decided to post the question here.

The desired result is that it returns the correct value. Wheras currently, it does not.

What is wrong? Have I translated the maths incorrectly into java? Do I have faulty code? Or what?

(I know that specific debugging questions are harder to solve, however I think that it is simply something simple like not translating the maths correctly, however I just cannot find it.)

Thanks!

P.S. I tried both StackExchange and GameDev for this question. Very unfriendly & unhelpful. I hope I can get some help here .
5 years ago