Java-Gaming.org Hi !
 Featured games (91) games approved by the League of Dukes Games in Showcase (755) Games in Android Showcase (229) games submitted by our members Games in WIP (842) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Show Posts Pages: [1]
 1 Game Development / Game Mechanics / Re: Simplex noise for reasonable maps on: 2015-12-14 12:49:12 Odd to see someone using my old code The thresholds should be fairly trivial to understand. The map I would normally generate will create values between -1 and 1 with fairly even distribution (depending on how you have set the noise parameters though, particularly the scale). With your implementation approximately 50% of the map should be covered in water. If there is too much then you just set the value of deep water to less. Tweak the values depending on how you want your map to look. In my game I use a tilemap and I decide what kind of tiles to render depending on the threshold.In terms of the parameters, my advice is to get some visual output first, then play with the values. How perlin noise generally works is explained here: http://freespace.virgin.net/hugo.elias/models/m_perlin.htmNote: Persistance is equivalent to roughness if my memory serves me correctly.To get a large continent surrounded by an ocean, you just need to apply a function to modify the values towards the center of the map to be closer to one, and the cells towards the edges of the map to be closer to 0. I'm not entirely sure how you would implement this however.
 2 Game Development / Newbie & Debugging Questions / Re: 2D movement: How do I do that? on: 2015-12-13 13:40:23 Huh, never knew about the speed of that. I usually get libgdx to handle a lot of those math functions automaticly. Cheers for the pointer.
 3 Game Development / Newbie & Debugging Questions / Re: 2D movement: How do I do that? on: 2015-12-12 14:41:57 You don't want to do this recursively unless you want the unit to instantaneously move to the target. You want only call the method once per game loop for each unit. Otherwise it will do all the movement before anything renders to the screen.
4  Game Development / Newbie & Debugging Questions / Re: 2D movement: How do I do that? on: 2015-12-11 20:32:52
In order to do movement using that code you all you need to do is access the x_velocity and y_velocity variables which should be stored locally in the class I assume. All that class does is print them out to console.
Note I prefer to work in Vector2s, you can do this in x, y if you want.

Then every game loop, do the following:
 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21 `private Vector2 target;private Vector2 position;spublic boolean moveObject(float deltaTime){//Work out the distance to travelfloat distance = Math.sqrt(Math.pow(target.x - postion.x, 2) + Math.pow(target.y - postion.y, 2))//Adjust the position of the game object, factoring in deltaTime for time spent on the game loopposition.x += x_velocity * deltaTime;position.y += y_velocity * deltaTime;//Check if you have moved past the target by comparing new distance with the old distanceif((Math.sqrt(Math.pow(target.x - postion.x, 2) + Math.pow(target.y - postion.y, 2))) >= distance){//Move the position to the target to compensate for overshooting the targetposition.x = target.x;position.y = target.y;return true;} else {return false}`

Run moveObject recursively, when it returns true you should have reached your target. You will need to adjust this by adding a list if your RTS system has waypoints.
 5 Game Development / Newbie & Debugging Questions / Find closest valid cell in a tilemap on: 2014-12-29 14:04:09 Hi folks, my proposed problem I need help solving boils down to this: On game start, set player position to center of tilemap. If this tile is water however, find the nearest tile which is not water, and set the players position to that tile.Now my current proposed solution is thus:i = 1while(valid tile not found){Check each tile with distance i away from tile on x and y coordinate.If valid, valid tile not found = falseElse i++}While I will think this will work in finding a valid  position for my player to spawn at, it isn't efficient (will find a close valid point, not nessesarily the closest) and feels like a real brute force method. I'm trying to find either a method of solving this using Pythagorean to measure distance (instead of iterating and returning first valid) while being less computationally efficient, or using the height map I also have to find the closest point of land. The latter might be possible, but I forget how to solve a possible valley problem in the search.Anyway, any help would be appreciated
 6 Games Center / Contests / Re: Ludum Dare 31: "Entire Game on One Screen" on: 2014-12-10 14:20:09 I present to you our LD31 Jam Entry: Lights Out!Yes its another shmup :/ However I only realized that LD was on halfway through the weekend, so I enlisted some help from some friends and we quickly put something together within 24 hours in time for the Jam submission. All of us are pleased with what we presented though, and will see what we can do within 72 hours next time
 7 Games Center / Showcase / Re: Panda City Jump on: 2014-05-29 12:12:53 Those graphics look gorgeous; I really like the art style. Very nice work for something built in a month
 8 Game Development / Newbie & Debugging Questions / Online Card Game Architecture Design on: 2014-05-05 17:15:19 It has been a while now since I have made a client-server system, and the last time was when I was in university where I had a ready made web server to deploy to. So when my artist friend came to me with the idea to make an online card game I couldn't help but feel a little stupid on the subject.What I'm looking for is some advice and recommendations as to what systems I should use to implement the following game system. I can look up tutorials later, but I want advice as to what direction I should take.The client for the card game will be designed with LibGDX, which will maintain a TCP connection to the server (game is turn based so I figured TCP is fine). The server is then connected to a MySQL database which holds account details etc. What I'm fuzzy on is what to use to make the server, and what to deploy it on. I was hoping to use standard java ServerSockets for connections, and run the java servlet on an apache tomcat server (as that is what I have done in the past). Alternatively, I have been tempted by the RedDwarf ServerApp to administer a game server, but I am concerned as it seems to be a pretty out of date piece of software. What would you guys recommend I use? Particularly for supporting the server.
 9 Game Development / Newbie & Debugging Questions / [LibGDX] GWT Compile does nothing! on: 2014-04-28 11:15:29 [FIXED] After a while of agonizing I solved this by uninstalling all my GWT related plugins from Eclipse... I discovered that they were for some reason for an older version of eclipse to the one I have. I installed the latest GWT plugins, manually downloaded the latest GWT SDK and linked it to my projects build path and now the project is compiling. Somewhere along that process was the solution I'm trying to deploy a web version of my game, which works fine on desktop and when exporting to a JAR, but for the life of me I cannot get it to pass through GWT.As far as I can tell I've followed the normal process for creating the web app; Right click the gwt project folder in Eclipse -> Google -> GWT Compile. But when I click on it nothing happens. I get no popup, console feed and nothing changes in the WAR directory.Can anyone suggest what I might be missing? Or an alternate way I can export my game as a web app?
 10 Game Development / Newbie & Debugging Questions / Re: [LibGDX] Forground and background camera pan on: 2014-04-23 12:15:20 Yes indeed it is parallax scrolling! Thank you very much to you both
 11 Game Development / Newbie & Debugging Questions / [LibGDX] Forground and background camera pan on: 2014-04-23 11:51:34 What is the name of the effect where when your camera is panning in a game, the foreground is panning by at one speed and the background is panning by at a slower speed? I am looking to implement this in LibGDX so if someone could roughly outline how this is done I would be very grateful!My brain has completely blanked here, I've seen this before but never programmed it!
 12 Games Center / Contests / Re: Ludum Dare 29 on: 2014-04-23 11:36:52 I'll also be participating in this ludum dare. It is my first ever competition, but I have decided to go out and enter the compo as opposed to the jam to give myself a real challenge. Will see how I can perform with LibGDX under such tight conditions
 13 Game Development / Game Mechanics / Re: Generating "True" 2D Perlin Noise on: 2013-12-30 23:01:18 Quote from: Sabomoth on 2013-12-30 22:29:51I am afraid our implementations of Gustavson's original code is mismatched for me to be able to easily patch them together, for example, the one i copied already had octaves and that running before, and the get noise method seems to differ a bit as well. The result i get from your newest method is just even more zeroes and ones, and it only gives between numbers 0-1. No matter how low/high/many octaves, roughness or scale i got. I guess i'll try to build everything from scratch and not follow that guide of there, might even learn something.My implementation is pretty much taken directly from the link I posted above earlier:Stefan Gustavson, Simplex noise demystified: http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdfScroll down to page 11, and you will find the 2D simplex noise method. You will need that and any other methods which are referenced by it (also listed in the same article). After that, the generateOctavedSimplexNoise method I posted earlier should link in with it just fine.
14  Game Development / Game Mechanics / Re: Generating "True" 2D Perlin Noise on: 2013-12-30 21:39:12

I have altered your code to the following so it outputs a two dimensional array that can be used for image processing, I'll post it here in case someone else wants to refer to it.

 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22 `public float[][] generateOctavedSimplexNoise(int width, int height, int octaves, float roughness, float scale){      float[][] totalNoise = new float[width][height];       float layerFrequency = scale;       float layerWeight = 1;       float weightSum = 0;       for (int octave = 0; octave < octaves; octave++) {          //Calculate single layer/octave of simplex noise, then add it to total noise          for(int x = 0; x < width; x++){             for(int y = 0; y < height; y++){                totalNoise[x][y] += (float) noise(x * layerFrequency,y * layerFrequency) * layerWeight;             }          }                    //Increase variables with each incrementing octave           layerFrequency *= 2;           weightSum += layerWeight;           layerWeight *= roughness;                  }       return totalNoise;   }`

I ran a few tests and everything works great. A nice map is generated with the following:

 1  2 `SimplexNoiseGen sng = new SimplexNoiseGen();float[][] osn = sng.generateOctavedSimplexNoise(512, 512, 3, 0.4f, 0.005f);`

And the output! Note, there is a large mass of water because the output is between -1 and 1 for this map, and my program is currently set to make anything less than 0.1 deep water.

Sabomoth, give it a shot with the method I just posted, and drop down the roughness parameter, that should give you the result you are looking for. If it still aint right, just play around with the last three parameters so you get a good feel of what they do
 15 Game Development / Game Mechanics / Re: Generating "True" 2D Perlin Noise on: 2013-12-30 20:45:37 Quote from: Sabomoth on 2013-12-30 19:40:34That looks awesome!I played around with that last night but couldn't get a result nowhere near what you just got there. Been trying for an half hour to touch it up a bit to give presentable images.Try increasing decreasing the frequency of your output. I get much larger features and smoothing maps with a smaller frequency.Quote from: matheus23 on 2013-12-30 20:29:00@longshorts:Looking at the code and image, it looks like you only utilize one layer of simplex noise. If you couple together a couple of layers with different frequencies and weights, you get a much nicer result.Thanks, I did wonder about how to implement different octaves. I'll give it a shot then repost my results, thanks!
16  Game Development / Game Mechanics / Re: Generating "True" 2D Perlin Noise on: 2013-12-30 19:08:47
Thanks for the confirmation Roquen

Well since I put up my last post, I decided to take a stab at implementing Simplex Noise instead of Perlin based off the implementation by Stefan Gustavson, Simplex noise demystified: http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf

I used most of the 2D Simplex code he lists towards the end of the article, and then wrote the following function to stick it all in a 2D array that can be rendered in my game:

 1  2  3  4  5  6  7  8  9  10  11  12  13 `public static float[][] generateSimplexNoise(int width, int height){      float[][] simplexnoise = new float[width][height];      float frequency = 5.0f / (float) width;            for(int x = 0; x < width; x++){         for(int y = 0; y < height; y++){            simplexnoise[x][y] = (float) noise(x * frequency,y * frequency);            simplexnoise[x][y] = (simplexnoise[x][y] + 1) / 2;   //generate values between 0 and 1         }      }            return simplexnoise;   }`

This generates the following map!

Thank god. Just may end up using Simplex Noise after all! My only remaining question is how do you randomise this? My original idea was to simply give a random offset for all the x and y values of my array, but is it that simple? Or should I be doing something else instead?
 Pages: [1]
 DesertCoockie (36 views) 2018-05-13 18:23:11 nelsongames (82 views) 2018-04-24 18:15:36 nelsongames (74 views) 2018-04-24 18:14:32 ivj94 (755 views) 2018-03-24 14:47:39 ivj94 (85 views) 2018-03-24 14:46:31 ivj94 (626 views) 2018-03-24 14:43:53 Solater (101 views) 2018-03-17 05:04:08 nelsongames (182 views) 2018-03-05 17:56:34 Gornova (408 views) 2018-03-02 22:15:33 buddyBro (1068 views) 2018-02-28 16:59:18
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 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