carookee - group communication for you
Home / JavaForum / Java allgemein
Infos   |   Features   |   Gold-Edition   |   Kundenservice   
java
  Übersicht
  Forum
Beginner
Java allgemein
JDBC
JNI
Networking
Online-Ressourcen
Swing + AWT
XML
Meckerecke
  Mitglieder
LOGIN





· Passwort vergessen
· Kostenlos anmelden
  Information
  Demo
  Features
  Im Vergleich
  Anmeldung
SUCHE
Beiträge, Foren oder Verfasser finden:
  Kundenservice
  Impressum
  Datenschutz
  AGB
Status
5.687 User online
0 User eingeloggt
 

Beiträge
   Antworten     Neuer Beitrag    

Beitrag 1896 von 2212 (86%) |<   <   >   >|

Autor Dex
Datum 21.02.05, 12:04
Betreff Spielprogrammieren


Hallo,
vielleicht kann mir jemand helfen, ich versuche das Spiel 4Gewinnt in Java zu schreiben. Hänge im Moment aber fest. Vielleicht kann ir jemand weiter helfen: import java.awt.*;
import java.awt.event.*;

public class Calculator4V extends java.applet.Applet implements ActionListener
{
boolean spielerA=true;
Panel spielfeld;
Label anzeige;
int feld [][] = new int [6][7];
int zeile;
int spalte;

private Button button1;
private Button button2;
private Button button3;
private Button button4;
private Button button5;
private Button button6;
private Button button7;
private Button button8;
private Button button9;
private Button button10;
private Button button11;
private Button button12;
private Button button13;
private Button button14;
private Button button15;
private Button button16;
private Button button17;
private Button button18;
private Button button19;
private Button button20;
private Button button21;
private Button button22;
private Button button23;
private Button button24;
private Button button25;
private Button button26;
private Button button27;
private Button button28;
private Button button29;
private Button button30;
private Button button31;
private Button button32;
private Button button33;
private Button button34;
private Button button35;
private Button button36;
private Button button37;
private Button button38;
private Button button39;
private Button button40;
private Button button41;
private Button button42;

public void init()
{
for(int i=0;i<6;i++)
for(int j=0;j<7;j++)
feld[i][j]=0;

button1 = new Button("1");
button2 = new Button("2");
button3 = new Button("3");
button4 = new Button("4");
button5 = new Button("5");
button6 = new Button("6");
button7 = new Button("7");
button8 = new Button("8");
button9 = new Button("9");
button10 = new Button("10");
button11 = new Button("11");
button12 = new Button("12");
button13 = new Button("13");
button14 = new Button("14");
button15 = new Button("15");
button16 = new Button("16");
button17 = new Button("17");
button18 = new Button("18");
button19 = new Button("19");
button20 = new Button("20");
button21 = new Button("21");
button22 = new Button("22");
button23 = new Button("23");
button24 = new Button("24");
button25 = new Button("25");
button26 = new Button("26");
button27 = new Button("27");
button28 = new Button("28");
button29 = new Button("29");
button30 = new Button("30");
button31 = new Button("31");
button32 = new Button("32");
button33 = new Button("33");
button34 = new Button("34");
button35 = new Button("35");
button36 = new Button("36");
button37 = new Button("37");
button38 = new Button("38");
button39 = new Button("39");
button40 = new Button("40");
button41 = new Button("41");
button42 = new Button("42");

setLayout(new BorderLayout());
spielfeld = new Panel(new GridLayout(6,7,5,5));
add("Center", spielfeld);
anzeige = new Label();
add("South", anzeige);

spielfeld.add(button1);
spielfeld.add(button2);
spielfeld.add(button3);
spielfeld.add(button4);
spielfeld.add(button5);
spielfeld.add(button6);
spielfeld.add(button7);
spielfeld.add(button8);
spielfeld.add(button9);
spielfeld.add(button10);
spielfeld.add(button11);
spielfeld.add(button12);
spielfeld.add(button13);
spielfeld.add(button14);
spielfeld.add(button15);
spielfeld.add(button16);
spielfeld.add(button17);
spielfeld.add(button18);
spielfeld.add(button19);
spielfeld.add(button20);
spielfeld.add(button21);
spielfeld.add(button22);
spielfeld.add(button23);
spielfeld.add(button24);
spielfeld.add(button25);
spielfeld.add(button26);
spielfeld.add(button27);
spielfeld.add(button28);
spielfeld.add(button29);
spielfeld.add(button30);
spielfeld.add(button31);
spielfeld.add(button32);
spielfeld.add(button33);
spielfeld.add(button34);
spielfeld.add(button35);
spielfeld.add(button36);
spielfeld.add(button37);
spielfeld.add(button38);
spielfeld.add(button39);
spielfeld.add(button40);
spielfeld.add(button41);
spielfeld.add(button42);

button1.addActionListener(this);
button2.addActionListener(this);
button3.addActionListener(this);
button4.addActionListener(this);
button5.addActionListener(this);
button6.addActionListener(this);
button7.addActionListener(this);
button8.addActionListener(this);
button9.addActionListener(this);
button10.addActionListener(this);
button11.addActionListener(this);
button12.addActionListener(this);
button13.addActionListener(this);
button14.addActionListener(this);
button15.addActionListener(this);
button16.addActionListener(this);
button17.addActionListener(this);
button18.addActionListener(this);
button19.addActionListener(this);
button20.addActionListener(this);
button21.addActionListener(this);
button22.addActionListener(this);
button23.addActionListener(this);
button24.addActionListener(this);
button25.addActionListener(this);
button26.addActionListener(this);
button27.addActionListener(this);
button28.addActionListener(this);
button29.addActionListener(this);
button30.addActionListener(this);
button31.addActionListener(this);
button32.addActionListener(this);
button33.addActionListener(this);
button34.addActionListener(this);
button35.addActionListener(this);
button36.addActionListener(this);
button37.addActionListener(this);
button38.addActionListener(this);
button39.addActionListener(this);
button40.addActionListener(this);
button41.addActionListener(this);
button42.addActionListener(this);
}

public void actionPerformed(ActionEvent e)
{
if (spielerA)
{
anzeige.setText("Spieler A");

if (e.getSource() == button1)
{
if (okButton(1))
button1.setBackground(Color.red);
}
if (e.getSource() == button2)
{
if (okButton(2))
button2.setBackground(Color.red);
}
if (e.getSource() == button3)
{
if (okButton(3))
button3.setBackground(Color.red);
}
if (e.getSource() == button4)
{
if (okButton(4))
button4.setBackground(Color.red);
}
if (e.getSource() == button5)
{
if (okButton(5))
button5.setBackground(Color.red);
}
if (e.getSource() == button6)
{
if (okButton(6))
button6.setBackground(Color.red);
}
if (e.getSource() == button7)
{
if (okButton(7))
button7.setBackground(Color.red);
}
if (e.getSource() == button8)
{
if (okButton(8))
button8.setBackground(Color.red);
}
if (e.getSource() == button9)
button9.setBackground(Color.red);
if (e.getSource() == button10)
button10.setBackground(Color.red);
if (e.getSource() == button11)
button11.setBackground(Color.red);
if (e.getSource() == button12)
button12.setBackground(Color.red);
if (e.getSource() == button13)
button13.setBackground(Color.red);
if (e.getSource() == button14)
button14.setBackground(Color.red);
if (e.getSource() == button15)
button15.setBackground(Color.red);
if (e.getSource() == button16)
button16.setBackground(Color.red);
if (e.getSource() == button17)
button17.setBackground(Color.red);
if (e.getSource() == button18)
button18.setBackground(Color.red);
if (e.getSource() == button19)
button19.setBackground(Color.red);
if (e.getSource() == button20)
button20.setBackground(Color.red);
if (e.getSource() == button21)
button21.setBackground(Color.red);
if (e.getSource() == button22)
button22.setBackground(Color.red);
if (e.getSource() == button23)
button23.setBackground(Color.red);
if (e.getSource() == button24)
button24.setBackground(Color.red);
if (e.getSource() == button25)
button25.setBackground(Color.red);
if (e.getSource() == button26)
button26.setBackground(Color.red);
if (e.getSource() == button27)
button27.setBackground(Color.red);
if (e.getSource() == button28)
button28.setBackground(Color.red);
if (e.getSource() == button29)
button29.setBackground(Color.red);
if (e.getSource() == button30)
button30.setBackground(Color.red);
if (e.getSource() == button31)
button31.setBackground(Color.red);
if (e.getSource() == button32)
button32.setBackground(Color.red);
if (e.getSource() == button33)
button33.setBackground(Color.red);
if (e.getSource() == button34)
button34.setBackground(Color.red);
if (e.getSource() == button35)
button35.setBackground(Color.red);
if (e.getSource() == button36)
button36.setBackground(Color.red);
if (e.getSource() == button37)
button37.setBackground(Color.red);
if (e.getSource() == button38)
button38.setBackground(Color.red);
if (e.getSource() == button39)
button39.setBackground(Color.red);
if (e.getSource() == button40)
button40.setBackground(Color.red);
if (e.getSource() == button41)
button41.setBackground(Color.red);
if (e.getSource() == button42)
button42.setBackground(Color.red);

spielerA=false;
}
else
{
anzeige.setText("Spieler B");

if (e.getSource() == button1)
{
if (okButton(1))
button1.setBackground(Color.blue);
}
if (e.getSource() == button2)
{
if (okButton(2))
button2.setBackground(Color.blue);
}
if (e.getSource() == button3)
{
if (okButton(3))
button3.setBackground(Color.blue);
}
if (e.getSource() == button4)
{
if (okButton(4))
button4.setBackground(Color.blue);
}
if (e.getSource() == button5)
{
if (okButton(5))
button5.setBackground(Color.blue);
}
if (e.getSource() == button6)
{
if (okButton(6))
button6.setBackground(Color.blue);
}
if (e.getSource() == button7)
{
if (okButton(7))
button7.setBackground(Color.blue);
}
if (e.getSource() == button8)
{
if (okButton(8))
button8.setBackground(Color.blue);
}
if (e.getSource() == button9)
button9.setBackground(Color.blue);
if (e.getSource() == button10)
button10.setBackground(Color.blue);
if (e.getSource() == button11)
button11.setBackground(Color.blue);
if (e.getSource() == button12)
button12.setBackground(Color.blue);
if (e.getSource() == button13)
button13.setBackground(Color.blue);
if (e.getSource() == button14)
button14.setBackground(Color.blue);
if (e.getSource() == button15)
button15.setBackground(Color.blue);
if (e.getSource() == button16)
button16.setBackground(Color.blue);
if (e.getSource() == button17)
button17.setBackground(Color.blue);
if (e.getSource() == button18)
button18.setBackground(Color.blue);
if (e.getSource() == button19)
button19.setBackground(Color.blue);
if (e.getSource() == button20)
button20.setBackground(Color.blue);
if (e.getSource() == button21)
button21.setBackground(Color.blue);
if (e.getSource() == button22)
button22.setBackground(Color.blue);
if (e.getSource() == button23)
button23.setBackground(Color.blue);
if (e.getSource() == button24)
button24.setBackground(Color.blue);
if (e.getSource() == button25)
button25.setBackground(Color.blue);
if (e.getSource() == button26)
button26.setBackground(Color.blue);
if (e.getSource() == button27)
button27.setBackground(Color.blue);
if (e.getSource() == button28)
button28.setBackground(Color.blue);
if (e.getSource() == button29)
button29.setBackground(Color.blue);
if (e.getSource() == button30)
button30.setBackground(Color.blue);
if (e.getSource() == button31)
button31.setBackground(Color.blue);
if (e.getSource() == button32)
button32.setBackground(Color.blue);
if (e.getSource() == button33)
button33.setBackground(Color.blue);
if (e.getSource() == button34)
button34.setBackground(Color.blue);
if (e.getSource() == button35)
button35.setBackground(Color.blue);
if (e.getSource() == button36)
button36.setBackground(Color.blue);
if (e.getSource() == button37)
button37.setBackground(Color.blue);
if (e.getSource() == button38)
button38.setBackground(Color.blue);
if (e.getSource() == button39)
button39.setBackground(Color.blue);
if (e.getSource() == button40)
button40.setBackground(Color.blue);
if (e.getSource() == button41)
button41.setBackground(Color.blue);
if (e.getSource() == button42)
button42.setBackground(Color.blue);

spielerA=true;
}
}

public boolean okButton(int knopf)
{

return true;
}

public boolean zugSpielerA()
{
return false;
}
public boolean zugSpielerB()
{
return false;
}
}
danke schon mal im voraus.


Diskussionsverlauf:
Spielprogrammieren
        Re: Spielprogrammieren
                Re: Spielprogrammieren
                        Re: Spielprogrammieren
                                Re: Spielprogrammieren
    Re: Spielprogrammieren
            Re: Spielprogrammieren
                    Re: Spielprogrammieren
                            Re: Spielprogrammieren

 Auf diesen Beitrag antworten
 Neuen Beitrag verfassen


|<   <   >   >|

                                                                                                                                                                                                                           

Impressum  · Datenschutz  · AGB  · Infos  · Presse
Ein modernes Forum: teamturn.com