Last modified: January 26, 2023
Homework 2 - Core Game Mechanics
Part 1:
In HW 2, you will be implementing the core game mechanics for your game. For example, if your game was a platformer, you would want to implement movement, jumping, and platform physics (so the player can stand on platforms). Implement the core mechanics of your game. Don't worry about graphics yet - just use placeholders for now.
- Plan out what classes you will need to implement the core game mechanics of your game and write out a description in the Class Design and Brainstorm section of your README.md
- Each team member should implement at least one class.
- You should delete the classes you made temporarily while learning git
- You should have the core game mechanics working for your game, which means you will likely end up with more than 3 classes, but you should certainly have at least 3.
- Make sure you update your journals to keep a log of what you have done. Entries should be labeled with what you did in class and what you did at home, along with an estimate of time each day you work. See the example journal shown in Homework 1.
- For submission, simply make sure your final version has been pushed to your git repository.
If you are tired of continuously getting merge conflicts within the project.greenfoot file, you could add it to the .gitignore:
- From GitHub Desktop, go to the menu Repository → Open in terminal (mac) or Open in Command Prompt (windows)
Type in the following command:
git rm --cached project.greenfoot
From GitHub Desktop, go to the menu Repository → Show in Finder (mac) or Show in Explorer (windows)
- For Mac: Press command + shift + . (Command + Shift + Period) to see hidden files (files starting with .)
- For Windows: go to the view menu in a file explorer window and check the box for hidden items:
![](/static/lessons/A6/Windows_Add_To_Gitignore.png)
- Right-click on the .gitignore file and open it with TextEdit (mac) or Note Pad (Windows) or some other plain text editor.
- Write the following line in the file: *.greenfoot.
The only downside to adding project.greenfoot to the .gitignore file in git is greenfoot will no longer update which image is associated with which class. You can resolve that issue by adding code in the constructor for each class that explicitly sets the image to the desired image rather than depending on the greenfoot setting.
Example:
public class Apple extends Actor {
public Apple() {
setImage("apple1.png");
}
}
Problem: Oh noes! My teammate deleted files/changes I had committed! D:
Here is how you can recover files from old commits:
- First commit and push, discard or stash any uncommitted changes so you have a clean working directory.
- Go to the “History” tab in GitHub Desktop and find the most recent commit that has the changes you lost.
- Right-click on the desired commit and select the create branch from commit option.
- You can name your branch anything you like, but note that the name cannot contain spaces.
- Explanation: branches are a way to save different versions of your project with different commits and files. You can switch back and forth between branches and Git will simply make your project folder have the correct content for that branch whenever you switch. We recommend always committing uncommitted changes when switching branches unless you want the changes to get moved to the new branch.
- Go to the menu option repository → show in explorer (Windows) or repository → show in finder (Mac).
- Copy the file(s) you want to restore from your project folder to another location like the desktop.
- Click on the big left of the “fetch” button that says “Current Branch” and switch back to the main branch.
- Copy the recovered file(s) from the desktop back into your project folder in the file explorer/finder
- Commit and push your changes in GitHub Desktop.
Problem solved! That's super cool!