Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (592)
Games in Android Showcase (168)
games submitted by our members
Games in WIP (646)
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 ... 72
1  Games Center / WIP games, tools & toy projects / Re: Babbie's first software-rendered ray-tracing on: 2015-06-30 22:58:45
That would be ray casting, not tracing, as your linked article says.
This is ray tracing: https://en.wikipedia.org/wiki/Ray_tracing_(graphics)
Some also make the subtle distinction of path tracing: http://home.lagoa.com/2014/04/ray-tracing-vs-path-tracing-in-plain-english/

2  Discussions / Miscellaneous Topics / Re: How to Learn Web Development for Java Programmers on: 2015-06-27 07:13:32
Static sites are a thing, especially for tech blogs these days it seems...
3  Discussions / General Discussions / Re: Resizing a picture but still keeping it look pixelated? on: 2015-06-25 20:23:59
Linear will also be blurry for pixel art.

For Paint.NET you want the Image menu > Resize > set Resampling to Nearest Neighbor.
4  Game Development / Performance Tuning / Re: Video frame grabbing to bufferedImage on: 2015-06-25 02:50:04
I have used Xuggle for this, so it does work, but I cannot remember how fast it was, sorry. I don't recall it being noticeably slow though.

I wouldn't be surprised if nsigma had a good solution to this built in to Praxis Live.
5  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-06-24 17:21:16
Found this great break down of how Supreme Commander does it's graphics. Must-read for anyone wanting to know how AAA level RTS is done.
http://www.adriancourreges.com/blog/2015/06/23/supreme-commander-graphics-study/
6  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-06-24 15:17:44
Nobody said it was particularly useful or was better.
My 'diagnosis' is that whoever came up with it didn't realize it was possible someone would have such strong opinions about such an inconsequential detail and just wanted a method of "switching context" with syntax consistent with how the rest of the library is idiomatically used (i.e. method chains).

Whether or not it was ill-minded or retarded or genius I don't know, because I don't actually give a damn.

I await the monster.
7  Discussions / General Discussions / Re: Any DOWNLOADABLE programs for picking RGB colors easily with float value? on: 2015-06-24 00:45:00
Or DIY:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
import javax.swing.*;
import javax.swing.event.*;

public class NeedSomeColors {
   public static void main(String[] a) {
      JFrame frame = new JFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      JColorChooser jcc = new JColorChooser();
      frame.add(jcc);
      jcc.getSelectionModel().addChangeListener(new ChangeListener() {
         @Override
         public void stateChanged(ChangeEvent e) {
            float[] rgba = jcc.getSelectionModel().getSelectedColor().getRGBComponents(null);
            frame.setTitle(rgba[0] + " " + rgba[1] + " " + rgba[2]);
         }
      });
      frame.pack();
      frame.setLocationRelativeTo(null);
      frame.setVisible(true);
   }
}
8  Game Development / Newbie & Debugging Questions / Re: Tile by tile lighting how would i do this on: 2015-06-23 18:20:27
Question: what is the code for Utils.mixColours?
9  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Java OpenGL Math Library (JOML) on: 2015-06-23 17:27:36
Probably to allow switching to a different instance in the middle of a long method chain, just in case you want to do that.
10  Game Development / Newbie & Debugging Questions / Re: Tile by tile lighting how would i do this on: 2015-06-22 21:06:38
You can also make use of a 2D-array for the "shadow"-tiles that you will draw over the scene.
...

Let's not over-complicate things before tommohawk has a working naive solution.
Besides, the next step is using a light texture and additive blending instead of faking it with an array.
EDIT: actually I'm not sure what that method is trying to fake, but it sure isn't as robust as the simple way.
11  Game Development / Newbie & Debugging Questions / Re: Tile by tile lighting how would i do this on: 2015-06-22 21:01:52
I'll point it out very explicitly this time:

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  
for (int x = startX; x < toX; x++) {
               for (int y = startY; y < toY; y++) {
                  if (x < 0 || x > TileRenderer.map.getWidth() - 1 || y < 0 || y > TileRenderer.map.getHeight() - 1)
                     continue;

                  float tileBrightness = sunlight.a;

                  for (int i = 0; i < lights.size; i++) {

                     MasterTile tile = lights.get(i);
                     if (tile == null)
                        continue;
                     float distance = Vector2.dst(tile.getX() / MasterTile.TILE_WIDTH, tile.getY() / MasterTile.TILE_HEIGHT, x, y);
-                     tileBrightness += Math.max(0, distance / MAX_DISTANCE);
+                     tileBrightness += Math.max(0, 1 - distance / MAX_DISTANCE); // you really do need that 1 -

                  }
                  tileBrightness = Math.min(1, tileBrightness);
                 
                  Color tileColor = Color.WHITE;
                      tileColor = Utils.mixColours(tileColor, sunlight, sunlight.a);
                      tileColor = Utils.mixColours(tileColor, Color.WHITE, tileBrightness);

                  spriteBatch.setColor(tileColor);
                  spriteBatch.draw(pixelTexture, x * MasterTile.TILE_WIDTH, y * MasterTile.TILE_HEIGHT, MasterTile.TILE_WIDTH, MasterTile.TILE_HEIGHT);
                  spriteBatch.setColor(Color.WHITE);
12  Game Development / Newbie & Debugging Questions / Re: Tile by tile lighting how would i do this on: 2015-06-22 20:50:41
Clamp in this context: to limit to a range

1  
tileColor.a = Math.min(1, tileBrightness); // don't exceed 1.0



The inside-out lighting is because of the missing '1 - ...' in 1 - distance / MAX_DISTANCE

Try taking it out of the graphs I linked and see what happens.
13  Game Development / Newbie & Debugging Questions / Re: Tile by tile lighting how would i do this on: 2015-06-22 20:41:29
1  
2  
-tileBrightness += Math.max(0, distance / MAX_DISTANCE);
+tileBrightness += Math.max(0, 1 - distance / MAX_DISTANCE);


You want an negative slope, brightness is inversely proportional to distance.

You also aren't clamping tileBrightness prior to assigning it to tileColor.a, although SpriteBatch might do it anyway, I don't remember.
14  Game Development / Newbie & Debugging Questions / Re: Tile by tile lighting how would i do this on: 2015-06-22 20:26:11
You aren't summing the lights together.

Lights pseudocode in pretty much any framework:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
for each tile visible {
     tileBrightness = ambient; // ambient = 0 if you want total darkness outside of lights
   
    for each light visible {
        lightValueAtDistance = /* interpolation from before */
        tileBrightness += lightValueAtDistance;
    }
   
    // probably clamp tileBrightness here
   
    drawTile(tile, tileBrightness);
}



EDIT: example, here's a system of two lights, at positions p1 and p2: https://www.desmos.com/calculator/ua4b5gab8f
15  Game Development / Newbie & Debugging Questions / Re: Tile by tile lighting how would i do this on: 2015-06-22 19:57:40
How about just a linear interpolation?

1  
2  
3  
4  
5  
double maxDistance = 4.0;

...

alpha =  Math.max(0, 1 - distance / maxDistance)


https://www.desmos.com/calculator/2okgm0p5gl

EDIT: you can also try messing around with the curvature for various fall-off types: https://www.desmos.com/calculator/jfi7kcyu9j
16  Game Development / Newbie & Debugging Questions / Re: Tile by tile lighting how would i do this on: 2015-06-22 05:17:00
If you haven't profiled and seen that these color objects are causing a performance problem, then trying to avoid creating them would be a waste of time.
Besides, holding a cache of potentially thousands/millions of color objects (if you really need full RGB range) would most likely be a much larger strain on 'resources' then just creating them on the fly.
17  Game Development / Newbie & Debugging Questions / Re: Background Music System: How do i do this? on: 2015-06-21 20:31:48
BTW, TinySound doesn't require any multithreading on your part, its mixer runs in its own thread: https://github.com/finnkuusisto/TinySound/blob/master/src/kuusisto/tinysound/TinySound.java#L154-L160

Example: http://pastebin.java-gaming.org/dced04e902c15
18  Game Development / Newbie & Debugging Questions / Re: Background Music System: How do i do this? on: 2015-06-21 19:31:36
It says all of this right in the few sentences of the TinySound.java docs:

Quote
In order to use the TinySound system, it must be initialized. After that, Music and Sound objects can be loaded and used. When finished with the TinySound system, it must be shutdown.
19  Game Development / Newbie & Debugging Questions / Re: Background Music System: How do i do this? on: 2015-06-21 19:19:29
Check to see if your Sounds are null, quite easy to get the resource string wrong.
TS.init() and shutdown() should only happen once each, at beginning and end of app.
20  Game Development / Newbie & Debugging Questions / Re: Tile by tile lighting how would i do this on: 2015-06-21 18:55:38
Ninja'd by opiop, but yeah just use a plain white pixel as a texture, tint and set size + transparency at each call to spritebatch.

And please, use that wonderful thing called Pastebin Pointing

If it's his own thread specifically for this issue, I think longer code snippets are fine. Besides, none of these are even over 100 lines.
21  Game Development / Game Mechanics / Re: Inheritance Headache on: 2015-06-20 23:01:10
Looks like you're just about at the point where inheritance is more of a problem then a solution and something like a component entity system starts being beneficial:
http://gamedev.stackexchange.com/questions/31473/role-of-systems-in-entity-systems-architecture
http://gameprogrammingpatterns.com/component.html

Favor composition over inheritance.
22  Game Development / Newbie & Debugging Questions / Re: Background Music System: How do i do this? on: 2015-06-20 22:39:41
Add the TS jar into your project classpath, in eclipse this is the 'build path.' There are various equivalent ways of adding a jar to it: http://stackoverflow.com/questions/2727669/how-can-i-add-a-jar-to-my-build-path-in-eclipse
23  Game Development / Newbie & Debugging Questions / Re: Background Music System: How do i do this? on: 2015-06-20 22:30:27
Quick tip with TinySound, really any such media interface: if the sound to be played is long (such as a soundtrack) then strongly consider streaming it rather than loading the whole thing into memory up front. See http://finnkuusisto.github.io/TinySound/ and the streamFromFile options in the load* methods in http://finnkuusisto.github.io/TinySound/doc/
Really easy to not know about this and suddenly wonder why your app is using several gigs of RAM.
24  Game Development / Newbie & Debugging Questions / Re: Background Music System: How do i do this? on: 2015-06-20 22:17:56
I find TinySound useful, example usage including project setup: http://www.java-gaming.org/topics/getting-tinysound-to-play-oggs-in-a-jar/36100/msg/342436/view.html#msg342436

You can at least use it until you need something more sophisticated.
25  Game Development / Game Mechanics / Re: Best way to debug? on: 2015-06-19 00:20:29
Yes.

Alias: copy a pointer.
Shallow: copy contents of object into new object, return pointer to new object. (which may contain aliased fields)
Deep: copy contents of object, recursively shallow copy any references in the contents, return pointer to new object hierarchy containing no aliases to original hierarchy anywhere.
26  Game Development / Game Mechanics / Re: Best way to debug? on: 2015-06-19 00:09:48
In his code: copy = shooter; is not a shallow copy, it's an alias (Java's standard operating procedure).
27  Game Development / Game Mechanics / Re: Best way to debug? on: 2015-06-19 00:06:09
It's not called a shallow copy...


a = new ...();
b = a;               // alias
c = a.shallowCopy(); // shallow
d = a.deepCopy();    // deep

+---+             +---+
| 1 |<--------+   | 3 |
+-^-+         |   +-^-+
  |           |     |
+---+       +---+ +---+
| 1 |<--+   | 2 | | 3 |
+-^-+   |   +-^-+ +-^-+
  |     |     |     |
  a     b     c     d  


EDIT: that copy constructor is an example of a shallow copy. A deep copy (e.g. a correctly implemented clone()) also recursively copies reference-type fields.
28  Game Development / Game Mechanics / Re: Best way to debug? on: 2015-06-18 23:44:31
Quote
this makes a shallow copy cause it's not making a new shooter?

No. There is no copy at all.
29  Game Development / Game Mechanics / Re: Best way to debug? on: 2015-06-18 23:09:42
You know you can write a simple program to test things like that, right?

Quote
If I pass something, let's say an ArrayList in like the constructor, and set it to a local variable, will that local variable always have the most up to date version of the ArrayList? I thought it would be a copy..

Rule of thumb for how Java operates: no instance of a reference type is ever copied unless you do it explicitly somehow (e.g. clone() or a custom deep copy function).

This is plainly seen when you realize that the constructor parameter and local variable you mention are not the arraylist itself, but pointers to it. You're assigning the local variable pointer to point at some list, not copying the list.
30  Discussions / Miscellaneous Topics / Re: What IDE colour theme do you use? on: 2015-06-17 19:31:48
Interesting. I do suffer with my eyes a lot (Wanders off to look at dark themes)

Also look at (heh) f.lux if you haven't.
Set it to the 1 hour transition period and you don't even notice after a while.
Turn it off while doing graphics work though.
Pages: [1] 2 3 ... 72
 
deepthought (24 views)
2015-06-30 15:39:44

deepthought (26 views)
2015-06-30 15:39:09

deepthought (33 views)
2015-06-30 15:36:52

Za\'Anzabar (21 views)
2015-06-29 05:44:54

TritonDreyja (36 views)
2015-06-24 17:10:40

CopyableCougar4 (33 views)
2015-06-23 00:34:45

BurntPizza (37 views)
2015-06-21 20:36:46

cookiecompiler (80 views)
2015-06-11 15:42:53

cookiecompiler (44 views)
2015-06-11 15:41:14

NegativeZero (72 views)
2015-06-11 09:49:18
How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14
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!