Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
418 views
in Technique[技术] by (71.8m points)

java - 运行2D游戏的配置IntelliJ(Run configuration IntelliJ for 2D game)

I was importing the source code of a Java game to my local IntelliJ (community edition 2.3.2019) and try to make it run.

(我正在将Java游戏的源代码导入本地IntelliJ(社区版本2.3.2019),并尝试使其运行。)

I'm new to Java btw.

(我是Java的新手。)

I got the code from here: https://github.com/janbodnar/Java-Space-Invaders

(我从这里获得了代码: https : //github.com/janbodnar/Java-Space-Invaders)

What I did is download the code from the repo, export the zip file in a folder and import it as a project in IntelliJ.

(我所做的就是从存储库中下载代码,将zip文件导出到一个文件夹中,然后将其导入为IntelliJ中的项目。)

After importing a lot of my project files appear red as you can see here: IntelliJ red icons

(导入后,很多项目文件都显示为红色,如下所示: IntelliJ红色图标)

My first question is: Why are these icons red?

(我的第一个问题是:为什么这些图标是红色的?)

And how can I find out why IntelliJ is marking them red?

(我如何找出IntelliJ为什么将它们标记为红色?)

I tried by hovering over these icons, but nothing happens / indicates what's wrong.

(我将鼠标悬停在这些图标上,但没有任何反应/表明出了什么问题。)

Also: Afaik in order to make this project run I need to take care of the run configuration.

(另外:Afaik为了使这个项目运行,我需要注意运行配置。)

I tried this, but the main class is not choosable if I choose the path com.zetcode.SpaceInvaders.java (where the main class is part of the code).

(我试过了,但是如果我选择路径com.zetcode.SpaceInvaders.java(其中主类是代码的一部分),则主类是不可选的。)

What am I doing wrong?

(我究竟做错了什么?)

How can I run this project/code in IntelliJ?

(如何在IntelliJ中运行此项目/代码?)

Many thanks in advance.

(提前谢谢了。)

  ask by doct0re translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to follow these steps: 1. IntelliJ -> New Project-> Project from existing resources(the unzipped code directory).

(您需要执行以下步骤:1. IntelliJ-> New Project->现有资源中的项目(解压缩的代码目录)。)

2. Follow the next steps as given by project explorer.

(2.遵循项目浏览器给出的下一步。)

3. Remember this project uses jdk above 10 as it uses "var" keyword.

(3.请记住,该项目使用10以上的jdk,因为它使用“ var”关键字。)

4. So, go to the project settings if the jdk in step 2 was selected below 10. I couldn't see any red marked files.

(4.因此,如果在步骤10中选择了第2步中的jdk,请转到项目设置。我看不到任何带有红色标记的文件。)

I just ran the SpaceInvaders.java file to run the project & the game started.

(我只是运行SpaceInvaders.java文件来运行项目,然后游戏开始了。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...