What I did today

@Elsealabs


IntStream
    .range(x, y)
    .filter(i -> i % 2 == 0)
    .forEach(System.out::println); // method reference

Or, according to my forum rank :P


// confused C programmer
public static void printEvens(int start, int end) {
    IntStream
        .iterate(start + 1 & -2, i -> i + 2)
        .limit(((end & -2) - start + 2) >> 1)
        .forEach(System.out::println);
}

@BurntPizza

Oh nice. I didn’t even think about your addition. Method references seem interesting, but I don’t really get the point other than shortening code and making them a little bit easier to read, though maybe someone else knows what their true benefit is. I think I remember @SHC saying something about sticking to Java 8 for his project, specifically for method references.

The system out print in the first place is a result of me trying, but failing, to return the result as some sort of collection or list.

And I definitely don’t understand the second code snippet, haha.

Yeah, they’re pretty much just syntax sugar (not a bad thing): http://baddotrobot.com/blog/2014/02/18/method-references-in-java8/

wrote my vecmath package.
I don’t really understood the Hermite polynomirals interpolation but i was able to copy the formulae :stuck_out_tongue:

i played a mesa boogie express plus 5:50 combo at the local store and now i need one :persecutioncomplex:

Drenius made a truly inspiring quote in the #JGO IRC,

Very nice, now… where did you get the idea to encode that as a PNG? My bandwidth! :stuck_out_tongue:

Yes, this is beautiful… But sadly not too fast :frowning: (although I wouldn’t worry about it as long as everything is working good enough)
Very useful for working with any data and - at least in my opinion - much easier to read than “classical” code as you can see what the query do at first glance.

I made a Dragon Curve renderer. I think that’s enough fractal renderers for now.

I made it display parts of the curve in blue, and it’s cool to see how it flows.

I have watched a few videos and talks on the topic, yet still haven’t gotten a full grasp on it, but I thought somewhere along the line someone mentioned it was heavily optimized under the hood. But I’m not entirely sure.

I haven’t found a really good resource to see all of what java has to offer. I found out about map, filter, reduce, and forEach, through various YouTube tutorials or some JAX talks. But then I see things like collect, mapToObject, and the methods being used in the second part of BurntPizza’s code, that I have no clue what they do. Also I heard someone say currying and I have no clue what that means either.

Hopefully I’ll find a resource that gives a more in-depth overview of the topics.

My first usage of them is in the [icode]Display[/icode] class, creating callbacks for GLFW.


glfwSetWindowPosCallback(window, winPosCallback = GLFWWindowPosCallback((win, xPos, yPos) ->
{
    Display.posX = xPos;
    Display.posY = yPos;
}));

glfwSetCursorPosCallback(window, winCurPosCallback = GLFWCursorPosCallback(Mouse::glfwCursorCallback));
glfwSetScrollCallback(window, winScrollCallback = GLFWScrollCallback(Mouse::glfwScrollCallback));
glfwSetMouseButtonCallback(window, winMouseButtonCallback = GLFWMouseButtonCallback(Mouse::glfwMouseButtonCallback));

This makes code simpler, and also easy to read, because I hate writing anonymous classes and overriding the methods. When the methods we have to override is only one, it makes sense to reduce the amount of code we type and use this lambdas and method references.

The next major usage of method references are in the usage of [icode]GameTimer[/icode] class, but still, in the form of callbacks.


GameTimer timer = new GameTimer(10, TimeUtils.Unit.SECONDS);
timer.setCallback(this::timerOut);
timer.start();

There are also the [icode]Animation[/icode], and the entity classes which makes use of lambdas. Whatever you think of this, but I’m lovin’ it!!

Read the javadocs? http://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html

Also hit up wikipedia. http://en.wikipedia.org/wiki/Functional_programming

Made a bitwise autotiler. Woop.

Implemented the RadialGradiant paint with multiple stops (software rasterizer for now)

Finally added a simple text box that tells you what you’ve just picked up (that brown, semi-transparent thing in the top center). It moves down, stays some seconds, and moves up again…really simple, but i hate to do GUI work, so i postponed this for just too long.

Hold on kids! Method references are way more than sugar. You can define a method signature and have references to methods which match that signature. The simplest usage is you no longer need a one to one mapping of an implementation to class file. The implementation can be anywhere.

really looking forward to debugging enterprise code based on that :wink:

In the big scheme of things, this is really not very impressive, but I’m really happy I finally got some dudes wandering around my spaceship :smiley:

Things start to get real:

https://dl.dropboxusercontent.com/u/1668516/shots/quests/%20shot5.png

On to building the quest campaign selection screen!

Cheers,

Kev

And then I get to work on less fun but equally important bits, UI/menus and quest selection:

https://dl.dropboxusercontent.com/u/1668516/shots/quests/shot6.png

Excuse typos in text!

Cheers,

Kev