Results 1 to 5 of 5
  1. #1
    Schnensch is offline New to Programming
    Join Date
    May 2014
    Location
    Germany
    Posts
    4
    Rep Power
    0

    Question Java Tetris Spiel. Bitte um Hilfe

    Hi, i used this tut to program a tetris game http://zetcode.com/tutorials/javagamestutorial/tetris/ . But Eclipse says that something is wrong in the code and i dont know/get what. Maybe someone here can help me.
    Heres the eclipse package: *** Link removed See below


    Schnensch

    EDIT: sorry, i mixed up the 2 forums i used to post this qeustion. my bad. thought this was the german one. im a bit confused today
    Last edited by Norm; 05-17-2014 at 04:27 PM. Reason: Removed link to malware

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,321
    Rep Power
    25

    Default Re: Java Tetris Spiel. Bitte um Hilfe

    Please post in English
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Java Tetris Spiel. Bitte um Hilfe

    Just a few points I want to mention:
    a) The location you have choosen to upload the file seems wired to me. The first try I clicked on a download link and ended up with a tetris.zip.exe. I do not want to know what would have been inside there... But heya - I got some nice girls on my screen, so why do I complain? :) (So as I said: really wired site!)
    b) You could simply post the code directly in here. The problem is inside Board.java and you could simply tell us the error message you got together with the code.

    The problem is quite easy:
    Java Code:
                    for (int i=0; i < 4; ++i); {
    			int x = curX + curPiece.x(i);
    			int y = curY - curPiece.y(i);
    			board[(y * BoardWidth) + x] = curPiece.getShape();
    		}
    The for loop either takes one command (then only that command is inside the loop) or instead of one command a block { ... }.
    Your for loop has just a ";" which can be seen as an "empty command".

    So if you use eclipse: Remember the following Keystroke: Shift + Ctrl + F
    That will reformat your code. So after Shift + Ctrl + F we get:
    Java Code:
    		for (int i = 0; i < 4; ++i)
    			;
    		{
    			int x = curX + curPiece.x(i);
    			int y = curY - curPiece.y(i);
    			board[(y * BoardWidth) + x] = curPiece.getShape();
    		}
    I hope the indentation is shown in the forum. So you see that the for loop is just the ; and then you open a new block of code (which is legal and could be used (as an example) to have a special range for a local variable.)

    So your local variable i is local to the for loop. Your block of code comes after the for loop so i is unknown there (and that is the error message you get).

    With kind regards,

    Konrad

    Edit: The 2nd error in there is that you call "dropDown();" but there is no such method defined. So maybe you forgot to implement that method.
    Last edited by kneitzel; 05-17-2014 at 04:25 PM.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,321
    Rep Power
    25

    Default Re: Java Tetris Spiel. Bitte um Hilfe

    I clicked on a download link and ended up with a tetris.zip.exe.
    That looks like an attempt to load malware onto your computer. I'm removing the link so no one else can get infected.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Schnensch is offline New to Programming
    Join Date
    May 2014
    Location
    Germany
    Posts
    4
    Rep Power
    0

    Default Re: Java Tetris Spiel. Bitte um Hilfe

    Im sorry for the upload. I only googled "file hochladen" (i live in germany, so thats why) and just uploaded the .zip. I dont know what happend. Im very sorry :/

    Thanks for the answer. I will have a look into it when got the time today.

Similar Threads

  1. In.open() hilfe...
    By BlueJ_Grünschnabl in forum New To Java
    Replies: 1
    Last Post: 07-01-2013, 10:22 PM
  2. Replies: 6
    Last Post: 06-13-2013, 03:36 PM
  3. Java Tetris 1.0
    By levent in forum Java Software
    Replies: 1
    Last Post: 01-07-2012, 08:07 AM
  4. Normal tetris transform to Tetris with MVC.
    By kuburoman in forum Advanced Java
    Replies: 1
    Last Post: 04-24-2011, 10:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •