Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (804)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (868)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Java4K framework WIP / discussion  (Read 9101 times)
0 Members and 1 Guest are viewing this topic.
Offline Riven
Administrator

« JGO Overlord »


Medals: 1371
Projects: 4
Exp: 16 years


Hand over your head.


« Posted 2015-02-26 14:49:07 »

In an effort to breath life back into Java4K, I'm testing the waters with a Java4K platform. I'm sharing this WIP early, and plan to have a ton of revisions, based on your feedback, and/or my gut feeling.

My plan for Java4K is to lower the barrier to entry that haunted the last few years of Java4K. The toolchain required to build a tiny *.jar.pack200.gz was daunting, even for experienced members of the community. A newby would find that his bare bones main-loop would consume ~2500/4096 bytes, while those in possession of said toolchains could fit over 30KB of sourcecode in their 4KB binary. Suffice to say that this played at least some role in the Java4K contest participation rate dropping over the years.

To lower the barrier to entry, we have to make some radical changes to how the contest is setup - to the point where 'Java4K' may be a bit of a misnomer. Instead of focusing on binary size, we will focus on sourcecode size to which asset-sizes will be added. Entries (source + assets) will be limited to, say, 16K of sourcecode, which previously would have yielded a ~4K compressed binary for somebody with a reasonably advanced toolchain.
The result will be compiled & packed (serverside on JGO) in a JAR of which the final size plays no role. Both newbies and experts will likely find such a limit challenging enough to write a decent game with enough features, while still being restricted enough to 'get it done', reducing chances of feature creep.

To lower the barrier to entry even further, I will provide a game-loop, and people simply have to implement render() and/or update(), where a minimalistic valid contest-entry would be like:

MinimalisticEntry.java
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
-public class MinimalisticEntry extends Java4kRev1 // which extends javax.swing.JPanel
+public class MinimalisticEntry extends Java4kRev2 // which extends java.awt.Canvas
{
   int x;

   // called 60x per second
   public void update() { // move across screen at constant rate, regardless of framerate
      if(++x >= w) x = 0; // 'w' & 'h' provided by superclass
   }

   // called at most 60x per second
   public void render(Graphics2D g) {
      g.setColor(Color.YELLOW);
      g.drawRect(x, mouse.y, 64, 64); // 'mouse' provided by superclass
   }
}


Java4kRev#.java
(superclass of your entries)
Rev 2http://pastebin.java-gaming.org/154eb0e2a231eBackend now uses active rendering
Rev 1http://pastebin.java-gaming.org/e71548e1b2e1aInitial dump



TODO:
  • Add Keyboard support (alongside current Mouse support)
  • Add active-rendering backend, as opposed to current EDT piggyback/hack
  • Add support for identifying mouse buttons

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline Riven
Administrator

« JGO Overlord »


Medals: 1371
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2015-02-26 14:49:18 »

A slightly more elaborate entry

OddEntry.java
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  
import java.awt.*;
import net.indiespot.java4k.Java4kRev1;

public class OddEntry extends Java4kRev1 {
   @Override
   public void render(Graphics2D g) {
      // print instructions
      g.setColor(new Color(128, 64, 128));
      g.drawString("Drag the mouse a little...", 8, 20);

      // draw something mesmerizing for average Joe
      g.setColor(new Color(0, 64, 128));
      int b, r, a, c, q, t;
      for (r = 150; r >= 30; r -= 15) {
         t = ((elapsed() + 130_000) / ((200 - r) / 25));
         b = r / 3;
         a = (w - r) / 2;
         c = (h - r) / 2;

         q = (int) (t % (r + b));
         g.drawLine(a + Math.max(0, q - b), c, a + Math.min(r, q), c);

         q = (r + b) - (int) ((t + r) % (r + b));
         g.drawLine(a, c + Math.max(0, q - b), a, c + Math.min(r, q));

         q = (r + b) - (int) ((t + r - b) % (r + b));
         g.drawLine(a + Math.max(0, q - b), c + r, a + Math.min(r, q), c + r);

         q = (int) ((t - r) % (r + b));
         g.drawLine(a + r, c + Math.max(0, q - b), a + r, c + Math.min(r, q));
      }

      if (mouse.dragArea != null) { // 'mouse.dragArea' provided by superclass
         g.setColor(new Color(128, 64, 128));
         Rectangle w = mouse.dragArea;
         g.drawRect(w.x, w.y, w.width, w.height);
      }
   }
}


Result (please note the erratic framerate is caused by the GIF, not the game-loop)
Click to Play

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline Opiop
« Reply #2 - Posted 2015-02-26 15:07:05 »

Very cool, thanks for this. Might try my hand at a "4K" game soon!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
Administrator

« JGO Overlord »


Medals: 1371
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #3 - Posted 2015-02-26 15:12:48 »

Threads in the correct board(s) will automatically have the required forms to manage your contest-entry. Just copy/paste your source, upload your assets and press 'publish', and it will... happen. Visitors will see the *.jar and/or signed applet in the opening post.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline ra4king

JGO Kernel


Medals: 508
Projects: 3
Exp: 5 years


I'm the King!


« Reply #4 - Posted 2015-02-26 16:27:57 »

You're investing a lot of time into this, I'm glad to see this happen. I might finally submit a game for once!

Offline Abuse

JGO Ninja


Medals: 73


falling into the abyss of reality


« Reply #5 - Posted 2015-02-26 17:17:41 »

I realize it's against the principle of the contest, but I guess there's nothing to stop participants from String-encoding compiled code - essentially turning it into a "16KiB minus encoding & instanciation overhead" contest.
Offline Riven
Administrator

« JGO Overlord »


Medals: 1371
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #6 - Posted 2015-02-26 17:21:58 »

Abuse: I don't care really Smiley If people want to be jerks, then so be it. Cranky

Similarly, nothing prevents a contestant from fetching a JAR from the web, and attaching it to the ClassLoader. It's against the spirit and the rules of the competition. If anyone wants to 'win' like that, hoping to get away with it, then I feel sorry for the bastard.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline ags1

JGO Kernel


Medals: 367
Projects: 7


Make code not war!


« Reply #7 - Posted 2015-02-26 17:22:10 »

This looks promising!

Offline NegativeZero

JGO Kernel


Medals: 357
Exp: 1 month or less


Zero but not.


« Reply #8 - Posted 2015-02-26 23:39:44 »

The main reason I never got into J4k was the necessity to use Java2D.
Will this still be a requirement in the new compo?

I don't really want to learn a new API simply to participate in a jam.
Maybe I'm the odd one out though, still using LWJGL2.

Offline Riven
Administrator

« JGO Overlord »


Medals: 1371
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #9 - Posted 2015-02-26 23:43:10 »

Where would/will we draw the line? LWJGL? LibGDX? Any library?

Besides, if you're familiar with LWJGL, and willing to enter a sourcecode restricted contest with LWJGL, then Java2D is peanuts.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CopyableCougar4
« Reply #10 - Posted 2015-02-27 02:04:30 »

I'm excited to see how this goes and maybe participate in my first Java4k Smiley

Either wandering the forum or programming. Most likely the latter Smiley

Github: http://github.com/CopyableCougar4
Offline Gibbo3771

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Reply #11 - Posted 2015-02-27 06:22:55 »

Where would/will we draw the line? LWJGL? LibGDX? Any library?

Besides, if you're familiar with LWJGL, and willing to enter a sourcecode restricted contest with LWJGL, then Java2D is peanuts.

Well libgdx is bloated and lwjgl leaves a lot of work for the developer, not really much in between that I am aware of.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Pages: [1]
  ignore  |  Print  
 
 

 
Riven (581 views)
2019-09-04 15:33:17

hadezbladez (5510 views)
2018-11-16 13:46:03

hadezbladez (2402 views)
2018-11-16 13:41:33

hadezbladez (5772 views)
2018-11-16 13:35:35

hadezbladez (1223 views)
2018-11-16 13:32:03

EgonOlsen (4661 views)
2018-06-10 19:43:48

EgonOlsen (5682 views)
2018-06-10 19:43:44

EgonOlsen (3198 views)
2018-06-10 19:43:20

DesertCoockie (4095 views)
2018-05-13 18:23:11

nelsongames (5115 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08
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!