Java-Gaming.org Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (555)
Games in Android Showcase (150)
games submitted by our members
Games in WIP (602)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 ... 7 8 [9] 10
 81 
 on: 2015-03-02 22:29:09 
Started by Islidius - Last post by Islidius
just messing around with Stereograms and realized how easy it is to do.
(if you dont know what this is here is a link:http://en.wikipedia.org/wiki/Autostereogram)

To see the hidden text focus your eyes behind the Screen. Try to move the focus nearer and wider until you can see the text.

what do you think of it? Can you imagine a game or a model preview with this method?

Here is an example:


Here is the generation code(maybe not the fastest solution):

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  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
package pack;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Random;

import javax.imageio.ImageIO;

public class Main {
   
   BufferedImage img; // final Image
   BufferedImage pattern; // pattern Image
   BufferedImage depth; // depth field (inlcudes text)
   
   int standart = 140; // pattern tile width
   int tile = 100;
   
   Random r = new Random();

   public Main(){
      img = new BufferedImage(500, 500, BufferedImage.TYPE_INT_RGB); // init images
      depth = new BufferedImage(500,500,BufferedImage.TYPE_INT_RGB); // both need to have the same resolution
      pattern = new BufferedImage(standart,standart,BufferedImage.TYPE_INT_RGB);
     
      gen_pattern(); // generate pattern
     
      gen_background(); // store patter to background
     
      gen_foreground(); // gernerate the depth field
     
      gen_stereograph(); // apply the effect
     
      try {
         File output = new File("output.jpg"); // saving the file
         ImageIO.write(img,"jpg",output);
      } catch (IOException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
   }
   
   public void gen_pattern(){ // a standart grayscale noise generator
      for(int i = 0;i<standart;i++){
         for(int j = 0;j<standart;j++){
            int f = r.nextInt(255);
            Color c3 = new Color(f,f,f);
            pattern.setRGB(i, j, c3.getRGB());
         }
      }
   }
   
   public void gen_background(){ // apply pattern to background but only first tile
      for(int i = 0;i<standart;i++){
         for(int j = 0;j<img.getHeight();j++){
            img.setRGB(i, j, pattern.getRGB(i%standart, j%standart));      
         }
      }
   }
   
   public void gen_foreground(){ // generate the depth field
      for(int i = 0;i<depth.getWidth();i++){
         for(int j = 0;j<depth.getHeight();j++){
            Color c1 = new Color(10,100,100);
            depth.setRGB(i, j, c1.getRGB()); // fill with background color
         }
      }
     
      Graphics2D g2d = depth.createGraphics();
      g2d.setColor(new Color(20,60,60));
      g2d.setFont(new Font("Serif",Font.BOLD,150)); // add the text
      g2d.drawString("JGO", 80, 250);
      g2d.dispose();
   }
   
   public void gen_stereograph(){ // the effect
      for(int i = 0;i<img.getWidth();i++){
         for(int j = 0;j<img.getHeight();j++){
            int de = new Color(depth.getRGB(i, j)).getRed(); // getting the depth from the depth image(stored im red component)
            if(i+tile < img.getWidth())img.setRGB(i+tile, j, img.getRGB(i, j)); // repetition of the background
            if(i+tile-de < img.getWidth())img.setRGB(i+tile-de, j, img.getRGB(i, j)); // real stereogram effect
         }
      }
     
   }
   
   public static void main(String[] args){
      new Main();
   }

}


Islidius

 82 
 on: 2015-03-02 22:17:01 
Started by Icecore - Last post by Icecore
spelling, grammar and punctuation
Sry Sad
I try my best

I say simple)
(No selfish crap - only numbers)
"Minecraft passes 100 million registered users, 14.3 million sales on PC"
On 1 who buy game there is 6 ppl who play demo and leave
Rate is 6:1
How many people you know that play demo on site and don’t buy game?
Try find at least 1:1 to this rate, ask friends ^^:
play demo and leave : buy game.

Or explain where this 6 people?)

p.s I try answer everyone.

Easy to take a look at the Members tab above.
http://www.java-gaming.org/index.php?action=mlist
50 members per page, 274 pages -- over 10,000 members, and I'm guesstimating that only a small percentage over 10% have posted in the double digits. 1 or 0 seems to be the most common number of posts per member.
Strange I look 10 pages and max % ppl with number of posts per member. 0-1 on page, I see 50%
Its 1:1
I do something wrong?
Because minecraft have 6:1

Check for fun Smiley
http://www.minecraftforum.net
same max 0-1 Post members per page is 50% = 1:1 ^^

up:sry not press filter Alphabetic
50-75% midle = 3:1

I can write Http scraper to discover real number
But no one belive in my numbers XD

p.s
I don’t want to convince someone
I want to know the truth, how minecraft numbers can be real?

Let f**king write the scraper i am intresting XD

 83 
 on: 2015-03-02 21:51:22 
Started by Icecore - Last post by philfrei
Ugh, Reptilians! I lost an inlaw to D. Icke. Another to Holocaust denial (which is a rather tense chapter in the Storr book as his infiltration into the Irving death camp tour group is subject to being exposed).

I have to admit, I almost lost it myself after seeing "Loose Change". For about 48 hours I was seriously doubting my sanity as the film seemed to make sense. I had to do a lot of additional research to regain my footing. John Farmer's "The Ground Truth" was the antidote to 9/11 Trutherism for me. The FAA transcripts showed that the inconsistent "spin" put forth by the Bush administration PR after that debacle was mostly to protect their behinds for basic ineptitude, not to hide some monstrously diabolical and complicated plot.

The fourth chapter of the Storr book was fascinating. Perception is a lot closer to the philosophical "Platonic" ideal (we project what we know out into the world), than I previously gave credit for. It makes computational sense: handling all the sensory input in real time is very demanding, so the brain fills in, matching the incoming signals with known information. One of the implications: if you don't already know something exists and have an internal concept or model, it will probably be "invisible" (lumped in with background noise), even if it bites you in the butt. Ever notice, for example, when you learn about a new thing, suddenly it seems pops up everywhere? It was there all along.

 84 
 on: 2015-03-02 21:37:53 
Started by ratchet12340 - Last post by basil_
the only thing that sun did not do well is to give us proper control over polling and flushing queues - which is done by the EDT for us.

would be nice to remove EDT all together and just (re)implement it's purpose wherever we'd like .. but then, if most people cannot use the EDT properly right now, how many will be able to write or use a custom implementation ? Wink

good news if they dropped runAndWait() from javaFX. means they're using their own framework properly. nothing stops your from implementing your own runAndWait() method, with a Lock and Condition Wink

 85 
 on: 2015-03-02 21:37:24 
Started by ratchet12340 - Last post by Riven
Modal dialogs do not cause a new Thread to spawn. They create a new Event Queue and Event pump, right on top of the current queue/pump. Think of it as recursion. A stack of queues and pumps, where only the top of the stack is active.

When you have an uncaught exception reaching an event pump callsite, however, a new EDT will be spawned, as the active EDT is considered in a state not worthy to recover.

 86 
 on: 2015-03-02 21:32:39 
Started by Zarkonnen - Last post by Rayvolution
 I use getGraphics all the time and I've never experienced any issues on any OS, nor have any of my users.

Are you using a good version of slick or LWJGL? I don't see why this code snippit should be crashing, aside from you wasting resources recreating the image a million times. But you said the actual game doesn't so that's obviously not the problem.

In your real code, are you doing this:
Graphics g = img.getGraphics()
and use the graphics object or are you calling it the same way you are in your sample code?

 87 
 on: 2015-03-02 21:30:28 
Started by ratchet12340 - Last post by nsigma
What would be the alternative? For the entire GUI to freeze up whenever a dialog was opened? Or for no modal dialogs to be supported?

You're blurring together threads and modality.  There's no reason for dialogs not to be done using asynchronous callbacks - eg. the approach something like jQueryUI uses.  Swing is mostly event driven, so it just seems weird to me that this isn't the approach here.

JavaFX does have an EDT- they just call it the JavaFX Application Thread. And they do have an invokeLater() method, they just call it Platform.runLater()! But it's interesting that they chose not to include a runAndWait() method.

That was what I was trying to say, possibly too cryptically! Grin

 88 
 on: 2015-03-02 20:45:24 
Started by ratchet12340 - Last post by KevinWorkman
I was waiting to see what @KevenWorkman replied first, but there's probably another hacky (but less hacky than above!) way of doing this, without going as far as creating a new Toolkit - run the main game loop on the (well, an*) EDT.  The EventQueue will give you access to events which you can filter and dispatch as you like.

You can do active rendering in a relatively hack-less way by just disabling Swing's painting and using your own thread. But you're right, you'll have to use the invokeLater() to move events from the EDT to your thread- but again, most people who *think* they need to do this, really don't.

* Stupidest threading decision in AWT / Swing is blocking threads and pushing a new EDT / EventQueue when a modal Dialog opens!  Roll Eyes  The above suggestion would break if a Dialog opened.

What would be the alternative? For the entire GUI to freeze up whenever a dialog was opened? Or for no modal dialogs to be supported?

Which is still doing the work on the EDT - invokeAndWait() - the ideal way to make hard to find bugs - there's a reason they left it out of JavaFX!  Wink

JavaFX does have an EDT- they just call it the JavaFX Application Thread. And they do have an invokeLater() method, they just call it Platform.runLater()! But it's interesting that they chose not to include a runAndWait() method.

 89 
 on: 2015-03-02 20:20:15 
Started by Icecore - Last post by Ashedragon
Is... is this supposed to be readable?

 90 
 on: 2015-03-02 20:09:29 
Started by Zarkonnen - Last post by Zarkonnen
It's a native crash Pointing There won't be an Exception.

Anyway, as you are creating an image every frame, you might run out of vRAM, making the texture allocation fail, after which Slick2D might be sending its pixels to a null pointer.

This happens on the very first frame. Sorry if the example is misleading. In-game, I don't recreate the image each time.

Pages: 1 ... 7 8 [9] 10
 
BurntPizza (43 views)
2015-02-27 06:09:35

BurntPizza (33 views)
2015-02-27 05:56:17

Riven (26 views)
2015-02-27 02:34:15

Riven (30 views)
2015-02-27 01:47:26

Riven (32 views)
2015-02-27 01:46:04

BurntPizza (27 views)
2015-02-27 00:52:04

BurntPizza (29 views)
2015-02-27 00:50:29

Riven (47 views)
2015-02-26 23:38:45

Riven (24 views)
2015-02-26 23:37:24

BurntPizza (41 views)
2015-02-26 21:13:04
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

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27
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!