#code layout for game engine

1 messages · Page 1 of 1 (latest)

thin nacelle
#

im coding a game engine and i want to be able to import engine.NPC; but when i make the layout like that, my packages are src.game; instead of game;

folder layout for CodingEngine:

src - game - App.java
bin
engine - NPC.java

what layout would the correct way be?
also my engine is kinda like a library but idk how to use lib and im also editing it actively so might ask later how to do that

barren rockBOT
#

This post has been reserved for your question.

Hey @thin nacelle! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

ripe dune
#

Your source code should be all under src. Your resources too. In fact, beside the readme and builder instructions, not much is supposed to be outside of src

#

If your engine is meant to be a library, it should either be in another project, or your project should be a multiproject, when engine and app are two subprojects

thin nacelle
#

i would show you the full folder layout but linux isnt opening 3D_Laugh

thin nacelle
ripe dune
#

Same way you import any other stuff in a project

thin nacelle
#

but if its not in the package how would i find it in import

ripe dune
#

Same way it works when you use any other library

thin nacelle
#

uh

#

i never used a library before

#

im new-ish so im trying to do everything on my own for learning

ripe dune
#

but you're thinking of making part of your code a library?

#

I suggest reading a book before writing one. This is the same here

thin nacelle
#

if im being honest its because build tools cant run on my machine lol

#

and its being used like a library, but its not a json file

#

its just a project with java files (usually abstract) which im going to use to make a game engine

#

this might help

ripe crater
#

tree command maybe

ripe dune
# thin nacelle this might help

This doesn't change anything to what I said. I guess if you insist, you just need to make different folders that each have a src folder

thin nacelle
ripe dune
#

yup

#

Then set both src folders as source directories

thin nacelle
#

Source directories?

#

Damn brb googlin

thin nacelle
#

ok i cant find anything about source directories besides maven

#

what do you mean

#

and what should the package look like in App.java and Player.java

ripe dune
#

.... So, what are you using to program? What IDE, what build tool if any?

thin nacelle
#

i dont use a build tool and i use vi to code, but i can run vscode just takes 20m to load

ripe dune
#

.... Okay then the concept of source directory doesn't exist

#

Instead you'll need the more complicated concept of classpath

#

You'll compile Engine as usual

#

And You'll comple App by using as classpath the directory that contains the classes of Engine

thin nacelle
#

when you mean as usual do you mean compile the src folder to a bin folder or compile into engine with the .java files

thin nacelle
ripe dune
thin nacelle
#

will i have to import engine.bin.this; or can i import engine.this; if i use bin

#

actually ill research first it might answer

thin nacelle
#

i just tried using them both in one big directory but it wont find the import

ripe dune
#

It's so tiring having to explain that, we can't guess what do you mean.
What is that, "using them both in one big directory"?

thin nacelle
#

i showed in the screenshot

#

it cant find engine

#

but the package engine; command works fine in Player.java

ripe dune
thin nacelle
#

the error

#

the App.java code

ripe dune
thin nacelle
#

does codingEngine not count as a directory

ripe dune
#

Who cares, since there is more than one src

thin nacelle
#

so i should put one big src with engine and game in the src folder?

ripe dune
thin nacelle
#

it works now thanks

barren rockBOT
# thin nacelle it works now thanks

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.