aviks / GameZero.jl

Zero overhead game development library for the Julia programming language
Other
184 stars 23 forks source link

Impossible to include other files in the game #52

Open GabrielTavarez opened 2 years ago

GabrielTavarez commented 2 years ago

It would be great to have 1 file that contains the game and include other files that contains the structs created in the game.

I was tring to make a game.jl that had "include(snake.jl)".

In game.jl, all the loops and conditions would be verified, while the snake.jl file would have the definition of the struct snake and its methods. But when i try to do "include(snake.jl)" I get "LoadError: UndefVarError: include not defined".

Apperantly, there's no function "include" in gamezero, or it erases the base function from julia. I don't uderstand exactly

aviks commented 2 years ago

See the changes in this PR if it helps: https://github.com/aviks/GameZero.jl/pull/38

The stuff in that PR should probably be better documented.

BatyLeo commented 1 year ago

Hello, I have the same issue, everything works well when I have only one file, I face an error when trying to include other files. I tried following the instructions in the linked PR, but I get a LoadError: UndefRefError: access to undefined reference.

scottbigbrain commented 1 year ago

Hello, I have the same issue, everything works well when I have only one file, I face an error when trying to include other files. I tried following the instructions in the linked PR, but I get a LoadError: UndefRefError: access to undefined reference.

You can use game_include("yourefile.jl"), as was added in #22. Documentation should probably be added for that, sorry

BatyLeo commented 1 year ago

Thank you for your help, I'll try that ! Another solution I found is to put the external code inside a package/module.

scottbigbrain commented 1 year ago

Yeah, that works too