Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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 / Game Play & Game Design / Re: [LibGDX] 2D (top down) procedurally generated terrain. on: 2013-08-07 14:43:05
A little snippet of code to not render tiles outside specific radius.
1  
2  
3  
public static double calcDistance(double x1, double y1, double x2, double y2) {
   return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}


Usage:
1  
2  
3  
4  
5  
6  
final static double RADIUS = 25.0; //25 tiles
final static double TILESIZE = 1.0;
final static double RENDERDISTANCE = TILESIZE * RADIUS;
if(calcDistance(playerPos, tileX, tileY) <= RENDERDISTANCE) {
    //Render tile here.
}


This might not be the fastest way, but it gets the job done.
Hope it helps Smiley
2  Game Development / Newbie & Debugging Questions / Re: load wavefront obj in jogl on: 2013-07-17 08:16:00
A simple google Search gives you what you need.
https://www.google.com/search?q=Wavefront+obj+jogl
3  Games Center / WIP games, tools & toy projects / Re: [Open Source] RandomRPG on: 2013-07-16 23:42:59
Regarding the graphics, I am not going to worry about them just yet.
Currently I only create/draw new tiles or edit old ones when I need to(for example when adding new features, like the transition tiles).

NEW FEATURE:
I have implemented a map(pressing 'M').
Example:

(Black areas are chunks not generated/discovered)
4  Games Center / WIP games, tools & toy projects / Re: [Open Source] RandomRPG on: 2013-07-15 20:51:45
I have only one question: how you managed to get that transition from grass to sand and sand to water? Are you using a sprite for every type of transition (i.e. every tile to every other tile and every position (N S W E)) ?

I have 4 tiles which I rotate to all angles.
Look at the top right tiles here:

Source Code:
Resources.java

I first draw grass and then the transition tile over it.
5  Games Center / WIP games, tools & toy projects / Re: [Open Source] RandomRPG on: 2013-07-15 09:58:54
UPDATE:
Fixed the World Generator so that it almost smoothly connects the chunks.
One step closer to Infinite Terrains Cheesy

Example
Chunks are 32x32 and World size is 1024x1024
6  Games Center / WIP games, tools & toy projects / Re: [Open Source] RandomRPG on: 2013-07-12 12:38:43
Hey I kind of recognise the character where did you get it?

I don't quite remember, i got it somewhere off the internet Tongue
This is not the final character model, this is temporary.
7  Games Center / WIP games, tools & toy projects / Re: [Open Source] RandomRPG on: 2013-07-10 14:34:49
UPDATE. FINALLY Cheesy
After all these months i finally redid the rendering system.
The game now uses LWJGL to render and handle input.
Not much else has happened.

Planning on trying to release more updates very soon.
8  Game Development / Shared Code / Re: EzEngine - Easy Wrapper for LWJGL on: 2013-04-19 10:44:33
Added for loops to TextRenderer.java, it now contains 70% less code Tongue
100 - (538 / (1771 / 100)) = 69,621682665160926030491247882552% reduction
9  Game Development / Shared Code / Re: EzEngine - Easy Wrapper for LWJGL on: 2013-04-17 13:43:07
hi I took a quick look at the source of your textrenderer and you probably should take a look at for loops

I know, just threw that TextRenderer together for an other project. (It's actually my first working text renderer Cheesy)
plus there are some font alignment issues(if you scroll down you'll see).
There were alot of copy-paste, but i'll probably look into adding some for loops at a later date.
10  Game Development / Shared Code / Re: EzEngine - Easy Wrapper for LWJGL on: 2013-04-17 12:00:31
After some a long time in the dark, this engine is now back.
I have already implemented TextRenderer and a 2D Graphics lib  Shocked

Example:
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  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
import org.ezlwjgl.GL.*;
import org.lwjgl.input.Keyboard;

public class Example {

   public static void main(String[] args) {
      WindowManager.enableMouse = true;
      WindowManager.mouseGrab = true;
      WindowManager.enableKeyboard = true;
      WindowManager.createWindow("Test", 800, 600, 60);
      int texture = TextureLoader.loadTexture("/shop.png");
      while (true) {
         Renderer.make3D();
         Renderer.make2D();
         /**
          * ALIGN_CENTER align the text to center of screen
          * drawString(String text, int align) */

         Graphics.drawString("Center Aligned Text", Graphics.ALIGN_CENTER);

         /* drawString(String text, int textSize, double x, double y, double z) */
         Graphics.drawString("Absolute Coordinate Text", 1, 32, 250, 0);

         Graphics.drawString("Small text", .5, 32, 265, 0);

         Graphics.drawString("Big text", 2, 32, 275, 0);

         /* drawTexture(int textureID, double x, double y, double width, double height) */
         Graphics.drawTexture(texture, 0, 0, 32, 32);
         Graphics.drawString("<- Full texture draw", 1, 40, 8, 0);
         
         
         /**
          * Renders a tile from texture tile_x = tile x coordinate in pixels, tile_y = tile y coordinate in pixels, tile_w = tile width in pixels,
          * tile_h = tile height in pixels, size_x = texture width, size_y = texture height.
          *
          * drawTexture(int textureID, int tile_x, int tile_y, int tile_w, int tile_h, int size_x, int int size_y, double x, double y, double width, double height) */

         Graphics.drawTexture(texture, 0, 0, 16, 16, 32, 32, 0, 40, 32, 32);

         Graphics.drawString("<- Tiled texture draw", 1, 40, 48, 0);
         if (WindowManager.update() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
            break;
         }
      }
      WindowManager.destroyWindow();
   }
}

Produces:
11  Games Center / WIP games, tools & toy projects / Re: [Open Source] RandomRPG on: 2013-04-04 13:44:30
Bug Fix:
Fixed problem where smoothing would pick the wrong tile.
Bug occured when two blocks(shore lines) were "touching".
12  Games Center / WIP games, tools & toy projects / Re: [Open Source] RandomRPG on: 2013-04-04 12:45:00
UPDATE:
Added smooth textures, which are a little buggy.


Upcoming features:
Skill & Attributes system
Inventory & Equipment
Combat system

Possibly future features:
Convert rendering system to OpenGL(LWJGL or similar)
13  Game Development / Game Mechanics / Re: Smooth Graphics Algorithm? on: 2013-04-03 09:21:55
EDIT: Just to be clear, i already had the tiles. I only needed the code  Pointing

ME FIX Cheesy


Code: http://pastebin.java-gaming.org/24c7c4b2954
14  Game Development / Game Mechanics / Re: Smooth Graphics Algorithm? on: 2013-04-03 08:35:29
... Also how do you get the Memory Allocated?
Something like this:
1  
2  
memUse = (int) (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024;
bufferGraphics.drawString(String.format("Memory Usage: %sMB/%sMB", memUse, World.run.maxMemory() / 1024 / 1024), debugX + 1, debugY + 61);


It might not be completly accurate, but it works.
15  Game Development / Game Mechanics / [FIXED] Smooth Graphics Algorithm? on: 2013-04-02 15:31:42
I have a question:
What is the best way to do this: (smooth transitions, yellow is sand, blue is water, and white is "grass")

Hard edges:                                       Smooth edges:
 

currently, my plan is using this code(not finished): http://pastebin.java-gaming.org/2224c272c5b
S_NW / W_NW == SAND_NORTHWEST / WATER_NORTHWEST

But is this the fastest way? (probably not Tongue)

Screencap:

16  Game Development / Shared Code / Re: Reducing class file sizes (Java4K) on: 2013-03-19 08:17:33
Can you explain what this exactly does in more detail? How does it achieve the reduction?

I have made the reductions myself, I change Variable names and changes the code around.
So that the final class file would be smaller Cheesy

Code changes:
https://code.google.com/p/random-rpg/source/diff?path=/A.java&format=side&r=5 (First and final version comparison)
17  Game Development / Shared Code / Re: Reducing class file sizes (Java4K) on: 2013-03-15 17:23:16
Wait, you're talking about reducing class files for java4k but why all I see is lwjgl with physics?

Yes, this project originally was about using JBox2D with LWJGL as graphics lib.
But when i started editing(shortening variables), the class file started shrinking dramatically(~50bytes Tongue).

Then i started thinking why not try to make it smaller and smaller.
This way I will learn about shrinking games for Java4K (this game is not a Java4K game).
18  Game Development / Shared Code / Reducing class file sizes (Java4K) on: 2013-03-15 15:05:44
A little project i have, trying to reduce the size of a Java Class file.
Without removing any features.

Original Size: 5736bytes
Current reduction: 3150bytes removed (~55% reduction) (Pure javac compile, no compression or proguard)
With Proguard(class only): 3219bytes removed (~56% reduction)
Compressed Jar: 4219bytes removed (~73% reduction)
Compressed Proguard Jar: 4304bytes removed (~75% reduction)

NOTES:
Rolling your own builder in eclipse pays off, got a ~550b reduced class file size Cheesy

Fell free to leave any comments/tips which can help in my quest Cheesy

Source Code:
Final - http://pastebin.java-gaming.org/311b3907443
v1.4 - http://pastebin.java-gaming.org/e905a337341
v1.3 - http://pastebin.java-gaming.org/9e9052a7343
v1.2 - http://pastebin.java-gaming.org/19e90157a43
v1.1 - http://pastebin.java-gaming.org/619e900754a
v1.0 - http://pastebin.java-gaming.org/4619e996045 - This is not the first version, it's the first version i had access to.


I kept a little changelog: (Number prefixes are class sizes in bytes)
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  
32  
Prefix = bytes

5736 First

5712 Changed .76f to .75f
5707 Chaged wall/roof/floor size to 50 instead of 1000
5693 .. Some random shit (but it still works)
5687 .. Some random shit (but it still works)
5449 Removed debugging(box pos)
5330 Removed boolean isAlive and changed to !Display.isCloseRequested
5169 Shortened some variable names
5096 Removed unnecessary code.
4984 Removed unnecessary code.
4708 Reusing variables
4640 Reusing variables
4638 Shortened Variable name
4610 Changed !Display.isCloseRequested() to !Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)
4609 Removed unnecessary code.
4603 Changed some floats to ints
4055 Reused some variables FixtureDef, BodyDef & PolygonShape (used .clone())
3882 Removed unnecessary code.
3855 Removed unnecessary code.
3653 Removed unnecessary code.
3598 Changed Math.toDegrees() to Radian * (180 / 3.1415)
3547 Changed getContactList() to b.getPosition().y < .77f
3518 Removed unnecessary code.
3363 Reused some variables.
3339 Removed unnecessary code.
3275 Various fixes.
3238 Removed glDisable(GL_DEPTH_TEST) as it was never enabled by glEnable()
2683 Implemented custom builder into Eclipse. psuedo cmd: javac -cp "PROJECT_CP" -g:none SOURCE_FILE -d OUT_FOLDER
2586 Removed unnecessary code and various fixes.
19  Game Development / Newbie & Debugging Questions / Re: JBox2D & LWJGL Problem on: 2013-03-15 09:04:56
I found the problem Cheesy
I was using:
1  
2  
3  
float step = 1 / 60f;
// While and sutff here ----
World.step(step, 8, 1);

But this did not work as it should Sad

Fix:
1  
World.step(1/60f, 8, 1);

This works! Cheesy
20  Game Development / Newbie & Debugging Questions / Re: JBox2D & LWJGL Problem on: 2013-03-14 16:50:43
Oh. I guess that´s what happens when you just take "a quick look". Sorry about that. Smiley

Just to clarify: "right" and "left" works fine, it´s just "up" that´s causing a problem?


Yes, right and left works fine. But not up or the walls Sad
21  Game Development / Newbie & Debugging Questions / Re: JBox2D & LWJGL Problem on: 2013-03-14 15:56:28
I just took a quick look and in the shrunk version you overwrite bS, fS, pS all the time and in the other version you have separate objects for boxDef, groundDef etc. Perhaps that has something to do with it?

I read on the Box2D forums, that the *Def can be reused. But maybe i did something wrong somewhere... :s

Quote
On a sidenote: Is the shrunk version only shorter variable names? In that case I think you should ditch the shrunken version. Why would you want to change your code to something that´s much harder to read? Smiley
It makes the final Class file smaller Cheesy
I'm secretly practicing for Java4K!
EDIT: PolygonShape has a .clone() so thats not the problem, as I clone it before I reuse it.
EDIT2: On the other hand, maybe reusing variables only work in the C/C++ version Sad
22  Game Development / Newbie & Debugging Questions / [FIXED] JBox2D & LWJGL Problem on: 2013-03-14 15:28:17
Removed Cheesy
FIXED IT!
Moved to: http://www.java-gaming.org/topics/reducing-class-file-sizes-java4k/29004/view.html

Solution:
I found the problem Cheesy
I was using:
1  
2  
3  
float step = 1 / 60f;
// While and sutff here ----
World.step(step, 8, 1);

But this did not work as it should Sad

Fix:
1  
World.step(1/60f, 8, 1);

This works! Cheesy
23  Games Center / Cube World Projects / Re: Voxel - a start on: 2013-03-12 13:52:33
If you need terrain generation look at mine Smiley
http://www.java-gaming.org/topics/terrain-generator/27502/view.html

Local Copy: https://dl.dropbox.com/u/39535549/Volt.jar (Demo + Source)
24  Game Development / Performance Tuning / Re: Java Brute Forcing Algorithm Optimization. on: 2013-03-05 12:02:34
I have made a fully recursive version of this in C.
http://pastebin.java-gaming.org/652ff3f5941

It shouldn't be to hard to translate to Java. (Thats why I did it for you Cheesy)
Java:
http://pastebin.java-gaming.org/52fff495143

EDIT:
Actully doing some tests i found out that Java version is faster on longer passwords(strings).
While C is faster at smaller strings like 1-3 chars...

for example in one test:
In C version, "breakm", took ~320seconds,
while in Java version it took ~69seconds.
25  Java Game APIs & Engines / OpenGL Development / Re: OpenGL learning W/O internet access on: 2013-02-10 21:47:09
Download documentation and/or ebooks
26  Discussions / General Discussions / Re: New feature: appreciation results in post medals on: 2013-02-04 14:36:07
http://www.java-gaming.org/domain_seized.jpg Tongue
27  Game Development / Newbie & Debugging Questions / Re: Noob Projects? on: 2013-02-04 11:27:34
Screw around with Console(as in text-based) Games, just to get the feel of making a game(not concerning yourself about graphics or sound),
then move on to Java2D(or similar, libGDX, slick, etc.),
then you can move on to learning OpenGL and make a OpenGL Accelerated 2D games with basic sound(OpenAL),
and finally move onto 3D(OpenGL).

But don't get to excited, this is not a small learning curve.
It will take time and dedication to get from start to finish...

Good Luck  Grin
28  Game Development / Shared Code / Re: [LWJGL] EzRender - Easier Rendering on: 2013-02-01 13:22:51
A little Demo "Game"(not finished), showing off some Cel Shading Tongue
Download
29  Game Development / Shared Code / Re: [LWJGL] EzRender - Easier Rendering on: 2013-02-01 10:07:15
Uploaded a Jar Library, which you can include in your project.
You will also need to include the LWJGL libs too.

I'm now going to make a small/medium game with this library,
and I will only use the functions included in this library.
By doing this I can implement missing features into the library.
30  Game Development / Shared Code / Re: [LWJGL] EzRender - Easier Rendering on: 2013-01-31 13:45:37
Added Camera Controls,
WASD - Move Camera
Mouse - Rotate Camera Pitch & Yaw
Pages: [1] 2 3
 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (62 views)
2014-04-15 18:08:23

BurntPizza (60 views)
2014-04-15 03:46:01

UprightPath (73 views)
2014-04-14 17:39:50

UprightPath (56 views)
2014-04-14 17:35:47

Porlus (73 views)
2014-04-14 15:48:38

tom_mai78101 (99 views)
2014-04-10 04:04:31

BurntPizza (159 views)
2014-04-08 23:06:04

tom_mai78101 (254 views)
2014-04-05 13:34:39

trollwarrior1 (208 views)
2014-04-04 12:06:45

CJLetsGame (215 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!