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.

Newcomers DBPro Corner / read gosub from text file?

Author
Message
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 21st Jun 2011 16:19
is it possible to read a gosub from a text file,like an enemy gosub & actually run it to control the enemies code??

if so anyone have an example code i can study??
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 21st Jun 2011 17:18
Nah, if you want to run 'code' from an external text file within your game, then you'll need to include some form of scripting language into your game. There are some available for Dbpro though, just search for LUA.


Although, that's generally overkill, as you can often externalize game data without going to such extremes. You'll need to be more specific ab out what you're trying to do here though..

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 21st Jun 2011 18:01
Quote: "you can often externalize game data without going to such extremes"


Just to back Kevin up on what he is saying here: My latest game has an ini file with all the physics settings for friction, speed, screen colours etc. I can change the way the game behaves by changing the ini file, the game executable does not have to be recompiled.

David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 21st Jun 2011 18:19
dang! i was hoping it was possible.
i mainly want 2 cut the length of my code down,im making a huge rpg & its currently past 80k lines. takes my sorry pc almost 15 min 2 compile everytiime i test.

guess ill get a new pc,compile time should be cut in half i think.also fr will be alot better.
tks 4 the info!
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 21st Jun 2011 19:55
ouch, 15 minutes is a long long time.. So in your code are you including the character /envionment data / text/ dialogs etc etc all in source code ? - If so, then this type of stuff can often be separated from the program fairly easily.

There is the LUA option don't forget, it's a plug in language.. It'll mean converting your Dbpro code across, but it might well be an option in your situation.

You could write your own scripting system, it's not that difficult. Provided you keep it as simple and as high level as possible. So the script instructions try to do big things, rather than lots micro management of low level things.

For example.. I've been writing a new web site back end lately, I wanted to seperate code and data completely. For what i've in mind, meant build a sort of custom mark up language. I suspect you could do something along those lines.

I've no idea what data you have in your game, but lets say there's a conversation dialog with another character. So the script for this interaction, wouldn't just be the text, but it'd include with some OPCODES embedded with it in. So the game engine parsers this text and reacts Opcodes, so the opcodes could be things like, checks for the time of day, the sex of player, time of day.. etc etc.. whatever you need

The idea would be to have a handful of these opcodes, so the parser steps through the text making choices, in order to get to what it's after. So the reaction appears dynamic.

David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 22nd Jun 2011 02:43 Edited at: 22nd Jun 2011 04:24
well im not a hard core programmer.im mainly a 3d artist/animator but i can figure things out in dbp & get things 2 work.i keep learning better ways 2 code,then i go back 2 some old code,& i tell myself what was i thinking? lol

i thought i read somewhere on this forum that u can load your level by opening files & reading them..???? is this possible,surely it is!!
that alone would save huge lines of code!
i looked into the include command of including other dbp dbas. that was easy,but that doesnt cut compile time down at all! i think dbp compiles the included dba along with your main dba.


edit: well i timed it & its only 10 min 4 my game 2 compile.but thats still a longgggg time
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 22nd Jun 2011 09:49
You can definitely externalize game data, how hard that will be for you, depends upon how it's currently stored within your program. I should point out, that converting this stuff is often not necessarily hard to program, it's more a conceptual challenge.


Normally, it's best to store anything that's data related outside of the program code and in files. The file data is then loaded into the program while the game is executing (Look up the file commands in DBpro for how to do this). The format of the files your game uses is up to you. But you can store all the info about the characters etc in them. For example, Stuff like, names, positions, colours, inventories, favorite beers... whatever..

There's an example (In PlayBASIC) of doing something like this on my forum. Entity Example (Loading Game Levels

Shamus The Shadow Case (A game written for a DarkBASIC compo years and years ago) uses a similar system to store all the game data in. I don't think the src is in the package, but the levels are stored as text files (from memory). So perhaps looking at whats stored within them, will give you some ideas for your game.

In Shamus, the project was built in two parts. There's the game engine and the level editor. The level editor is for the artist/designer. It's a no thrills tool to handle the object placement/collision & all definitions needed. Doesn't have to be pretty, just functional. The game engine, loads whatever level it's pointed at and plays it. This structure allows the game to modified, without changing the game source code constantly.


There's bound to be lots of existing discussions/examples on the boards here also. Try searching for "file format" (TDK's File Formats or even "World Editor", "Matrix Editors" examples. The latter might be useful to look at, so you can see how others go about building tools to setup the game world data in Dbpro. This should give you some ideas on making your own game editors.

Well, best of luck..

David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 22nd Jun 2011 15:51
ok thanks for all your help!

Login to post a reply

Server time is: 2024-11-27 21:47:27
Your offset time is: 2024-11-27 21:47:27