Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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  
  3DzzD - Applet Boot - source code  (Read 7458 times)
0 Members and 1 Guest are viewing this topic.
Offline DzzD
« Posted 2009-04-23 18:58:50 »





LASTEST VERSION HERE : http://www.java-gaming.org/topics/3dzzd-applet-boot-v2-updated/22239/view.html






EDIT :

look here for the lastest version :

http://www.java-gaming.org/topics/3dzzd-applet-boot-source-code/20341/msg/166925/view.html#msg166925










It will be part of the next 3DzzD release but as this one is not yet ready and also beccause it can be used separatly, here it is.

http://demo.dzzd.net/Test/CAR.html

How to use it :

Put Boot.class, Boot$AppletLoader.class and an Image BLANK.GIF (wich will be the Java splash for recent JVM) on your remote server and replace BOOTCLASS parameter with your own applet class name.

I recommend to not pack it in a jar

The animation will play until the init method of the Applet return, so you may do all your initialisation and loading stuff inside the constructor or the init() method.

Dowload Java 1.1 binary


HTML code :

<APPLET      code   = "Boot.class"
       width   = "600"
       height   = "400"
       MAYSCRIPT>
<PARAM NAME="IMAGE" VALUE="BLANK.GIF">
<PARAM NAME="BOOTBGCOLOR" VALUE="eeeeee">
<PARAM NAME="BOOTCLASS" VALUE="Viewer3D">      
</APPLET>

Java sources :

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  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
/*
* This file is part of 3DzzD http://dzzd.net/.
*
* Released under LGPL
*
* 3DzzD is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 3DzzD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with 3DzzD.  If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2005 - 2009 Bruno Augier
*/





import java.awt.*;
import java.applet.*;
import java.awt.image.*;

/**
 * Boot
 *
 * An Applet Boot class
 *
 * @author Bruno Augier
 * @website: http://dzzd.net/
 * @version 1.00 2008/04/15
 */

public final class Boot extends Applet implements Runnable,AppletStub
{      
   private int nbStart=0;
   private Graphics g;      
   private int bgColor;
   Container c;
   
   public boolean loaded;
   public Thread t;
   public Applet a;
     
   private int w()
   {
      return this.getSize().width;
   }
   
   private int h()
   {
      return this.getSize().height;
   }      
   
   private int nb=0;
   private long lTime;
   
   public void run()
   {
               
      try
      {
         this.lTime=System.currentTimeMillis();
         while(!this.loaded)
         {
            int cx=this.w()>>1;
            int cy=this.h()>>1;
            for(int n=0;n<180;n++)
            {
               int r=255;
               int v=165+(n>>1);
               int b=75+n;
               this.g.setColor(new Color(b|(v<<8)|(r<<16)));
               double a=(nb-n*1.1)*Math.PI/180.0;
               double ca=Math.cos(a);
               double sa=Math.sin(a);
               int x=cx+(int)(8.0*ca);
               int y=cy+(int)(8.0*sa);
               
               int x2=cx+(int)(12.0*ca);
               int y2=cy+(int)(12.0*sa);
               this.g.drawLine(x,y,x2,y2);
            }
            nb+=6;
            long time=System.currentTimeMillis();
            long delta=time-lTime;
            lTime=time;
            if(delta<20)
               Thread.sleep(20-delta);
            Thread.sleep(1);  
         }
      }
      catch(InterruptedException ie)
      {
      }
     
   }
   
   public void paint(Graphics g)
   {
     
      if(this.nbStart++==0)
      {  
         String sBgColor=this.getParameter("BOOTBGCOLOR");
         if(sBgColor!=null)
         {
            try
            {
               this.bgColor=Integer.parseInt(sBgColor,16);
            }
            catch(Exception e)
            {
               e.printStackTrace();
            }
           
         }  
         this.c=this.getParent();
         this.g=this.c.getGraphics();
         this.c.remove(this);  
                     
         this.loaded=false;
         this.t=new Thread(this);
         this.t.start();
         
         
         String bootClass=this.getParameter("BOOTCLASS");
         new AppletLoader(bootClass);
      }
      Color color=new Color(this.bgColor);
      this.c.setBackground(color);  
      this.g.setColor(color);
      this.g.fillRect(0,0,w(),h());
     
      super.paint(g);
     
   }
   
   private class AppletLoader implements Runnable
   {
      String name;
     
      AppletLoader(String name)
      {      
         this.name=name;
         Thread t=new Thread(this);
         t.start();  
      }
     
      public void run()
      {
         
         try
         {
            Thread.sleep(2000);
            a=(Applet)Class.forName(this.name).newInstance();
           
            {  
               a.setStub(Boot.this);
               a.setSize(w(),h());
               a.init();
               c.add(a);
               a.start();
            }  
                       
            loaded=true;
            t.join();
                     
         }
         catch(Exception e)
         {
            e.printStackTrace();
         }
           
      }
     
   }
   
   public void start()
   {
      if(this.a!=null)
         this.a.start();
   }
   
   public void stop()
   {
      if(this.a!=null)
         this.a.stop();
   }
   
   public void destroy()
   {
      if(this.a!=null)
         this.a.destroy();
      this.a=null;
   }
   /*
   public void update(Graphics g)
   {
     
   }*/

     
   public void appletResize(int width, int height)
   {
      if(this.a!=null)
         this.a.setSize(width,height);
   }
}

Offline bobjob

JGO Knight


Medals: 10
Projects: 4


David Aaron Muhar


« Reply #1 - Posted 2009-04-23 19:01:05 »

http://demo.dzzd.net/test/IPHONE.html
error 404 http couldnt be found

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline DzzD
« Reply #2 - Posted 2009-04-23 19:09:06 »

http://demo.dzzd.net/test/IPHONE.html
error 404 http couldnt be found

oups sorry wrong URL Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline bobjob

JGO Knight


Medals: 10
Projects: 4


David Aaron Muhar


« Reply #3 - Posted 2009-04-23 19:19:00 »

seemed to run smooth enough.

I did notice few artifacts, when spinning the car around (attached image) .

would strictfp help this? or is it calculated with double precision?


anyway if someone really didnt want artifacts im sure they could just render an extremely low poly version first, then render the high quality one.


My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Offline DzzD
« Reply #4 - Posted 2009-04-23 19:25:59 »

seemed to run smooth enough.

I did notice few artifacts, when spinning the car around (attached image) .

would strictfp help this? or is it calculated with double precision?


anyway if someone really didnt want artifacts im sure they could just render an extremely low poly version first, then render the high quality one.



thanks for testing,

it use double precision but that's a bug, I am currently modifyng the soft renderer for the next release and it make more artefact than before as I dont finished modifications yet

Offline SimonH
« Reply #5 - Posted 2009-04-23 19:31:24 »

In FF java6 with a clear cache I get;

approx 5 seconds white box
approx 2 seconds white box with black border
approx 15 seconds loading animation
car appears & applet runs smoothly (looks very nice!)

After the app is cached the white box no longer appears.

People make games and games make people
Offline DzzD
« Reply #6 - Posted 2009-04-23 19:40:34 »

thks for the detailled answer

Quote
approx 5 seconds white box
that's the BLANK.GIF image wich can be replaced by any 2*2 color image (I let white for debug purpose)

NB: this thread is a pool, dont hesitate to vote plzzz Smiley

Offline h3ckboy

JGO Coder


Medals: 5



« Reply #7 - Posted 2009-04-23 19:47:44 »

it is loading forever, It hasnt started :/
Offline DzzD
« Reply #8 - Posted 2009-04-23 19:48:45 »

it is loading forever, It hasnt started :/
could you, plz, provide the console content ?

Offline h3ckboy

JGO Coder


Medals: 5



« Reply #9 - Posted 2009-05-01 11:58:45 »

works fine now  Huh
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline DzzD
« Reply #10 - Posted 2009-05-01 17:36:23 »

works fine now  Huh

so update your vote Smiley

Offline fireside

Senior Newbie





« Reply #11 - Posted 2009-05-01 19:15:19 »

On a phone modem, you just see a blank window for quite a while before the little rotating circle thing comes up.  It could be confusing if there happens to be one other person in the world besides me that doesn't have a high speed connection.
Offline mh114

Junior Duke





« Reply #12 - Posted 2009-05-02 15:55:38 »

Worked smoothly in Vista, Java 6u13. Smiley I'll try it in Linux later.

Offline h3ckboy

JGO Coder


Medals: 5



« Reply #13 - Posted 2009-05-03 10:25:06 »

so update your vote Smiley
'
can't I dont think you allowed it?
Offline mh114

Junior Duke





« Reply #14 - Posted 2009-05-04 04:49:48 »

Worked nicely in Ubuntu 9.04 as well. Good work!

Offline DzzD
« Reply #15 - Posted 2009-05-04 22:54:32 »

Quote
can't I dont think you allowed it?
oups, I dont know how to do this....

Quote
Worked smoothly in Vista, Java 6u13.  I'll try it in Linux later.
Worked nicely in Ubuntu 9.04 as well. Good work!
double cool !  Cool

Offline DzzD
« Reply #16 - Posted 2009-05-29 18:07:32 »

Online Test :

http://demo.dzzd.net/View3D/IPHONE.html

Dowload Java 1.1 binary

special thanks to jojoh for pointing out some bugs


HTML code :

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  
<APPLET      code   = "Boot.class"
       width   = "600"
       height   = "400"
       MAYSCRIPT>
<PARAM NAME="IMAGE" VALUE="BLANK.GIF">
<PARAM NAME="BOOTBGCOLOR" VALUE="eeeeee">
<PARAM NAME="BOOTCLASS" VALUE="Viewer3D">      
<PARAM NAME="BOOTTOSTART" VALUE="FALSE">

<!-- START OF CUSTOM JAVA ERROR MESSAGE -->

<TABLE STYLE="WIDTH: 500px;
               HEIGHT: 450px;
               BACKGROUND-COLOR: #000000"
>
  <TBODY>
   <TR>
    <TD STYLE="TEXT-ALIGN: center">
     <A href="http://java.com/">
      <IMG STYLE="BORDER: 0px;"
           src="JAVA.JPG">
     </A>
    </TD>
   </TR>
 </TABLE>

<!-- END OF CUSTOM JAVA ERROR MESSAGE -->

</APPLET>



Java code :

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  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
/*
* This file is part of 3DzzD http://dzzd.net/.
*
* Released under LGPL
*
* 3DzzD is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 3DzzD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with 3DzzD.  If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2005 - 2009 Bruno Augier
*/



import java.awt.*;
import java.applet.*;
import java.awt.image.*;

/**
 * Boot
 *
 * An Applet Boot class
 *
 * @author Bruno Augier
 * @website: http://dzzd.net/
 * @version 1.00 2008/04/15
 */

public final class Boot extends Applet implements Runnable,AppletStub
{      
   private volatile int nbStart=0;
   private volatile Graphics g;      
   private volatile int bgColor;
   private volatile Container c;
   private volatile boolean loaded;
   private volatile Thread t;
   private volatile Applet a;
   private volatile boolean bootToStart=false;
   
     
   private int w()
   {
      return this.getSize().width;
   }
   
   private int h()
   {
      return this.getSize().height;
   }      
   
   private int nb=0;
   private long lTime;
   public void run()
   {
               
      try
      {
         this.lTime=System.currentTimeMillis();
         while(!this.loaded)
         {
            int cx=this.w()>>1;
            int cy=this.h()>>1;
            for(int n=0;n<180;n++)
            {
               int r=255;
               int v=165+(n>>1);
               int b=75+n;
               this.g.setColor(new Color(b|(v<<8)|(r<<16)));
               double a=(nb-n*1.1)*Math.PI/180.0;
               double ca=Math.cos(a);
               double sa=Math.sin(a);
               int x=cx+(int)(8.0*ca);
               int y=cy+(int)(8.0*sa);
               
               int x2=cx+(int)(12.0*ca);
               int y2=cy+(int)(12.0*sa);
               this.g.drawLine(x,y,x2,y2);
            }
            nb+=6;
            long time=System.currentTimeMillis();
            long delta=time-lTime;
            lTime=time;
            if(delta<20)
               Thread.sleep(20-delta);
            Thread.sleep(1);  
         }
      }
      catch(InterruptedException ie)
      {
         ie.printStackTrace();
      }
     
   }
   
   public void paint(Graphics g)
   {
     
      if(this.nbStart++==0)
      {  
         String sBgColor=this.getParameter("BOOTBGCOLOR");
         if(sBgColor!=null)
         {
            try
            {
               this.bgColor=Integer.parseInt(sBgColor,16);
            }
            catch(Exception e)
            {
               e.printStackTrace();
            }
           
         }  
         this.c=this.getParent();
         this.g=this.c.getGraphics();
         this.c.remove(this);  
                     
         this.loaded=false;
         this.t=new Thread(this);
         this.t.start();
         
         String bootToStart=this.getParameter("BOOTTOSTART");
         if(bootToStart!=null && bootToStart.equals("TRUE"))
            this.bootToStart=true;
         String bootClass=this.getParameter("BOOTCLASS");  
         
         new AppletLoader(bootClass);
      }
      Color color=new Color(this.bgColor);
      this.c.setBackground(color);  
      this.g.setColor(color);
      this.g.fillRect(0,0,w(),h());
     
      super.paint(g);
     
   }
   
   private class AppletLoader implements Runnable
   {
      String name;
     
      AppletLoader(String name)
      {      
         this.name=name;
         Thread t=new Thread(this);
         t.start();  
      }
     
      public void run()
      {
         
         try
         {
            Thread.sleep(1000);
            Boot.this.a=(Applet)Class.forName(this.name).newInstance();
            Boot.this.a.setVisible(false);
           
            {  
               Boot.this.a.setStub(Boot.this);
               Boot.this.c.add(Boot.this.a);
               Boot.this.a.resize(new Dimension(Boot.this.w(),Boot.this.h()));
               
               Boot.this.a.init();  
               if(!Boot.this.bootToStart)
                  Boot.this.a.setVisible(true);            
               Boot.this.a.start();
               if(Boot.this.bootToStart)
                  Boot.this.a.setVisible(true);
            }  
                       
            Boot.this.loaded=true;
            Boot.this.t.join();
                     
         }
         catch(Exception e)
         {
            e.printStackTrace();
         }
           
      }
     
   }
   
   public void start()
   {
      if(this.a!=null)
         this.a.start();
   }
   
   public void stop()
   {
      if(this.a!=null)
         this.a.stop();
   }
   
   public void destroy()
   {
      if(this.a!=null)
         this.a.destroy();
      this.a=null;
   }
   /*
   public void update(Graphics g)
   {
     
   }*/

     
   public void appletResize(int width, int height)
   {
      if(this.a!=null)
         this.a.setSize(width,height);
   }
}

Offline jojoh

JGO Knight


Medals: 5
Projects: 7


games4j.com


« Reply #17 - Posted 2009-09-09 00:55:06 »

Hi again!

I was planning to use this great tool more on games4j.com, but was worried about some stability issues, that I couldn't really test, since it only appeared on OS X (as far as I know). I wasn't sure if it was this tool or ogg loader combined with multithreading. Seems like it might have been a bit of both. I finally managed to fool someone to let me test crashing his OS X browser a bit, and it seems like running a java 6 applet using this Applet Boot on OS X with java 1.5 on it will freeze the browser (safari and ff tested), and you will have to kill the browser. Only a gray or white space is displayed for the applet as well, and not the error message.

Not sure if there is anything to do about it, but probably good to know about, and would be good to know if someone can confirm that this is the case, and if there is a workaround.

Offline DzzD
« Reply #18 - Posted 2009-09-09 08:31:54 »

Hi again!

I was planning to use this great tool more on games4j.com, but was worried about some stability issues, that I couldn't really test, since it only appeared on OS X (as far as I know). I wasn't sure if it was this tool or ogg loader combined with multithreading. Seems like it might have been a bit of both. I finally managed to fool someone to let me test crashing his OS X browser a bit, and it seems like running a java 6 applet using this Applet Boot on OS X with java 1.5 on it will freeze the browser (safari and ff tested), and you will have to kill the browser. Only a gray or white space is displayed for the applet as well, and not the error message.

Not sure if there is anything to do about it, but probably good to know about, and would be good to know if someone can confirm that this is the case, and if there is a workaround.


I think that you can easily see what is going wrong by modifying the following part of code :
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
               Boot.this.a.setStub(Boot.this);
               Boot.this.c.add(Boot.this.a);
               Boot.this.a.resize(new Dimension(Boot.this.w(),Boot.this.h()));
               
               Boot.this.a.init();  
               if(!Boot.this.bootToStart)
                  Boot.this.a.setVisible(true);            
               Boot.this.a.start();
               if(Boot.this.bootToStart)
                  Boot.this.a.setVisible(true);


a first thing to do would be to put the whole inside a try catch throwable
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
      
try
{
Boot.this.c.add(Boot.this.a);
               Boot.this.a.resize(new Dimension(Boot.this.w(),Boot.this.h()));
               
               Boot.this.a.init();  
               if(!Boot.this.bootToStart)
                  Boot.this.a.setVisible(true);            
               Boot.this.a.start();
               if(Boot.this.bootToStart)
                  Boot.this.a.setVisible(true);
}
catch (Throwable t)
{
=> draw a message on screen to the user to tell him that the applet have a problem
}


this can help in some case like for example if the user have an older JVM than the one requiered for the Applet because the booter will just start fine on any JVM  (because it is 1.1 compatible) and an exception will be throw, this will avoid an hugly grey or white panel without any information to appear.

another thing you can add in this code bock is logging informations at each step, this way it will be easy to found what is going wrong, optionaly you can also add a timeout that make a message appear after a given amount of time saying that the applet could not start.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
try
{
Boot.this.c.add(Boot.this.a);
               Boot.this.a.resize(new Dimension(Boot.this.w(),Boot.this.h()));
               
//Log before init

               Boot.this.a.init();  
               if(!Boot.this.bootToStart)
                  Boot.this.a.setVisible(true);  

//Log before start
         
               Boot.this.a.start();
               if(Boot.this.bootToStart)
                  Boot.this.a.setVisible(true);
//Log after start

}
catch (Throwable t)
{
=> draw a message on screen to the user to tell him that the applet have a problem
}



last but not least I woul recommend to add a nice flash GUI explaining how to install java inside the Applet tag, this way if a user come without any JVM the flash will be displayed and will provide a user friendly way to alert user to install java

something like
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
<APPLET .....

<PARAM ....
<PARAM ....


<FLASH TAG src=noJavaGUI.swf .....>

</FLASH TAG>

</APPLET>

Offline jojoh

JGO Knight


Medals: 5
Projects: 7


games4j.com


« Reply #19 - Posted 2009-09-10 13:59:18 »

Thanks for the suggestions.

I just had a brief look and though that it should all have been taken care of by the try{}catch in the original code, but that is catching Exception and not Throwable, so that was the problem. You were almost right about the changes needed, but the problem is already at the line:
1  
   Boot.this.a = (Applet) Class.forName(this.name).newInstance();


I also made a small change so that it will display a message to the user if it has java 1.1 or better, but not what requested by the applet. That is, if for example a user has java 1.4, and tries to view a 1.5 Applet, a message will be displayed (by applet boot), telling him to install latest version of java, in order to view the applet and then opens java.com in another tab in the browser.

I have not been able to thoroughly test, this, so any reports on how it works would be great (especially for OS X and linux). It is currently in use at:
Dirami Conquest (currently java 1.5)
It seems like there is a pause when it reads libs or the certificates for playing ogg, but that is probably out of hands of the Applet Boot.
Any feedback on the game here

This is the change I did to the code:
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  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
/*
 * This file is part of 3DzzD http://dzzd.net/.
 *
 * Released under LGPL
 *
 * 3DzzD is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * 3DzzD is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with 3DzzD.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Copyright 2005 - 2009 Bruno Augier
 */


import java.applet.Applet;
import java.applet.AppletContext;
import java.applet.AppletStub;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.net.URL;

/**
 * Boot
 *
 * An Applet Boot class
 *
 * This file has been changed by Joakim Johnson. Added the not sufficient java stuff and a try{}catch(Throwable)
 * @author Bruno Augier
 * @website: http://dzzd.net/
 * @version 1.00 2008/04/15
 */

public final class Boot extends Applet implements Runnable, AppletStub {
   private volatile int nbStart = 0;
   private volatile Graphics g;
   private volatile int bgColor;
   private volatile Container c;
   private volatile boolean loaded;
   private volatile boolean notSufficientJava = false;
   private volatile Thread t;
   private volatile Applet a;
   private volatile boolean bootToStart = false;

   private int w() {
      return this.getSize().width;
   }

   private int h() {
      return this.getSize().height;
   }

   private int nb = 0;
   private long lTime;

   public void run() {

      try {
         this.lTime = System.currentTimeMillis();
         while (!this.loaded) {
            if(notSufficientJava) {
               this.g.setColor(new Color(255,165,75));
               g.drawString("Please make sure that you have the", w()/2-100, h()/2-30);
               g.drawString("latest version of java installed and activated", w()/2-120, h()/2-10);
            }else {
               int cx = this.w() >> 1;
               int cy = this.h() >> 1;
               for (int n = 0; n < 180; n++) {
                  int r = 255;
                  int v = 165 + (n >> 1);
                  int b = 75 + n;
                  this.g.setColor(new Color(b | (v << 8) | (r << 16)));
                  double a = (nb - n * 1.1) * Math.PI / 180.0;
                  double ca = Math.cos(a);
                  double sa = Math.sin(a);
                  int x = cx + (int) (8.0 * ca);
                  int y = cy + (int) (8.0 * sa);
   
                  int x2 = cx + (int) (12.0 * ca);
                  int y2 = cy + (int) (12.0 * sa);
                  this.g.drawLine(x, y, x2, y2);
               }
               nb += 6;
            }
            long time = System.currentTimeMillis();
            long delta = time - lTime;
            lTime = time;
            if (delta < 20)
               Thread.sleep(20 - delta);
            Thread.sleep(1);
         }
      } catch (InterruptedException ie) {
         ie.printStackTrace();
      }

   }

   public void paint(Graphics g) {

      if (this.nbStart++ == 0) {
         String sBgColor = this.getParameter("BOOTBGCOLOR");
         if (sBgColor != null) {
            try {
               this.bgColor = Integer.parseInt(sBgColor, 16);
            } catch (Exception e) {
               e.printStackTrace();
            }

         }
         this.c = this.getParent();
         this.g = this.c.getGraphics();
         this.c.remove(this);

         this.loaded = false;
         this.t = new Thread(this);
         this.t.start();

         String bootToStart = this.getParameter("BOOTTOSTART");
         if (bootToStart != null && bootToStart.equals("TRUE"))
            this.bootToStart = true;
         String bootClass = this.getParameter("BOOTCLASS");

         new AppletLoader(bootClass);
      }
      Color color = new Color(this.bgColor);
      this.c.setBackground(color);
      this.g.setColor(color);
      this.g.fillRect(0, 0, w(), h());

      super.paint(g);

   }

   private class AppletLoader implements Runnable {
      String name;

      AppletLoader(String name) {
         this.name = name;
         Thread t = new Thread(this);
         t.start();
      }

      public void run() {

         try {
            Thread.sleep(1000);
            try {
               Boot.this.a = (Applet) Class.forName(this.name).newInstance();
               Boot.this.a.setVisible(false);
               Boot.this.a.setStub(Boot.this);
               Boot.this.c.add(Boot.this.a);
               Boot.this.a.resize(new Dimension(Boot.this.w(), Boot.this.h()));

               Boot.this.a.init();
               if (!Boot.this.bootToStart)
                  Boot.this.a.setVisible(true);
               Boot.this.a.start();
               if (Boot.this.bootToStart)
                  Boot.this.a.setVisible(true);
               Boot.this.loaded = true;
               Boot.this.t.join();
            } catch (Throwable throwable) {
               notSufficientJava=true;
               throwable.printStackTrace();
               Thread.sleep(6000);
               AppletContext a = getAppletContext();
               URL url = new URL("http://java.sun.com/");
               a.showDocument(url, "_blank");
            }

         } catch (Exception e) {
            e.printStackTrace();
         }

      }

   }

   public void start() {
      if (this.a != null)
         this.a.start();
   }

   public void stop() {
      if (this.a != null)
         this.a.stop();
   }

   public void destroy() {
      if (this.a != null)
         this.a.destroy();
      this.a = null;
   }

   /*
    * public void update(Graphics g) {
    *
    * }
    */


   public void appletResize(int width, int height) {
      if (this.a != null)
         this.a.setSize(width, height);
   }
}

Offline DzzD
« Reply #20 - Posted 2009-09-14 23:04:22 »

Quote
I also made a small change so that it will display a message to the user if it has java 1.1 or better, but not what requested by the applet. That is, if for example a user has java 1.4, and tries to view a 1.5 Applet, a message will be displayed (by applet boot), telling him to install latest version of java, in order to view the applet and then opens java.com in another tab in the browser.

I have not been able to thoroughly test, this, so any reports on how it works would be great (especially for OS X and linux). It is currently in use at:
Dirami Conquest (currently java 1.5)
It seems like there is a pause when it reads libs or the certificates for playing ogg, but that is probably out of hands of the Applet Boot.
Any feedback on the game here

work fine with MSJVM Smiley ( opened java.sun.com or something like, you should better redirect to java.com for direct installation )

Offline jojoh

JGO Knight


Medals: 5
Projects: 7


games4j.com


« Reply #21 - Posted 2009-09-15 16:39:40 »

work fine with MSJVM Smiley ( opened java.sun.com or something like, you should better redirect to java.com for direct installation )

Ah, thanks for reminding me! java.com was down for the whole day that I tested it. I thought that Oracle might have changed it's mind about how useful java is.  persecutioncomplex Is back up now, so I will change it back.

It seemed like some os-browser combos wouldn't open up a new tab for

getAppletContext().showDocument(...);

It worked fine using FF and WinXP. Anyone knows what blocks it and if there is a workaround?
It is probably a good idea to print out where to get java in the applet anyway.

Offline DzzD
« Reply #22 - Posted 2009-09-15 16:48:37 »


It seemed like some os-browser combos wouldn't open up a new tab for



I have tested on IE6 so it logically open a new window (cause ie6 dont have tabs Smiley  I keep this configuration : IE6/XP/MSJVM/Java1.6 so I can test compatibility with it because when it run on it it should run fine everywhere )

for tabbed browser I really dont know... but not sure you can do anything to force a tab rather than a window it seems to me that it is more related to browser & java version than to the command showDocument (maybe it exist a special target name  ?)

Offline jojoh

JGO Knight


Medals: 5
Projects: 7


games4j.com


« Reply #23 - Posted 2009-09-30 17:35:40 »

Sorry I missed your reply.

I was probably a bit unclear. The showDocument() doesn't do a thing, no tab, no new browser. I'd be happy with opening a new browser, even though most ppl probably prefer new tab, but no nothin' isn't very good user experience. That could be the fancy pop-up blockers, and I just have to live with displaying a link in the applet.

Offline DzzD
« Reply #24 - Posted 2010-04-12 21:06:14 »

UPDATED VERSION HERE : http://www.java-gaming.org/topics/3dzzd-applet-boot-v2-updated/22239/view.html

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

Longarmx (46 views)
2014-10-17 03:59:02

Norakomi (37 views)
2014-10-16 15:22:06

Norakomi (29 views)
2014-10-16 15:20:20

lcass (32 views)
2014-10-15 16:18:58

TehJavaDev (62 views)
2014-10-14 00:39:48

TehJavaDev (62 views)
2014-10-14 00:35:47

TehJavaDev (52 views)
2014-10-14 00:32:37

BurntPizza (70 views)
2014-10-11 23:24:42

BurntPizza (40 views)
2014-10-11 23:10:45

BurntPizza (82 views)
2014-10-11 22:30:10
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

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!