Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Tic Tac Toe help on: 2009-11-23 17:36:22
Riven thanks , your code did give me an idea about neat coding that is to be used in games , and I don't copy source codes so don't worry about it Smiley.
And can you name any good books related to java game programming ?

Thanks
2  Game Development / Newbie & Debugging Questions / Re: Tic Tac Toe help on: 2009-11-23 12:54:01
ok here's my code so far the problem now i have is to choose which turn  is it of the cross or circle and also how to make checks that this player has won or not

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  
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class myTicTacToe extends MouseAdapter{

   public myTicTacToe(){
   
   jf=new JFrame("Tic Tac Toe");
   jf.setVisible(true);
   jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);
   jf.setSize(500,500);
   jf.setResizable(false);
   jf.setLayout(null);
   ii=new ImageIcon("F:\\ttt\\frame.gif");
   c=new ImageIcon("F:\\ttt\\circle.gif");
   cx=new ImageIcon("F:\\ttt\\cross.gif");
   jl=new JLabel(ii);
   circle=new JLabel(c);
   cross=new JLabel(cx);
   jpi=new JPanel();  // panel
   
   jf.addMouseListener(this);
   test=new JLabel();
   jf.add(test);
   test.setBounds(20,20,50,50);
   }


   public void init(){
   jf.add(jl);
   jf.add(jpi);
     
   test.setBounds(50,10,100,10);
   jpi.setBounds(50,75,290,290);
   jpi.setLayout(null);
   jl.setBounds(50,75,300,300);
   
   for(int i=0;i<9;i++){
      box[i]=new JLabel();
      jpi.add(box[i]);
      box[i].addMouseListener(this);
      }
   
   }

   
   
   public void mousePressed(MouseEvent me){
      int x=me.getX();
      int y=me.getY();
      test.setText(x+"  "+y);
      if( (x>76 && x<151) && (y>131 && y<203) ){
      box[0].setBounds(27,27,70,70);
      box[0].setIcon(new ImageIcon("circle.gif"));  
      }
     
      else if( (x>169 && x<242) && (y>131 && y<203) ){
      box[1].setBounds(118,27,70,70);
      box[1].setIcon(new ImageIcon("cross.gif"));  
      System.out.println("2nd");
      }
     
      else if( (x>258 && x<333) && (y>131 && y<203) ){
      box[2].setBounds(210,27,70,70);
      box[2].setIcon(new ImageIcon("circle.gif"));  
      System.out.println("3rd");
      }
     
      else if( (x>76 && x<151) && (y>222 && y<288) ){
      box[3].setBounds(27,115,70,70);
      box[3].setIcon(new ImageIcon("cross.gif"));  
      System.out.println("4");
      }
     
      else if( (x>169 && x<242) && (y>222 && y<288) ){
      box[4].setBounds(118,115,70,70);
      box[4].setIcon(new ImageIcon("cross.gif"));  
      System.out.println("5");
      }
     
      else if( (x>258 && x<333) && (y>222 && y<288) ){
      box[5].setBounds(210,115,70,70);
      box[5].setIcon(new ImageIcon("cross.gif"));  
      System.out.println("6");
      }
     
      else if( (x>76 && x<151) && (y>308 && y<381) ){
      box[6].setBounds(27,205,70,70);
      box[6].setIcon(new ImageIcon("cross.gif"));  
      System.out.println("7");
      }
     
      else if( (x>169 && x<242) && (y>308 && y<381) ){
      box[7].setBounds(118,205,70,70);
      box[7].setIcon(new ImageIcon("cross.gif"));  
      System.out.println("8");
      }
     
      else if( (x>258 && x<333) && (y>308 && y<381) ){
      box[8].setBounds(210,205,70,70);
      box[8].setIcon(new ImageIcon("cross.gif"));  
      System.out.println("9");
      }
     
     
   }
   

private JFrame jf;
private String p1;
private String p2;
private ImageIcon ii,c,cx;
private JLabel jl;
private JLabel circle,test;
private JLabel cross;
private JPanel jpi;
private JLabel box[]=new JLabel[9];
private int count=0;
private boolean player=false;
}

class myMain{

   public static void main(String arg[]){
   
   myTicTacToe ttt=new myTicTacToe();
   ttt.init();
   
   }
}
3  Game Development / Newbie & Debugging Questions / Re: Tic Tac Toe help on: 2009-11-22 00:59:44
I have searched on google but didn't find any custom made java tic tac toe , all of em are made with buttons Sad , i too have made one with buttons but i want to do it the other way now  persecutioncomplex
4  Game Development / Newbie & Debugging Questions / Re: Tic Tac Toe help on: 2009-11-21 16:50:59
I don't get the rectangle thing you told , I do know about the mouseListeners and stuff  Undecided
5  Game Development / Newbie & Debugging Questions / Tic Tac Toe help on: 2009-11-21 15:58:09
Hello people I need some help with making tic tac toe , i have made it with buttons , but now i want to make it without buttons , like I place my own tic tac toe grid on the frame and then when user clicks on a certain block then it should but circle or cross on that place , I know mouseListener will be used , but i want to know how could i possibly do it on my own image?
6  Game Development / Newbie & Debugging Questions / Re: Some questions on: 2009-11-10 00:54:55
I think i should be using a 2d engine cause i really don't want a 3d game , anyways how can i set the pulp core engine up on my system?
7  Game Development / Newbie & Debugging Questions / Some questions on: 2009-11-09 10:42:22
Hello people i am new to these forums and so to the java game development world . I am good at C++ and currently studying Java course in my university and know all the OO concepts so it wont be difficult for me to start game development . I want to make a game like "WORMS" but don't know where to start and which engine to use and how to use ? can anyone please give answers to my questions ?


Regards,
Ahmed
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (55 views)
2014-11-26 15:22:04

toopeicgaming1999 (48 views)
2014-11-26 15:20:36

toopeicgaming1999 (8 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (26 views)
2014-11-25 11:26:43

Gibbo3771 (23 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (75 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50
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!