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 / I have many generic programming question and about Language 1.hierarchy.

Author
Message
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 7th May 2011 19:37 Edited at: 7th May 2011 20:21
I would like to ask many questions , because I don't understand many things.

1st:

What #include function real does. (I use it to include some file of my code , I include my file of all data types)

What this means? If I include some file for example



I thing I include all data types of my game when the program starts.


2nd:

When we put local variables and when put global variables.

As I know global variables declared and the program access these variables in all functions.

As I know local variables declared and the program access them only inside of a function.

For example:



The out put would be

1
0

Problem , if I assume , I have one for next loop with variable all_monsters

I use to use this variable in all of my functions to index all my monsters in my game.

I use many variables as integers to scan all my for next loops and check all my data types.

Most of my data types are arrays.

For example:



This data type with name Stairs defined as my_stairs is a 2 dimensional array which I check all my levels and how many stairs I will have in my each level.

I include all my types in the top of my program with #include function and I define then as Global.

Which means all my data types are global and accessible from all functions.

But there is problem I am taking error 118
Runtime Error 118 - Array does not exist or array subscript out of bounds at line 10997

Nothing is out of bounds. When I put.



The error fixes.

So Data types in fact are not global.

3rd:

When I using some variable for some for next loop again even if I have defined as global variable , for example



The compiler generates error 118
Runtime Error 118 - Array does not exist or array subscript out of bounds at line 10997

But again there is nothing out of bounds , but the program don't know if the variable all_monsters which I use it because this variable , supposed to be global as I defined above but for and next loops doesn't recognize and I mean any variable.

And if I add this code.



And the error fixes again.

Insted I put it as global the compiler doesn't recognize it , when I need to have one for next loop , all looping variables must be local.

4th:

When I am defining one data type as global outside of my functions at the top of my source code with #include function , in fact it isn't local.
I must define it always as local inside my function.



Even if I have defined in my types.dba file above with #include function.

5th:

When I have one function in my game loop , or many many other functions in my game loop , and these functions have local dim some data type.

Is it possible the compilere drop an error , not enough memory to make such an array?

I got this error some time and remove the:




And the error was fixed , but the same error generated.

Runtime Error 118 - Array does not exist or array subscript out of bounds at line 11157

My program so far is 25000 lines , is it possible to not have enough memory to program any more?

And I don't have my program in one single file of source code , I have too many.

I have one srceenshot how my project is!!

6th

I am using fileblocks plugin to load all my data from my game , my graphics , my levels , my sprites everything.

When I loading my data I use this kind of code.



My engine uses one special mechanism to render my walls and I would like to ask about the limitation of fileblocks and if this is possible these limits increased.

For example.

I have all kind of my graphics categorized.

For example all WALLS starts with string 1
All Doors start with string 2

So lets explain about the category 1 walls.

The category 1 have and another one category WALLSETS

So I create a special string WALL_category+WALLSETS_category
The wallsets have the number of wallsets from 00 to 99

So I create this string 101.
After this , I need to use the wall graphic category , which is from 00 to 99 for example what kind of wall I have , 01 wall 02 flipped wall 03 window graphic 04 stairs graphic , etc.

So I add another string in my category:
WALL_category+WALLSETS_category+WALLGRAPHIC_category
10101

After that , I create another category the wall position , this is the 3D perspective of my walls in front of player , this category takes numbers from 01 to 23 , are the wall sprite positions to see the 3D corridors. So the wallstring is
WALL_category+WALLSETS_category+WALLGRAPHIC_category+WALL_positions
1010101
This is one million ten thousand and one hundred and one , image in darkbasic images.

I saw the limits in fileblocks is up to 2000000 in this level you are safe to program , after this the plugin makes bugs.

Do not tell me to change my engine , I will not and is the only way to implement my 3D walls.

I would like to ask which are the limits of fileblocks and which are the limits of images , sprites , musics , sounds in darkbasic.

I made many changes to small the numbers , you will say , who will create a game with 2 million images , I don't have 2 million images , but I use huge numbers to define my wallsets , my wall positions and my decorations in my game.

So far is good , but I feel , I am approaching the limits of the Language , some times my program is not working well and is not programming problem , but language limit problem.

Thank you very much , I thing there will be an answer for all of these rare questions.

Attachments

Login to view attachments
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 8th May 2011 00:37
I have one idea , might will fix this.

If I use GOSUBS insted of Functions , will all my variables are in Global scope?
Insted I use Draw_Walls_North fanction but Draw_Walls_North as a Label and call it with Gosub and then return it , will my variables inside my Gosub are all accessible in global scope and my all_monsters varible will not return error.

I will try it , this means I need to make a lots of changes in my whole code

So if someone wants to answer some of the above question it would be great.

Thank you.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 8th May 2011 09:54
Quote: "So if someone wants to answer some of the above question it would be great."


1. Yes that adds Types.dba to your program so you can use whatever is in there... but looking at your attached picture you've already added them via the IDE so there's no need to use #INCLUDE.

2-5. Actually the first code snip in #2 wouldn't run properly because you put the function close to the top. If Darkbasic sees a function during normal program flow it errors out. Move the function to the bottom and put an END before it hits the function. And yes that would be the output. You don't really need to put GLOBAL before any array because every array is GLOBAL by default.

The best way to check if the array is out of bounds with multi-dimensional arrays is using IanMs version of the ARRAY COUNT() command. ARRAY COUNT() normally just shows how many elements are in an array but with multi-dimensional arrays it's a little harder to determine because the array is a lot bigger. IanMs version allows you to check each individual dimension so you can easily determine if the numbers you want to use will be within or outside the bounds of the array.

The following code snip will make your Stairs() array using 10,100 and randomly pick numbers 1 to 20 and 1 to 200 so that each dimension may or may not be within the array bounds. It runs a Test function to check if it's within the bounds using IanMs version of ARRAY COUNT() and if it's within the bounds it'll pick a random number to add to the array. If it's not within the bounds it says that it's out of bounds only. To pause the action hold down the spacebar.

For this to run properly you need to add IanMs wonderful Matrix 1 Utilities Plugin... if you don't have it you should get it because it's full of useful commands.

http://forum.thegamecreators.com/?m=forum_view&t=85209&b=18



I'm confident that once you add checks to stay within the bounds of the array you'll find out where the real problem in your program is... which is where the variables are going beyond the array bounds.

6. I don't really use fileblocks so I'm not sure about the limits but what I do know is you don't have to have separate image numbers for each wall. If image number 1 is a wall you can use that image as many times as you want to create all the walls. A lot of things in Darkbasic (really any language) can be reused. It would be silly if each individual wall had to have a different image number to work properly.

Quote: "Do not tell me to change my engine , I will not and is the only way to implement my 3D walls."


It's that kind of attitude that made you think Darkbasic Pro was somehow flawed because it was giving you out of bounds errors.

Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 8th May 2011 20:04
I would like to ask and one more question.

The order of my included files in my project have any importance?
Or are the same!

What is the difference , if my types.dba file if in the 3rd position in the project or in 10th position in the project?

And how to change the order of the files in the project , there is no button in the IDE.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 9th May 2011 09:00
It doesn't matter what order their in but if you want to change them you can open the project file (the .dbpro file) in Notepad and change the order manually.

Here's a clip from your .dbpro file (look at the includes):


People sometimes have problems with the UDTs or arrays not loading in the correct order but the quick solution is to just put them at the top of your main file.

Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 9th May 2011 15:41 Edited at: 9th May 2011 15:45
Now I am making two experiments.

First , I will replace all of my functions with Gosubs and Labels
And Second , I will try to compile my whole project in one single HUGE source code.

I see what is the difference.

In my huge single file , I put my types on very top.
Then I put all image Defines after the all types
Then I put all Variable next to the Defines.
And all initialization after that.

And after that , I will create another one Label with Goto to a Main_Gameloop.
So when the program starts at Line 1 , I will call with Goto my Game Loop and from the game loop just before the game loop I will call all my gosubs.

The example


It is small because , I am writing my whole code from the beginning , I transfer code parts from my original files to this single huge one file project.

Attachments

Login to view attachments
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 10th May 2011 23:43
I have and one more question.

What is the limit of source code lines?

I have wrote 15000 lines of code in one single file and my IDE becomes slower.

With this , when I have error , the compiler jumps to correct line , but the IDE environment becomes slow.
Quel
15
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 11th May 2011 01:22
There shouldn't be any technical limits. If there is, that's well above what DBP is capable of.

I can't say anything about the editor's speed, mine just goes totally nuts at some times, and even for a couple hundred it goes 1 fps like for a minute or two here and there...

-In.Dev.X: A unique heavy story based shoot'em ~25%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 11th May 2011 02:13
Here , it happens something like , the IDE , is trying to refresh my huge code and constantly have lag.

Is there any option which I configures the IDE and make it don't refresh the code very often?

Thank you...

The game so far goes well , I am programming my monsters AI and my Battle system.

Login to post a reply

Server time is: 2024-11-22 22:12:02
Your offset time is: 2024-11-22 22:12:02