6 Common MISTAKES and FIXES for this video below!!!
1. The MyWorld and ShipPlayer classes are not needed if you are just doing the Maze Game!!! I skipped “how to install Greenfoot” and “basic intro” that I did for the 6 hour FULL COURSE on YouTube.
2. If your MazeBlocks are lining up vertically on the left side after you multiply by 50, you need to go back to the MazeWorld class and multiply the x – value by 50 as well.
3. If your MazeBlocks are lining up at the bottom left and bottom right, you need to go back to the MazeWorld class and make
super(12, 12, 50); and change it to super(600, 600, 1);
4. If it bothers you that everything gets shifted up and to the left 25 pixels after you design it.
You can +25 to the x and y to all the MazeBlocks (unlikely you will want to do that), shrink the map 25 pixes to 575 x 575 connecting the bottom and right side, or just add a couple blocks in to fill in the spaces and save the world.
5. Moving issues – Simply double check the Movers class that it has all the different move methods. Make sure MazeRunner extends Movers (MazeRunner is subclass of Movers). Make sure the move method you are chosing is in the act method. Otherwise it is probably something simple in your if-statement. Other problems feel free to leave a detailed comment below (preferably with your code).
6. Walks through walls problems. Double check your move method. The only move method I had that interacted with the wall was the slideAround(). Make sure your code only has the method that you want and that method has interaction with walls. Here is an EDITED moveAndTurn method should look something like this.
public void moveAndTurn()
{
if (Greenfoot.isKeyDown(“d”))
{
setRotation(0);
setLocation(getX() + 4, getY());
if( hitWall() )
{
setLocation(getX() – 4, getY())
}
}
}
// And keep doing that for each direction. The move(int) method doesn’t work well with wall interaction.
We will develop our first game of my 6 hour course here. The Maze Game. This will start as if the watcher has 0 programming or Greenfoot knowledge and we will go from there. You will use examples the following programming topics in this game:
Classes & Objects
Methods
If and else if statements
Constructor Method
Return types
Parameters
Data Types
Variables
And much more!
As always after a tutorial you should use what you know on a project of your own creation.
Twitter: @tanner_crow
IG : java.teacher
Nguồn: https://zagran-tour.com/
Xem thêm bài viết khác: https://zagran-tour.com/game/
Wheres the link to the source code?
How you create a object just clicking?
10/10 would subscribe if you do Minecraft let’s plays
This video helped a lot, thanks!