• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Putting pieces inside a board

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...

 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



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

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



 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic