Java: Advanced Game Development
February 17, 2018
Jet (AM Class): What's wrong with the image I'm using in Avoider Game?
In general, background images should be the same size as your world. If the image is smaller than the world, the background image is tiled in the background of the world.
For the Avoider Game, these images should work for you.
Evan (PM Class): I was wondering if there was a way I could export it as a .exe so I could brag to my friends that I made and game and send it to them.
To learn how to share Greenfoot games, see the video below:
Rohan (AM Class): Why does the ColorSniffer goes half through the wall and then stop? Pretty sure it just tests for middle of the character, not the whole character.
You're right. The ColorSniffer that I posted earlier just uses the getColorAt method in the GreenfootImage class to get the color at one particular point in the background--the point at the ColorSniffer's (x,y) coordinates. For Actors, getX() and getY() give the x and y coordinates of the center of the Actor's image.
Download Maze2.0x for a version of the Maze program that checks to see if the wall color is anywhere under the bounding box of the ColorSniffer's image. Open up the code for the ColorSniffer class and scroll down to the bottom to see the changes that make use of the bounding box.
You'll also find a couple of subclasses added (the "x" in Maze2.0x is for "eXtended"). The subclasses inherit behaviors from the ColorSniffer class and extend them by adding keyboard control (ColorBumper) or random movement (ColorEnemy).
Zach (AM Class): How can I use strings to have my player and an actor have a conversation?
February 10, 2018
MacOS: keyboard glitches / certain keys stop working
On recent versions of MacOS, certain keys may seem to occasionally stop working temporarily or permanently (until Greenfoot is restarted). This is due to the "press-and-hold for accented characters" functionality in MacOS interfering with regular keyboard input.
The solution is to disable this functionality, which can only be done via the Terminal application. Open it and enter the following command:
defaults write -g ApplePressAndHoldEnabled -bool false
To re-enable the press-and-hold functionality, use this command:
defaults write -g ApplePressAndHoldEnabled -bool true
Unfortunately, there is no way to disable this function just for Greenfoot — turning it on or off affects all applications.
Today, we'll try to set aside time for Avoider Game, CodingBat, Quizlet Live, and some independent project work. I added some video to answer some of the FAQs I've gotten in the last couple of weeks. They might come in handy for your individual work.
Adrian (AM class): How can an actor detect a wall?
Here is the image I used for the maze background:
Zach (AM class): How can one actor can remove another actor from the world?
Using the Animal class
If you'd like a peek at the code in the Animal class, watch the video below:
Zach (AM class): How can I make a title screen?
Creating the title screen
Managing the title screen and play screen
Zach (AM class): How can I set add my own images and set them to the actor's image?
Once you have an image file with the image you want, setting the image of your actor is easy.
If an image isn't the right size, you can use code to resize it in Greenfoot.
Zach (AM class): How can I display information about collisions?
Alex (AM class): I want to continue my Sandbox game.
February 3, 2018
So far, we've gotten down the basics of Java and Greenfoot, and I've seen some interesting starts on games.
I'd like you guys to have some free time today develop your games further or do some more CodingBat practice. However, to improve your coding skils and start or further develop your games, we need to take some time to go deeper into Greenfoot first.
To do that, we'll spend our first hour or so on the Avoider Game, using a programming strategy called pair programming.
Do's and Don'ts of Pair Programming
Remember the Do's and Don'ts explained in the video:
It does not matter how slowly you go as long as you do not stop. ― Confucius
Our pair programming task for today is Avoider Game Part 1. The Navigator should have the web page open in front of him. The Driver should create the scenario.
For the AM class, we'll randomly pick partners with the student shuffle scenario.
Independent Work Period
When you have finished pair programming (Avoider Game Part 1), you can do any of the following:
January 27, 2018
I got some questions in last week's reflections:
Here is an FAQ project with answers and hints to help you.
Continue working on String-1. If you finish that, go on to Logic-1.
Java Concept Review
Are you ready for Quizlet live?
Independent work time
During independent work time, you can work on CodingBat, review Java concepts to get ready for Quizlet live, or work on a project idea of your own.
We'll watch a video on pair programming today and practice pair programming with the Avoider Game. If you've already done work on Avoider, let me know where you're at with it.
January 20, 2018
Students will need email addresses to sign in to CodingBat and submit reflections. Send an email message to firstname.lastname@example.org with JAGD in the subject line.
We'll introduce ourselves, discuss bathrooms, snacks and other important matters, and take a survey.
Work at your own pace
The main reason for the survey I'm giving is to make sure you're getting work that's the right level of challenge for you. You'll also have the opportunity to email reflections to me at end of each class to let me know how things are going. If you're feeling overwhelmed, I'll provide more background material. If you're feeling bored, I'll find you some work at a higher level of challenge.
We will spend a significant amount in independent work periods. There may be specific tasks that need to be completed, or there may be different choices depending on where you're at in your work.
If it looks like you don't have anything to do, I'll check in with you, but you don't have to wait for me. When you finish one activity and you're not sure what to do next, look on this announcements page. Find something that will help you develop as a programmer. If you need help figuring that out, ask.
Your first task for this morning is your survey. If your class meets from 9am to 11:30am, take the AM Student Survey.
If your class meets from noon to 2:30pm, take the PM Student Survey.
The videos below discuss the things you need to know about return types, parameters, and Strings for today's CodingBat activities. If you're already comfortable with this material, you can skip down to the CodingBat video.
Not sure if you're comfortable? You can review the material anyway, or skip down to the CodingBat video and try out CodingBat. You can always come back to the review material if you need to.
Return types and parameters
Notice the download link below this video. You'll get best results from the video if you download the scenario and code along with me while you watch the videos.
Scenario download: CodingBat.zip (save and unzip before opening)
If need a review of basic game programming in Greenfoot, check out these tutorials:
Java Concept Review
If we have time, we'll play Quizlet live when you're done reviewing the material.