File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Putting pieces inside a board Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Putting pieces inside a board" Watch "Putting pieces inside a board" New topic
Author

Putting pieces inside a board

asr era
Greenhorn

Joined: Feb 17, 2013
Posts: 4
To fill in the board square covered by a piece, it would be helpful to have a method similar to the one above that copies the non-zero entries from the given array into the corresponding board squares.

I need to implement this now, but I have the following questions:

where do I put the contents array? I don't see a board array in the program

do i need to put the contents array inside the board once it was laid down or once it appears? and how do i know a piece was laid down? what if statement should i use for that?



Code:







Code:










Code:







Code:




I don't know where the content of the board is stored, but I know that board extends grid and contains int[][]contents; however I used contents to rotate the pieces earlier, so I don't think that's where the pieces are saved.

Everything seems to indicate that int [][]contents contains both, but I don't understand the code.

Btw, this is a tetris game.

I also implemented the following code earlier, but I don't know what reference to pass in for the board variable.

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
http://www.gamedev.net/topic/638951-putting-pieces-inside-a-board/#entry5033580

at the bottom of the homework instructions posted at the above site, it states clearly
"If you have questions, don't hesitate I will try to answer them."

what was your instructor's response?
asr era
Greenhorn

Joined: Feb 17, 2013
Posts: 4
It's not my instructor. I just googled the lab. Look above it says April 29.

I have a question: how can i put the pieces inside the board?

Do I have to do it after it lands or as soon as it appears?

And what if statement would I use? I don't understand how I could implement this...

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39869
    
  28
Where on earth did you find code with so many static members? Why are the move methods synchronised?
asr era
Greenhorn

Joined: Feb 17, 2013
Posts: 4
Campbell Ritchie wrote:Where on earth did you find code with so many static members? Why are the move methods synchronised?


I didn't program it. I am just implementing some algorithm to complete it.




if I want to put shapes inside board, this is what must be done, right?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39869
    
  28
Please tell us which website you found that on. All those static elements look like very poor design to me.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2596
    
    9

I see a "Tetris" class ... you making Tetris game?


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
asr era
Greenhorn

Joined: Feb 17, 2013
Posts: 4



How do I access int[ROWS][COLUMNS] outside?

I tried the following, but it doesn't work...



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Putting pieces inside a board