• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Public functions

Wingnut

Well-known member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
1,414
What's the prefferable way in Cerberus when you want to offload your main and move some functions
into a external.cxs laying beside the main.cxs (not inside modules).
 
Not sure what you mean. All Cerberus source files are modules and imported the same way regardless, but the general convention is to have the program entry function coupled with the core mojo class in the same source file. Additional sub classes are imported, but here are some rules.

All classes, function,etc in sources are public, unless the Private keyword is declared somewhere.
The private keyword only takes affect at the module scope level and not the class scope. This means that the same source file, all classes and functions are public regardless if anything was declared private inside or outside a class.
 
Last edited:
Not sure what you mean
Same here. Maybe you can ask a bit more specifically. With your question a lot of things come to mind regarding the structure of a cerberus project:
Folder structure, file naming, file size, interdependencies, class and/or function modules, modules_ext folder, native files etc.
 
What's the prefferable way in Cerberus when you want to offload your main and move some functions
into a external.cxs laying beside the main.cxs (not inside modules).
To each their own I would say. I have projects where everything is in one file. Then I have projects where every class is in their own file. I have projects where functions are in their own file. It is up to you how you want to structure your own code.
 
I have projects where everything is in one file. Then I have projects where every class is in their own file.
For me. It depends on the size of the project. The more complex, the more modular the directory tree and file hierarchy should be for easy code locating.
 
Thanks. Okay I'm starting to get a lot of functions recently and I want to lay them off into a separate functions.cxs and somehow include it into my main?

EDIT Sorry, what I mean is, should imported .cxs files be inside the data folder or should all cxs be in one place?
 
Last edited:
Besides functions, I also created a lot of methods inside the main class (Class Game Extends App) right now.

How can you drag them out a file?
 
should imported .cxs files be inside the data folder or should all cxs be in one place?
They should not be in teh data folder. There should only reside the resources of your app and they are copied to stay available at runtime. On the other hand your .cxs files are only needed at compiletime and they all result in the executable file afterwards.
If you have a lot of interdependency in your source you could for example have a imports.cxs file inside a "imports" folder next to your yourmainfile.cxs. imports.cxs only consists of the import directives for all the common modules you use. And you can put them all inside the "imports" folder.

I also created a lot of methods inside the main class (Class Game Extends App) right now.

How can you drag them out a file?
I don't think you can, but you could think about an other way of structuring your code in this case. For larger projects I prefer an Game class that is as short and as readable as possible, so you can easily grasp what the main funcionality is about.
 
You can't seem to have several classes that extends from App.

So I converted methods into functions (example below) which only gives me "Error: Type'Canvas' not found" as it wants to have App-related types like the canvas?

Function explosion:Int(grassland:Canvas,x:Int,y:Int,a:Int,b:Int:a)
...
Return 0
End
 
That's what I mean by high interdependency. If you do the "imports.cxs" thing, you can write "Import imports" in all files that need access to those things. In your case you would have to have "import mojo2" inside imports.cxs.
 
This works out pretty good. Thanks! (y)
 
Back
Top Bottom