Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] - Modular engine framework

Author
Message
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 14th Jan 2015 20:26
This is an abstract, modular framework which provides a solid foundation for building a more robust game engine.

It's used here to setup and run a simple 2d 'Breakout' like game level, and this is a trimmed down version of the same framework used to build my 3d RPG Sulium.

Utilizing a basic re-usable framework greatly speeds development time of new and different projects in much the same way a base mesh speeds 3d character modeling / scuplting. It provides something of a blank generic starting point instead of having to start from scratch all over again every time.

Keep in mind that most modules are still rather WIP, and can be improved upon in many places. The user_interface module in particular has a long list of TODO items and planned improvements.

Attachments

Login to view attachments
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 15th Jan 2015 05:57 Edited at: 15th Jan 2015 06:10
I use Indigo as my editor and simply adding .DBA files to the project is sufficient enough to include them. I haven't had to use the #INCLUDE command ever.

I'm liking the idea of a "Framework_Required" function. I've always struggled with knowing I need something similar to this... with my main problem not so much the module, but rather the version of the module. Such as, my keyboard module from 2015 not working with a project I wrote in 2014.

EDIT: Wait... did I just solve my own problem? By using the #INCLUDE command, does that allow me to dynamically attach .DBA files to my project?

Such as sudo;



HMMMMmmmmmm....

EDIT EDIT: Wah, but in further thinking, then I lose all the magic that the editor brings to the table in identifying variables, routines & functions.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 15th Jan 2015 07:32
Quote: "I use Indigo as my editor and simply adding .DBA files to the project is sufficient enough to include them. I haven't had to use the #INCLUDE command ever. "


But then you have to go and re-add them through a file dialog on every project no? This would get tedious, with #INCLUDE you can just comment/uncomment an #INCLUDE line to manage which files are linked and which are not.

Quote: "By using the #INCLUDE command, does that allow me to dynamically attach .DBA files to my project? "


Sort of. I set the module loader up with a similar thought in mind, the intention being that if I didn't execute a call to require a module it wouldn't get included, but I believe it ended up attaching any #INCLUDE that wasn't commented out even if the flow of execution didn't actually process the command. Simply being uncommented in the source anywhere is enough to get it compiled in. Like if I never made a call to require a given module, the source was still compiled in, but it's initialization routines will not run until/unless the require call is made.

If you truly don't want a module included at all, the #INCLUDE line and following gosub have to be commented out, otherwise it will be included but remain inactive until required. The framework_require is mostly useful for managing the initialization routines and in preventing a module that is required by multiple other modules from initializing multiple times.

I also really wanted the ability to include files based on dynamic concatenation, something like #INCLUDE "modules/guiDocs/" + reqDoc$ + ".dba" I always found this handy in php, but unfortunately DBpro can only include literal file strings.

One major change I plan to make are the TODOs listed here:



managing priority values manually has proved to be problematic, with updates processing in un-intended orders at times if I'm not careful. I will be changing this so that instead of setting a priority, an update function can provide a list of other updates it depends on and requires so that if all pre-req updates have not completed for a given update, it will defer until they have. The gui element processing does something similar to this when an element's parent has not yet been resolved, it will defer until it has.

Quote: "Wah, but in further thinking, then I lose all the magic that the editor brings to the table in identifying variables, routines & functions."


Hmm, I actually use the IDE pretty much only to compile and occasionally to lookup command syntax/parameters in the help. I do virtually all of my actual coding in notepad++ It has a lot of nice tools and plugins for text editing, bookmarks/jumps, regex, side by side diff comparison, split screen and cloning, syntax highlighting though that gets a bit limited when dealing with DBpro commands due to spacing. Attached is a language definition for DBpro that can be imported for the syntax/commands it is able to work with.

I guess I just haven't found navigating routines/functions to be much of an issue, by organizing and breaking the code up into modules, the file and function naming conventions narrow the search to reasonable sized collection in most cases, and all functions / notable variables are summarized in the file headers for quick searching and explanation. In a large module like the UI, I work on the left side, clone it over to the right side and keep the clone on the header for reference.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-21 11:30:04
Your offset time is: 2024-11-21 11:30:04