Hi,
I want to make a game that I saw in internet but via applet code (and with move counter).

The game is
http://leepoint.net/notes-java/examples/games/slidepuzzle/slidepuzzle.html

Could someone help me please ???

Recommended Answers

All 4 Replies

anybody ???

what do you want us to do? write the code and paste it here?
the point of this forum is to give you the chance to write it yourself, and ask questions about where you're stuck.

so, how far are you with your coding?

what do you want us to do? write the code and paste it here?
the point of this forum is to give you the chance to write it yourself, and ask questions about where you're stuck.

so, how far are you with your coding?

Far away unfortunately ... :(

My code is :

import javax.swing.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.*; 

public class SApplet extends Applet implements ActionListener {
  TextField input,output;
  Label label1,label2, label3, label4, label5, label6;
  JButton[] buttons = new JButton[9];
  JLabel lbl;
  int num, sum = 0,i;
  int[] test = {2,1,3,8,7,5,6,4,0};
  int metrhths = 0;
  Label metrhthsl;
  
  public void init(){
      GridLayout layout = new GridLayout(4,3);
      setLayout(layout);
      Label keno = new Label("");
            Label keno2 = new Label("");
       metrhthsl = new Label("moves: "+Integer.toString(metrhths));
      
      for(i=0;i<9;i++){
          buttons[i]=new JButton(Integer.toString(test[i]));
          add(buttons[i]);
          buttons[i].addActionListener(this);
        }
         add(keno);
        add(metrhthsl);
        add(keno2);
  }
  public int getArrayIndex(int[] myArray, int myObject)
 {
   int ArraySize = Array.getLength(myArray);
   for (int i = 0; i < ArraySize; i++)
      {
       if (myArray[i] == myObject)
        {
         return(i);
        }
      }
  return(-1);
 }

     public void actionPerformed(ActionEvent ae){
         metrhths +=1;
         metrhthsl.setText("moves: "+Integer.toString(metrhths));
        //add(metrhthsl);
         Object source = ae.getSource();
         String label = ae.getActionCommand();
         int labelint = Integer.parseInt(label);
         int index=getArrayIndex(test, labelint);
         if((buttons[index+1].getText()).equals("0")){

  //  if(source==buttons[1]){
        
    int[] test2 = {1,1,3,8,7,5,6,4,0};
     
      for(i=0;i<9;i++){
          buttons[i].setText(Integer.toString(test2[i]));

        }
    }
  }
  
}

well, good luck then. And if you have specific questions and not "do it for me", feel free to ask them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.