Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

How to open the scenario in Greenfoot? #77

Open
LittleBenjiBoy opened this issue Apr 28, 2022 · 6 comments
Open

How to open the scenario in Greenfoot? #77

LittleBenjiBoy opened this issue Apr 28, 2022 · 6 comments

Comments

@LittleBenjiBoy
Copy link

I downloaded the master branch as a zip and I opened the project.greenfoot file in soultraps-master\src\main\resources with Greenfoot and it opened an empty scenario. Can you give instructions on how to open the game with Greenfoot?

Thanks in advance

@lfuelling
Copy link
Owner

lfuelling commented Apr 28, 2022

Hi,

the short answer is: You can't. The greenfoot file is there only because the engine needs it when the game is run as a java program, it's not a proper project file.

Soultraps is a Maven project, you'll need to install Maven and use the mvn clean package command to create the target/soultraps.jar file which then can be executed using java -jar target/name-of.jar.

You can also use an IDE like IntelliJ or Eclipse to edit the source code and run the program from within the IDE.

If you want more information on how/why I did this, please check out my blog post about using Greenfoot without having to use the Greenfoot IDE :)

@lfuelling
Copy link
Owner

lfuelling commented Apr 28, 2022

Here's the long answer on how to run this, using IntelliJ (I tested it on macOS, should also work on Linux and WIndows, although the screenshots will look a bit different):

  1. Download the zip and extract (or clone the repo using git)
  2. Download IntelliJ (there is either a free "community edition" or a 30 day trail for the "ultimate edition", community is fine for this) using the link above
  3. Open IntelliJ and in the initial window select "Open"
  4. In the file dialog that appears, select the soultraps folder (where the pom.xml is located) and click "open"
  5. Open the "File" menu and select "Project Structure":
    The File Menu
  6. In the structure window, select the SDK dropdown and click "Download SDK":
    The SDK menu
  7. Select Java Version 1.8 (I'm using the Bellsoft JDK, others should work too) and click download:
    The download selector
  8. Click "Apply" in the project structure window and close it
  9. Click the "Add Configuration" button:
    The 'add configuration' button
  10. In the new window, click the plus sign and select "Application":
    The 'add' menu
  11. Fill out the form like shown in this screenshot:
    The application config
  12. You can now start the game using the "play" button:
    The "run" button

@LittleBenjiBoy
Copy link
Author

Hello!

Thanks so much for the detailed explanation on how to get this game running. After following all your steps, I was not able to get the game running. I would get this error: "soultraps-master\src\main\java\io\lerk\soultraps\levels\Level.java:15:19
java: package javafx.util does not exist". I had to add the JavaFX.jar files to the Project Structure in Libraries, but even then, while the game was running, I was getting too many errors, like: java.io.IOException: Problem reading font data. The game's fonts weren't able to load like the one showed in the .gif that you have in the readme.

Anyway, I wanted to be able to run this game solely using Greenfoot because I need to code a game with Greenfoot for a school project and wanted to get coding ideas, but thanks for your response and information. I will be sure to check out your site and read your blog post :).

@lfuelling
Copy link
Owner

lfuelling commented Apr 29, 2022

No problem :)

Depending on your operating system you might need to use another JDK (install or set it using the project structure window).
Maybe try installing Oracle 1.8 (although their website is a nightmare), this should contain JavaFX for most platforms.

EDIT: I totally forgot that there is a prebuilt jar for v0.0.3.
If you just want to run the game and debugging is not important you can use that.

@LittleBenjiBoy
Copy link
Author

Yeah lol, their website is a nightmare. I had to depend on google to help me with all these JavaFX issues. I'm really a newbie when it comes to programming. My operating system is Windows 10.

When I would try to run the prebuilt jar for v0.0.3 through CMD, I would get this error (I think it's a JavaFX issue):
image

Troubleshooting info:
My versions of java are:
image

JDK Version:
image

@lfuelling
Copy link
Owner

lfuelling commented Apr 29, 2022

The javac version seems to be wrong, it should be something like ~1.8. Try running java -version in the shell, I assume the Java version is not 1.8. Java >= 11 does not include JavaFX and thus causes the class not found error.

This could be fixed by setting the JAVA_HOME environment variable to the path of the version of Java you want to use, but I don't know how to do that on Windows unfortunately 🙈
It could also be that there is a GUI way to do this, and that changing JAVA_HOME is not the correct way to set the Java version on Windows.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants