Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC-design and displaying arrays using Swing/Graphics in Java
    text
    copied!<p>I'm working on a small Chess game and think I'm almost done with the basic model and ready to start writing the GUI.</p> <p>What I've been wondering for a long time is that if the Chess board is represented by a Square array of [8][8], and I create a method to draw a square and somehow establish a relation between that method and the Square model, will I then magically have a visual Chess board?</p> <p>I mean, say that a square is 10x10 pix, does that mean that the first element (represented by a square) will begin at (0, 0), element two at (10, 0), element/square nine at (0, 10) etc? When I checked out Graphics2D I noticed that the method to draw a rectangle requires x and y coordinates, what do I do if I want the position to depend on the array element?</p> <p>Or I am going to have to write down the coordinates of each square on the board?</p> <p>Another thing that has been bothering me is whether it's [row][column] or [column][row]? I've been using [column][row] in my code since it seems right if you think of it as (x, y). When you move up and down you change the row, = y, etc.</p> <p>I've been trying to google around to find out how to apply the MVC-design, what to think about, do's an dont's, etc. The only thing I know this far is that model = data logic, view = gui and control = interaction, the conclusion is that either I'm bad at googling or there isn't any good information targeted at beginners regarding MVC.</p> <p>Mainly I don't really understand the relation between M, V and C.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload