public class Exit
{
Room destination; //The room that the exit leads to
Room origin; //The room that the exit is in
String description;
/*NOTE: At some point, we will probably want to make these fields private, and create getter/setter methods for them. Notice that right now, they don't have any access modifiers (so no public, private, or protected), so they have default access, which means that any class in the same package can access them.
*/
public void showDescription()
{
System.out.println(description);
}
public void setDescription(String description)
{
this.description = description;
}
}
This is some basic code for an Exit class in our text-based RPG. It leads from one room to another. We'll likely make some significant changes to this class, such as making the fields private or protected.
A lot of this code might seem confusing if you're a new Java developer, but I'll be explaining it all in due time. If you'd like to start learning, I'm writing lessons and tutorials on Java game development here: https://itch.io/jam/summer-learn-java-jam-month-1/community
If you want to learn more about the game, The Java Secret, visit http://bit.ly/2K3mYoZ.
A lot of this code might seem confusing if you're a new Java developer, but I'll be explaining it all in due time. If you'd like to start learning, I'm writing lessons and tutorials on Java game development here: https://itch.io/jam/summer-learn-java-jam-month-1/community
If you want to learn more about the game, The Java Secret, visit http://bit.ly/2K3mYoZ.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.