Since the applets no longer work. I have decided to stop programming in Java. I never really gotten used to Java.
I will keep programming but in another language. I was thinking of buying Play Basic but for the moment I do my programming exercises in Blitz Basic.
(edit:)
I think the google site is returning errorous data from the applets. Maybe this will go away.
Learning how to program/code video games step by step in Java. Platformers, Shooters, Turn Based Strategy, Real Time Strategy.
dinsdag 19 juni 2012
maandag 11 juni 2012
Java applets do not work anymore on my pc
I have tried firefox, internet explorer and google chrome but the applets do not show anymore. Also the browsers freeze when I load the pages. This happened before but not with all the browsers. I have no idea what I can do to fix it. I will try to look up what the problem might be.
edit :
I could not find any information yet. I have also tried reinstalling the java runtime. This did not fix it. I also tried another computer and this gives the same error. Also older applet that used to work did not work anymore. I get a magic number error with the applets when they do load. I hope this problem will fix itself in the future. As I have no idea what to do.
edit :
I could not find any information yet. I have also tried reinstalling the java runtime. This did not fix it. I also tried another computer and this gives the same error. Also older applet that used to work did not work anymore. I get a magic number error with the applets when they do load. I hope this problem will fix itself in the future. As I have no idea what to do.
Manhattan Distance example
Manhattan distance example. Move the mouse over the applet to see the distance change.
import java.awt.*;
import java.applet.*;
public class manhattandistanceexample001 extends Applet implements Runnable {
// Graphics for double buffering.
Graphics bufferGraphics;
Image offscreen;
int mousex = 0;
int mousey = 0;
public void init() {
setBackground(Color.black);
offscreen = createImage(getSize().width,getSize().height);
bufferGraphics = offscreen.getGraphics();
new Thread(this).start();
}
public void run() {
for(;;) { // animation loop never ends
repaint();
try {
Thread.sleep(10);
}
catch (InterruptedException e) {
}
}
}
public boolean mouseMove(Event e, int x, int y){
mousex = x;
mousey = y;
return true;
}
public void update(Graphics g){
bufferGraphics.clearRect( 0 , 0 , getSize().width , getSize().width );
bufferGraphics.setColor( Color.red );
bufferGraphics.drawString( "Manhattan Distance " , 10 , 10 );
for ( int y = 0 ; y < 240/32 ; y++ ){
for ( int x = 0 ; x < 320/32 ; x++ ){
bufferGraphics.drawRect( x * 32 , y * 32 , 32 , 32 );
int dist = mdist( mousex / 32 , mousey / 32 , x , y );
bufferGraphics.drawString( "" + dist , x * 32 , y * 32 + 16 );
}
}
g.drawImage(offscreen,0,0,this);
}
public int mdist( int x1 , int y1 , int x2 , int y2 ){
return Math.abs( x2 - x1 ) + Math.abs( y2 - y1 );
}
}
Euclidean Distance example
Euclidean distance example. Move the mouse over the applet to see the distance change.
import java.awt.*;
import java.applet.*;
public class euclideandistanceexample001 extends Applet implements Runnable {
// Graphics for double buffering.
Graphics bufferGraphics;
Image offscreen;
int mousex = 0;
int mousey = 0;
public void init() {
setBackground(Color.black);
offscreen = createImage(getSize().width,getSize().height);
bufferGraphics = offscreen.getGraphics();
new Thread(this).start();
}
public void run() {
for(;;) { // animation loop never ends
repaint();
try {
Thread.sleep(10);
}
catch (InterruptedException e) {
}
}
}
public boolean mouseMove(Event e, int x, int y){
mousex = x;
mousey = y;
return true;
}
public void update(Graphics g){
bufferGraphics.clearRect( 0 , 0 , getSize().width , getSize().width );
bufferGraphics.setColor( Color.red );
bufferGraphics.drawString( "Euclidean Distance " , 10 , 10 );
for ( int y = 0 ; y < 240/32 ; y++ ){
for ( int x = 0 ; x < 320/32 ; x++ ){
bufferGraphics.drawRect( x * 32 , y * 32 , 32 , 32 );
int dist = edist( mousex / 32 , mousey / 32 , x , y );
bufferGraphics.drawString( "" + dist , x * 32 , y * 32 + 16 );
}
}
g.drawImage(offscreen,0,0,this);
}
public int edist( int x1 , int y1 , int x2 , int y2 ){
return (int)Math.sqrt( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) );
}
}
zaterdag 2 juni 2012
The blog still works.
It looks like the email I got from blogger support was wrong. The blog still works. I have 2 examples which I still need to place on the weblog. These are distance formula's examples. I am also stil thinking of what to program next. Though it is summer and I spend a lot of time outside. I have not programmed a lot. But I am reading programming books. I have an old Java 2 book which I am curently reading.
Abonneren op:
Posts (Atom)