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.

DarkBASIC Professional Discussion / Idea: Modular Programming

Author
Message
Mage
12
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 1st Oct 2017 08:11
Sets of generic functions that are very polished, then able to be pasted into any new program to immediately provide functionality.
I have a few games and editors and I've been thinking. Program it really well, once.





It is better to program modular systems. For example a Bitmap Font system I drop a dozen functions into a program and a few files into the program directory and suddenly the program has fantastic text. I have another system that safely loads objects and textures, keeps track of them, skips loading a texture again if loaded, clones already loaded objects, and smartly deletes the asset if no longer needed. Instant optimized asset management.

In some programs I have a rudimentary textbox accept input. It's harder than it sounds. I was thinking I should work out the very best textbox, like support backspace (done), add a character marker, mouse support, edit the middle of the text not just the end. Have it use the Bitmap font system. Basically program it awesome and super efficient. Then I can drop those functions into any program I make and have awesome text input.

Then I thought if I can do this with text input, then why not add on to it with a basic dictionary support. Like have every text input broken up into words and sent to a word list file. Then when typing have it try and auto complete the word, press space and it auto completes. So doable. Great for editors, like typing dialog.

I was thinking the same thing about lists. Like a lot of times I need to vertically list selectable stuff like file names, quests, maps, stuff. It's usually real rudimentary like a for loop and some mouse click handling stuff. I could just program a really nice generic list with mouse over graphics, a scroll bar, mouse wheel scroll support. Maybe a generic folder loader for it too. Then any time a program needs an awesome list it's there.

I use a system that prevents the program from crashing when the screen is locked or a Full Screen app is minimized. Same deal.

I guess moving between projects it seems to me there are certain things that can be programmed really well once that can be shared between programs, immediately giving a huge benefit. Like a brand new game and instead of starting with an empty page you start with 20-30 functions and some sort of framework.


See my previous tip here...
https://forum.thegamecreators.com/thread/207584
seppgirty
FPSC Reloaded Backer
9
Years of Service
User Offline
Joined: 3rd Jul 2009
Location: pittsburgh, pa.
Posted: 1st Oct 2017 14:58
Some good advice there mage. you don't need to re invent the wheel every time. A great way to speed up development time.
gamer, lover, filmmaker
Ortu
DBPro Master
11
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 2nd Oct 2017 21:54
Yeah i agree. I've also been building out an abstract modular framework which provides these same sorts of generic reusable components throughout the work and discussion within my project wip thread.

Math module
Media module
Animation module
UI module
Logging and system utilities module
XML reader module
Sqlite module

So on and so on, easily ported from project to project because there is no project specific code in them.

Breaking things down like this makes them easier to maintain also
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Mage
12
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 3rd Oct 2017 07:26 Edited at: 3rd Oct 2017 08:46
Progress.

I worked on this for a day and things went very well. I first created a cool animated background and I notice it's a lot nicer to work with than a plain background. I'll do that a lot more often.



I implemented a listbox that handles mouse input, mouseovers, scrollbar, and truncates text that is too long. Labels, buttons with caption, grouped buttons. Sill planning to do 2 buttons with a caption (yes/no), textbox with all the refinements, a textbox with caption, and a textbox that autocompletes words.

Everything is completely dynamic. In the video I can even change the font and font size, the controls all adjust to the changes automatically.
The proper controls are triggered when the mouse button is released, everything highlights, no side effects.

Simple Flexible Code.

The code is extremely simple to use.

button = MButton_New("Press Here", x, y, width)

Then in a loop somewhere...

MButton_Draw(button)

The single function call handles everything including input. So clean and simple.

Then...

buttonpressed = MButton_GetSelected()



Faster Fonts.

I was also looking at performance. In the video there's something like 450 sprites on the screen because of the font system. All of the screen controls were taking about 4-5ms to draw. Then I thought I can optimize the font system by having each word generated as a single sprite, cached, and pasted to the screen. Cached words would expire after like 5 seconds if unused. Would reduce the sprite count to about 40. Possibly a 10x speed boost there.


Replies.

Ortu wrote: "So on and so on, easily ported from project to project because there is no project specific code in them.

Breaking things down like this makes them easier to maintain also"

Yes doing this ground work will make things so easy. Like I'll be able to make a control which is a group of other controls, like a whole file loading menu with all the refinements in one line of code. If I update something then just replace the generic functions. So easy.

seppgirty wrote: "Some good advice there mage. you don't need to re invent the wheel every time. A great way to speed up development time."

It's like you do things the hard way one time but in a way where you never have to do it again. Plus everything looks great and there's functionality and consistency.

Login to post a reply

Server time is: 2019-02-23 01:29:22
Your offset time is: 2019-02-23 01:29:22