Show Posts
|
|
Pages: [1]
|
|
1
|
Discussions / Miscellaneous Topics / Re: Why am I an idiot?
|
on: 2006-12-24 01:23:45
|
|
i know exactly what ur talking about.. i havent graduated yet from university.. i started in computer science and when i was learning C++ i was reading and playing with more that what i was thought .. we learend console applications and i was already playing with opengl, glut and glut based GUI. when i started learning data structures in C++ i was more interested in what java is and how to use it, i was writing my data structures in java when my assignments r in C++ and end up not finishing my c++ project. when i did unix system programming i was more interested in how to daul install linux and windows together and how to hack and compile the kernel.. so the teacher introduce the course and i go off course to learn more stuff not covered in the course.
there is more to my story , the end is that im now senior in computer engineering and minor in computer science.. no degree yet. but im working as a software engineer, the recruiter was amazed with the stuff that i know and i passed all the interviews so i got hired.
few months ago i was going crazy about .net and mono, but when i heard that java is going GPL i went back to java , yet im trying to learn C# now. i have learned from my mistakes, first "keep it simple", then when u solve the problem u can look into how to make a better solution. but first solve the problem before anything else.
ur not an idiot, u just cant thing about one thing at a time, ur mind creates threads of thoughts that pulls u away from the main objective.
the solution is in ur mind buddy.
good luck to you.
|
|
|
|
|
4
|
Game Development / Shared Code / Re: learning how to create chessboard in java
|
on: 2006-12-17 19:33:24
|
ok im trying to understand what u mean.. do u mean that i need to create a sperate class for event handeling and have a methode that determinds where the event came from and take action according to that ? im looking into my design AGAIN. and i can see somthing interesting .. im using board squars as object in board, that means that board squares is stand alone, but board requaires boardsquare as part of it , it is declared as an object withen the class. but if i use inheretince instead of createing object , then the code may look cleaner, and easy transition to see what new features where added to class board. im going to look again into those issues, i got the even handelign and all i need to know to get this working, but im looking into best design that is easy to follow and resue and maintain or modify by others who want to create their own chess board or checkers board or what ever board. i enjoy ur openions  .. thanks.. Bilal El Uneis
|
|
|
|
|
5
|
Game Development / Shared Code / Re: learning how to create chessboard in java
|
on: 2006-12-16 03:44:57
|
here is my code so far... i love to hear from u guys.. peace, Bilal El Uneis 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 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
|
import java.awt.event.*; import javax.swing.*;
public class BoardSquare extends JPanel implements MouseListener { public BoardSquare() { super(); addMouseListener(this); } public BoardSquare(String name) { super(); setName(name); addMouseListener(this); }
public void mouseClicked(MouseEvent e) { }
public void mousePressed(MouseEvent e) { }
public void mouseReleased(MouseEvent e) { }
public void mouseEntered(MouseEvent e) { System.out.println("wellcome to square " + getName()); }
public void mouseExited(MouseEvent e) { } public static void main(String args[]) { JFrame frame = new JFrame(); frame.setSize(200,200); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new BoardSquare("test square")); frame.setVisible(true); } }
import java.awt.*; import javax.swing.*;
public class Board extends JPanel { protected BoardSquare[][] squares; public Board() { setSize(800,700); setLayout(new GridLayout(8,8)); squares = new BoardSquare[8][8]; createSquares(); } public Board(int h, int w) { setSize(h,w); setLayout(new GridLayout(8,8)); squares = new BoardSquare[8][8]; createSquares(); } private void createSquares() { for(int i=0;i<8;i++) { for(int j=0;j<8;j++) { BoardSquare panel = new BoardSquare(""+i+""+j); panel.setBackground(getColor(i,j)); add(panel); squares[i][j] = panel; } } } private Color getColor(int x, int y) { if((x+y)%2 == 0) return Color.WHITE; else return Color.BLACK; } public void addPiece(Piece p, int x, int y) { squares[x][y].add(p); paintAll(getGraphics()); } public void removePiece(int x, int y) { if(squares[x][y].getComponentCount() > 0) { squares[x][y].remove(0); paintAll(getGraphics()); } } public static void main(String args[]) { Board t = new Board(); for(int i=0; i<8; i++) { t.addPiece(new Piece("Rpawn.gif"),1,i); t.addPiece(new Piece("Bpawn.gif"),6,i); } t.addPiece(new Piece("Rrook.gif"),0,7); t.addPiece(new Piece("Brook.gif"),7,7); t.addPiece(new MoveablePiece("Rrook.gif"),0,0); t.addPiece(new Piece("Brook.gif"),7,0); t.addPiece(new Piece("Rknight.gif"),0,6); t.addPiece(new Piece("Bknight.gif"),7,6); t.addPiece(new Piece("Rknight.gif"),0,1); t.addPiece(new Piece("Bknight.gif"),7,1); t.addPiece(new Piece("Rbishop.gif"),0,5); t.addPiece(new Piece("Bbishop.gif"),7,5); t.addPiece(new Piece("Rbishop.gif"),0,2); t.addPiece(new Piece("Bbishop.gif"),7,2); t.addPiece(new Piece("Rqueen.gif"),0,4); t.addPiece(new Piece("Bqueen.gif"),7,4); t.addPiece(new Piece("Rking.gif"),0,3); t.addPiece(new Piece("Bking.gif"),7,3); JFrame frame = new JFrame(); frame.setSize(800,700); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false); frame.add(t); frame.setVisible(true); JOptionPane.showInputDialog("testing pawn move"); t.removePiece(1,0); t.addPiece(new Piece("Rpawn.gif"),2,0); } }
import javax.swing.*;
public class Piece extends JLabel { public Piece() { super(new ImageIcon("Bking.gif")); setName("Bking.gif"); } public Piece(String image_file) { super(new ImageIcon(image_file)); setName(image_file); } public static void main(String args[]) { JFrame frame = new JFrame(); frame.setSize(200,200); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Piece piece = new Piece("Rking.gif"); frame.add(piece); frame.setVisible(true); System.out.println(piece.getName()); } }
import java.awt.*; import java.awt.event.*; import javax.swing.*;
public class MoveablePiece extends Piece implements MouseListener { public MoveablePiece() { super(); addMouseListener(this); } public MoveablePiece(String piece_name) { super(piece_name); addMouseListener(this); }
public void mouseClicked(MouseEvent e) { }
public void mousePressed(MouseEvent e) { System.out.println(getName() + " pressed.."); }
public void mouseReleased(MouseEvent e) { }
public void mouseEntered(MouseEvent e) { System.out.println("u enterd " + getName()); System.out.println("Parent is " + e.getComponent().getParent().getName()); }
public void mouseExited(MouseEvent e) { } public static void main(String args[]) { MoveablePiece p = new MoveablePiece(); JPanel panel = new JPanel(); panel.setName("black panel"); panel.setSize(50,50); panel.setBackground(Color.black); JFrame frame = new JFrame(); frame.setName("frame"); frame.setLayout(new GridLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300,300); frame.add(p); frame.add(panel); frame.setVisible(true); } }
|
|
|
|
|
|
6
|
Discussions / Miscellaneous Topics / books u read to learn , and read for pastime
|
on: 2006-12-12 22:21:59
|
|
ok .. so what books do u read?
1- programming books?
2- other books?
3- how do u learn more ?? google or read books?
for me:
1- ditel and ditel how to program, C++/java/C# , orielly mostly java.
2- math books , algebra and calculus.
3- the essintials from books but how to do things from google and the web.
|
|
|
|
|
8
|
Game Development / Shared Code / Re: learning how to create chessboard in java
|
on: 2006-12-06 02:48:51
|
once again i modyfied my solution .. made better use of inheritence and use JPanel instead of JFrame and then added panels to it.. now my code does update and move, as i used paintAll(graphics g) .. also i think my code looks more simple now, even a real biggener can follow. i also added main methode to Piece.java so that u can test it as a stand alone application, and see if it adds the chess piece  . so here it is  .. peace 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
|
import javax.swing.*;
public class Piece extends JLabel { public Piece() { super(new ImageIcon("Bking.gif")); } public Piece(String image_file) { super(new ImageIcon(image_file)); } public static void main(String args[]) { JFrame frame = new JFrame(); frame.setSize(200,200); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new Piece("Rking.gif")); frame.setVisible(true); } }
|
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
|
import java.awt.*; import javax.swing.*;
public class Board extends JPanel { protected JPanel[][] squares; public Board() { setSize(800,700); setLayout(new GridLayout(8,8)); squares = new JPanel[8][8]; } public Board(int h, int w) { setSize(h,w); setLayout(new GridLayout(8,8)); squares = new JPanel[8][8]; } public void createSquares() { for(int i=0;i<8;i++) { for(int j=0;j<8;j++) { JPanel panel = new JPanel(); panel.setBackground(getColor(i,j)); add(panel); squares[i][j] = panel; } } } protected Color getColor(int x, int y) { if((x+y)%2 == 0) return Color.WHITE; else return Color.BLACK; } public static void main(String args[]) { Board t = new Board(800,700); t.createSquares(); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(800,700); frame.setResizable(false); frame.add(t); frame.setVisible(true); } }
|
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
|
import javax.swing.*;
public class Board2 extends Board { public Board2() { super(); } public Board2(int h, int w) { super(h,w); } public void addPiece(Piece p, int x, int y) { squares[x][y].add(p); paintAll(getGraphics()); } public void removePiece(int x, int y) { squares[x][y].remove(0); paintAll(getGraphics()); } public static void main(String args[]) { Board2 t = new Board2(); t.createSquares(); for(int i=0; i<8; i++) { t.addPiece(new Piece("Rpawn.gif"),1,i); t.addPiece(new Piece("Bpawn.gif"),6,i); } t.addPiece(new Piece("Rrook.gif"),0,7); t.addPiece(new Piece("Brook.gif"),7,7); t.addPiece(new Piece("Rrook.gif"),0,0); t.addPiece(new Piece("Brook.gif"),7,0); t.addPiece(new Piece("Rknight.gif"),0,6); t.addPiece(new Piece("Bknight.gif"),7,6); t.addPiece(new Piece("Rknight.gif"),0,1); t.addPiece(new Piece("Bknight.gif"),7,1); t.addPiece(new Piece("Rbishop.gif"),0,5); t.addPiece(new Piece("Bbishop.gif"),7,5); t.addPiece(new Piece("Rbishop.gif"),0,2); t.addPiece(new Piece("Bbishop.gif"),7,2); t.addPiece(new Piece("Rqueen.gif"),0,4); t.addPiece(new Piece("Bqueen.gif"),7,4); t.addPiece(new Piece("Rking.gif"),0,3); t.addPiece(new Piece("Bking.gif"),7,3); JFrame frame = new JFrame(); frame.setSize(800,700); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false); frame.add(t); frame.setVisible(true); JOptionPane.showInputDialog("testing pawn move"); t.removePiece(1,0); t.addPiece(new Piece("Rpawn.gif"),2,0); } }
|
|
|
|
|
|
9
|
Game Development / Shared Code / Re: learning how to create chessboard in java
|
on: 2006-12-05 11:11:53
|
ok .. here is my new code, i ca now add all pieces to the chess board and show the board with those pieces, i can remove a piece and move it.. but it only removes and i need to minimize then maximize the window to so that i will show the new piece moved.. hmm., i need to look into that. i used some nice chess pieces found on the internet and .. my board looks nice. but again, i need to fix this drawing thing, then i can start writing mouse handling stuff in another class.. suggestions are very very wellcomed  and appriciated. here is my code so far. peace 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
|
import javax.swing.*;
public class Piece extends JLabel { public Piece() { super(new ImageIcon("Bking.gif")); } public Piece(String image_file) { super(new ImageIcon(image_file)); } }
|
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
|
import java.awt.*; import javax.swing.*;
public class Board { protected JPanel[][] squares; protected JFrame boardFrame; protected Container container; public Board() { boardFrame = new JFrame(); boardFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); boardFrame.setSize(800,700); boardFrame.setResizable(false); } public void showBoard() { boardFrame.setVisible(true); } public void createSquares() { container = boardFrame.getContentPane(); container.setLayout(new GridLayout(8,8)); squares = new JPanel[8][8]; for(int i=0;i<8;i++) { for(int j=0;j<8;j++) { JPanel panel = new JPanel(); panel.setBackground(getColor(i,j)); container.add(panel); squares[i][j] = panel; } } } private Color getColor(int x, int y) { if((x+y)%2 == 0) return Color.WHITE; else return Color.BLACK; } public static void main(String args[]) { Board t = new Board(); t.createSquares(); t.showBoard(); } }
|
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
|
import javax.swing.*;
public class Board2 extends Board { public Board2() { super(); } public void addPiece(Piece p, int x, int y) { squares[x][y].add(p); squares[x][y].repaint(); } public void removePiece(int x, int y) { squares[x][y].remove(0); squares[x][y].repaint(); } public static void main(String args[]) { Board2 t = new Board2(); t.createSquares(); for(int i=0; i<8; i++) { t.addPiece(new Piece("Rpawn.gif"),1,i); t.addPiece(new Piece("Bpawn.gif"),6,i); } t.addPiece(new Piece("Rrook.gif"),0,7); t.addPiece(new Piece("Brook.gif"),7,7); t.addPiece(new Piece("Rrook.gif"),0,0); t.addPiece(new Piece("Brook.gif"),7,0); t.addPiece(new Piece("Rknight.gif"),0,6); t.addPiece(new Piece("Bknight.gif"),7,6); t.addPiece(new Piece("Rknight.gif"),0,1); t.addPiece(new Piece("Bknight.gif"),7,1); t.addPiece(new Piece("Rbishop.gif"),0,5); t.addPiece(new Piece("Bbishop.gif"),7,5); t.addPiece(new Piece("Rbishop.gif"),0,2); t.addPiece(new Piece("Bbishop.gif"),7,2); t.addPiece(new Piece("Rqueen.gif"),0,4); t.addPiece(new Piece("Bqueen.gif"),7,4); t.addPiece(new Piece("Rking.gif"),0,3); t.addPiece(new Piece("Bking.gif"),7,3); t.showBoard(); JOptionPane.showInputDialog("testing pawn move"); t.removePiece(1,0); t.addPiece(new Piece("Rpawn.gif"),2,0); } }
|
|
|
|
|
|
10
|
Game Development / Shared Code / Re: learning how to create chessboard in java
|
on: 2006-12-04 19:42:54
|
i havent looked or did anything extra on my code, im trying to learn jgl more "java gl using pure java" and also hacking it to understand how it is implemted and im using UDoc to get uml like diagrams from the jgl package , to understand it more. i will come back to my chess program "gui at this point" and maybe redo it using jgl and draw everything in 3D. but again this thread is my attempt at that and all i post here is my learning while im doing things .. please be specific about what bla_bla vs blaBla means?? where in my code ur exactly pointing? again, any suggestions and advices r very wellcome.. i learn from everyone.  peace
|
|
|
|
|
11
|
Game Development / Shared Code / Re: learning how to create chessboard in java
|
on: 2006-11-30 23:26:45
|
ok, now board2 can add, remove piece, so to move a pieace from one location to another u just call remove , then add to the new location. im not sure i changed anything in board or piece , but here is the complete code again. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
import javax.swing.*;
public class Piece extends JLabel { public Piece() { super(new ImageIcon("king.gif")); } }
|
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
|
import java.awt.*; import javax.swing.*;
public class Board { protected JPanel[][] squares; protected JFrame boardFrame; protected Container container; public Board() { boardFrame = new JFrame(); boardFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); container = boardFrame.getContentPane(); container.setLayout(new GridLayout(8,8)); create_squares(); boardFrame.setSize(400,450); boardFrame.setVisible(true); } private void create_squares() { squares = new JPanel[8][8]; for(int i=0;i<8;i++) { for(int j=0;j<8;j++) { JPanel p = new JPanel(); p.setBackground(setColor(i,j)); squares[i][j]=p; container.add(p); } } } private Color setColor(int x, int y) { if((x+y)%2 == 0) return Color.WHITE; else return Color.BLACK; } public static void main(String args[]) { new Board(); } }
|
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
|
import javax.swing.*;
public class Board2 extends Board { public Board2() { super(); } public void addPiece(Piece p, int x, int y) { JPanel panel = squares[x][y]; panel.add(p); panel.repaint(); } public void removePiece(Piece p, int x, int y) { JPanel panel = squares[x][y]; panel.remove(p); panel.repaint(); } public static void main(String args[]) { Piece p = new Piece(); Board2 b2 = new Board2(); b2.addPiece(p,0,0); JOptionPane.showInputDialog("put anything here"); b2.removePiece(p,0,0); b2.addPiece(p,0,3); } }
|
|
|
|
|
|
12
|
Game Development / Shared Code / Re: learning how to create chessboard in java
|
on: 2006-11-29 19:23:55
|
ok , i did some reseach , looked at more code from google  , here is what i decided to do.. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
import javax.swing.*;
public class Piece extends JLabel { public Piece() { super(new ImageIcon("king.gif")); } }
|
i then created a board, that does nothing but paint a board for you.. 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
|
import java.awt.*; import javax.swing.*;
public class Board { protected JPanel[][] squares; protected JFrame boardFrame; protected Container container; public Board() { boardFrame = new JFrame(); boardFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); container = boardFrame.getContentPane(); container.setLayout(new GridLayout(8,8)); create_squares(); boardFrame.setSize(400,450); boardFrame.setVisible(true); } private void create_squares() { squares = new JPanel[8][8]; for(int i=0;i<8;i++) { for(int j=0;j<8;j++) { JPanel p = new JPanel(); p.setBackground(setColor(i,j)); squares[i][j]=p; container.add(p); } } } private Color setColor(int x, int y) { if((x+y)%2 == 0) return Color.WHITE; else return Color.BLACK; } public static void main(String args[]) { new Board(); } }
|
finally i created board2 to use board and has a feature of adding pieces to it. 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
|
import javax.swing.*;
public class Board2 extends Board { public Board2() { super(); } public void setPiece(Piece p, int x, int y) { JPanel panel = squares[x][y]; if(panel.getComponentCount()>0) panel.remove(0); panel.add(p); panel.revalidate(); } public static void main(String args[]) { Piece p = new Piece(); Board2 b2 = new Board2(); b2.setPiece(p,0,0); } }
|
suggestions and comments appreciated
|
|
|
|
|
13
|
Game Development / Shared Code / Re: learning how to create chessboard in java
|
on: 2006-11-27 16:00:12
|
im trying to add chess piece to my board, then ill attempt to move the piece around , and after that i can create the whole board with pieces in it .. and that is it .. very simple.. as for rules on what is legal and what is not that is up to the logic code or the engine, in fact i might modify my code later on, to be Board.java that shows how to create simple Board , then ChessBoard extends Board that will show how to add pieces and allow moving them on the board. so that others who want to learn how to create a board for any other reasons can use the code .  ok, im trying to figure out how to add chess piece, but this is not working.. here is my code now.. 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
|
import java.awt.*; import java.awt.event.*; import javax.swing.*;
public class ChessBoard extends JFrame implements MouseListener { JPanel [][] squares; public ChessBoard() { Container c = getContentPane(); c.setLayout(new GridLayout(8,8, 1 , 1)); squares = new JPanel[8][8]; for(int i=0; i<8; i++) { for(int j=0; j<8; j++) { squares[i][j] = new JPanel(); if((i+j)%2 == 0) squares[i][j].setBackground(Color.white); else squares[i][j].setBackground(Color.black); squares[i][j].addMouseListener(this); c.add(squares[i][j]); } } } public void addPiece(String piece_name,int i, int j) { JLabel piece_icon = new JLabel(); piece_icon.setIcon(new ImageIcon(piece_name)); squares[i][j].add(piece_icon); squares[i][j].repaint(); } public void mouseClicked(MouseEvent e){ } public void mouseEntered(MouseEvent e){ } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public static void main(String args[]) { ChessBoard test = new ChessBoard(); test.addPiece("king.bmp",0,1); test.setSize(300,300); test.setResizable(false); test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); test.setVisible(true); } }
|
|
|
|
|
|
15
|
Game Development / Shared Code / Re: learning how to create chessboard in java
|
on: 2006-11-27 15:24:38
|
wow, interesting , i swear my code has squares [j] = new JPanel();
i dont understand why it pasted with 1 d array.. let try this again.
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
|
import java.awt.*; import java.awt.event.*; import javax.swing.*;
public class ChessBoard extends JFrame implements MouseListener { JPanel [][] squares; public ChessBoard() { Container c = getContentPane(); c.setLayout(new GridLayout(8,8, 1 , 1)); squares = new JPanel[8][8]; for(int i=0; i<8; i++) { for(int j=0; j<8; j++) { squares[i][j] = new JPanel(); if((i+j)%2 == 0) squares[i][j].setBackground(Color.white); else squares[i][j].setBackground(Color.black); squares[i][j].addMouseListener(this); c.add(squares[i][j]); } } } public void addPiece(String piece_name,int i, int j) { Icon piece_icon = new ImageIcon(getClass().getResource(piece_name)); squares[i][j].add((JComponent)piece_icon); } public void mouseClicked(MouseEvent e){ } public void mouseEntered(MouseEvent e){ } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public static void main(String args[]) { ChessBoard test = new ChessBoard(); test.addPiece("king.bmp",0,0); test.setSize(300,300); test.setResizable(false); test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); test.setVisible(true); } }
|
|
|
|
|
|
16
|
Game Development / Shared Code / learning how to create chessboard in java
|
on: 2006-11-27 06:48:53
|
|
this is my attempt to learn how to create a chess board, ill share my code here and add more as i learn more.. peace
/* * ChessBoard.java * * Created on November 26, 2006, 10:06 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */
/** * * @author Bilal El Uneis */
import java.awt.*; import java.awt.event.*; import javax.swing.*;
public class ChessBoard extends JFrame implements MouseListener { JPanel [][] squares; /** Creates a new instance of ChessBoard */ public ChessBoard() { Container c = getContentPane(); c.setLayout(new GridLayout(8,8, 1 , 1)); squares = new JPanel[8][8]; for(int i=0; i<8; i++) { for(int j=0; j<8; j++) { squares[j] = new JPanel(); if((i+j)%2 == 0) squares[j].setBackground(Color.white); else squares[j].setBackground(Color.black); squares[j].addMouseListener(this); c.add(squares[j]); } } } public void mouseClicked(MouseEvent e){ } public void mouseEntered(MouseEvent e){ } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public static void main(String args[]) { ChessBoard test = new ChessBoard(); test.setSize(300,300); test.setResizable(false); test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); test.setVisible(true); } }
|
|
|
|
|
17
|
Java Game APIs & Engines / Java 2D / Re: jgl java gl written in pure java
|
on: 2006-11-25 20:51:14
|
ok .. i dont know if i mentined i use netbeans 5.5.. any way does anyone know of a good uml diagram generator tht i can use with the jgl to extract how classes are inherited and that way i can see things visually with their methods before i surgically modify the code in those methodes  peace ..
|
|
|
|
|
18
|
Java Game APIs & Engines / Java 2D / Re: jgl java gl written in pure java
|
on: 2006-11-25 10:55:03
|
|
wow, interesting .. from 50 using java2D to about 2000 fps in slick using lwjgl.. nice. but agian , jgl can be used where hardware accelaration is not supported , and if supported i think java2d can do well, hopefully in the future better pipline and better performance can be achived in java2d
|
|
|
|
|
19
|
Java Game APIs & Engines / Java 2D / Re: jgl java gl written in pure java
|
on: 2006-11-25 10:47:34
|
|
about java2D being slower than opengl.. i doubt that, if its accelarated using opengl or d3d it shouldnt.. but again maybe some operations more algorithmitic "bad spelling", so uses cpu to compute before sending output to GPU.. i think if u stick to simple operations like lines, triagle and polygons u wont see much difference, .. just my openion.
peace
|
|
|
|
|
20
|
Java Game APIs & Engines / Java 2D / Re: jgl java gl written in pure java
|
on: 2006-11-25 10:44:17
|
did u download jgl from robin's site ?? the one he has up there is jgl2.4 beta 3 i think , and the source code for that doesnt compile under jdk1.6 and i dont know how it compiled under jdk1.1 , he has created objects with wrong name so the compiler cant find definition.. any way i fixed that on the copy i got + there will be some casting problems "warrnings " due to using newer and more strict java 1.5 and 1.6.. if u download the source code ull get folder with examples, look at example-app .. that has the examples using glut and can be compiled and run as application.. oh u might want to look at main methode and change Frame to JFrame and then add a mthode for close operation. mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); he uses awt , and no closing operation or event handling is provided  . im still learning this api and i want to write the same program in C/C++ and java "using jgl".. peace
|
|
|
|
|
21
|
Java Game APIs & Engines / Java 2D / Re: jgl java gl written in pure java
|
on: 2006-11-25 08:49:35
|
yeah i visited the forum and the site, very interesting .. i sent email to robin and he said that he is going to add some new features and upload it soon, i dont know how soon. but for me i think that rewriting the drawing parts to use java2D will surely make better performance, because java2D uses opengl pipeline or d3d .. and it fits well with swing and awt. and again , supported where java2d api is supported , which i have always seen it supported even if the system was embeded like damn small linux. im starting to learn opengl and glut, im reading the red book and i have wrote little demo in C, then translate it to java using jgl, there is little incompatibility in a sense that i didnt see my wire frame square in java, all i got is the black canvas  . but im playing with it.. after i get good handle on this then convert to C++ "piece of cake" then C# using tao api.. and as i learn more then i can propebly with the help of others  change the jgl api to use java2D for drawing. ill post code of my java and C/C++ code using and learning opengl if any one wants to see  . peace
|
|
|
|
|
22
|
Java Game APIs & Engines / Java 2D / Re: jgl java gl written in pure java
|
on: 2006-11-25 03:38:30
|
|
im not sure about performance hit reagarding an api on top of each other.. but im sure u guys heard that java is going open source and GPL. now the standard api that is provided is suppost to run on all platforms in since that u install the jre and it is avaialable..
here is a senario, i use damn small linux to do unix testing of my application, it runs totally from ram and it is only 50 mb, then i install jre and java3D api, everything goes well, but when i run my java3D application it doesnt because i dont have opengl or mesa installed.. that is becuase for this system to be small there is a lot of things omitted, it even uses small x server xvisa or somthing like that. but java runs fine because it can use software emulation when hardware accelaration is not there. so by having JGL in here i can still do opengl on linux and windows and any system that has jre for it.
i have tried some of the glut examples in JGL and the performance was ok with softwar emulation. and i think if we can rewrite the drawing parts with java2D then we can gain more performance without having the fliker problem when an api uses gl and the component uses directX or direct 3D .. the case of jogl and java3D with swing.
any way .. if u download the source code it will not compile , it has errors.. i have them fixed so if u want it i can email it to u, i use netbeans 5.5 and jdk1.6 rc 1.
peace
|
|
|
|
|
23
|
Java Game APIs & Engines / Java 2D / jgl java gl written in pure java
|
on: 2006-11-24 23:47:09
|
|
hi i came across this api, called jgl, u can google it, it is written using pure java, that means build on top of libraries provided with jre by default, nothing extra needed. it has gl calls and glut calls too. i have downloaded the source code which didnt compile at first. fixed it got rid of the warrning that is genarated due to outdated casting problem with jdk1.1.
the api and code is GPL. so we can basically modify it and so on .. any one interested in modifying the library to use java2d instead? this could provide good speed.
peace
|
|
|
|
|
26
|
Java Game APIs & Engines / Java 3D / how good is java3D for real time gaming like fps
|
on: 2006-11-16 00:40:33
|
|
hi,
discuss why java3D is not or is good for game progamming in java , in particular first person shooter. compare it with jogl and lwjgl as they r the most famous.
i have tried java3D, not easy to learn at first, but then u come to appreciate the design. im not sure about performance. it integrates well with other java components. on the other hand jogl seems to be little buggy and not backward compatibe with previous versions. i have seen jake2 which is quake 2 ported to java using lwjgl and jogl and joal. never seen an fps written completly using java3D yet..
peace
|
|
|
|
|
28
|
Java Game APIs & Engines / JOGL Development / Re: jogl release in sep 14
|
on: 2006-11-15 13:22:00
|
ok .. i was looking and found this ... hope it can help others.. /* * Example 2: Hello JOGL * * Draws a multi-colored triangle to the GLCanvas. As in the previous * example, the GLCanvas is placed in a JFrame and made visible. This * time OpenGL functions are called in the init, reshape and display * methods to set up the OpenGL environment and draw the triangle. * OpenGL commands can only be executed within the GLEventListener * methods (when called automatically). The OpenGL context is not * current anywhere else, and OpenGL calls will have no effect. * * It is recommended to always retrieve the GL object from the * GLDrawable parameter in the GLEventListener methods as opposed to * storing the object in a instance variable. The reason for this is * that if it is stored in an instance variable, it is too easy to * use it to call OpenGL methods in places other than the GLEventListener * methods. * * Author: David Wolff * * Licensed under the Creative Commons Attribution License 2.5: * http://creativecommons.org/licenses/by/2.5/ */ //package tutorial.b_HelloJOGL; import java.awt.BorderLayout; import javax.media.opengl.GL; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCanvas; import javax.media.opengl.GLEventListener; import javax.swing.JFrame; public class HelloJOGL implements GLEventListener { /* * Set up the background color, and clear the modelview matrix. */ public void init( GLAutoDrawable d ) { GL gl = d.getGL(); gl.glClearColor( 0,0,0,0 ); gl.glMatrixMode( GL.GL_MODELVIEW ); gl.glLoadIdentity(); } /* * Set up a simple orthographic projection, with a square * window. */ public void reshape( GLAutoDrawable d, int x, int y, int width, int height ) { GL gl = d.getGL(); gl.glMatrixMode( GL.GL_PROJECTION ); gl.glLoadIdentity(); gl.glOrtho( -1.0, 1.0, -1.0, 1.0, -0.1, 0.1 ); gl.glMatrixMode( GL.GL_MODELVIEW ); } /* * Draw a triangle. */ public void display( GLAutoDrawable d ) { GL gl = d.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glBegin( GL.GL_TRIANGLES ); gl.glColor3f(1.0f,0.0f,0.0f); gl.glVertex2d( -0.75, -0.75 ); gl.glColor3f(0.0f,0.0f,1.0f); gl.glVertex2d( 0.75, -0.75 ); gl.glColor3f(0.0f,1.0f,0.0f); gl.glVertex2d( 0.0, 0.75 ); gl.glEnd(); } /* * Create a JFrame containing a GLCanvas. The GLEventListener * for the GLCanvas is an instance of HelloJOGL. */ public static void main( String[] args ) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); // Create a GLCanvas object and place into the JFrame GLCanvas canvas = new GLCanvas(); canvas.setSize(400,400); // Add an instance of HelloJOGL as the GLEventListener for // the GLCanvas. canvas.addGLEventListener( new HelloJOGL() ); frame.getContentPane().add( canvas, BorderLayout.CENTER ); frame.pack(); frame.setVisible( true ); } /* * Unused method. */ public void displayChanged( GLAutoDrawable d, boolean modeChanged, boolean deviceChanged ) { } }
|
|
|
|
|
29
|
Java Game APIs & Engines / JOGL Development / jogl release in sep 14
|
on: 2006-11-15 13:00:27
|
|
im talking about the latest release of jogl.. there is not enough examples and it seems that the older examples dont work on this api..
where can i get examples starting from simple window , to drawing lines and then cube and progress..
peace
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|