Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Putting pieces inside a board

 
asr era
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49789
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where on earth did you find code with so many static members? Why are the move methods synchronised?
 
asr era
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49789
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please tell us which website you found that on. All those static elements look like very poor design to me.
 
K. Tsang
Bartender
Posts: 3504
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see a "Tetris" class ... you making Tetris game?
 
asr era
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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

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



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic