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:
Global this_is_my_global_variable as integer
Function my_function()
local this_is_my_local_variable as integer
this_is my_local_variable=2
Endfunction
this_is_my_global_variable=1
my_function()
print this_is_my_global_variable
print this_is_my_local_variable
wait key
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:
Type My_Stairs
x as integer
y as integer
direction as integer `the direction of stairs 1=North 2=South 3=West 4=East
destination_level as integer `Which level the stair leads
destination_x as integer `The destination map position x
destination_y as integer `The destination map position y
staircase_type as integer `The type of stair case 1=UPSTAIRS 2=DOWNSTAIRS
Endtype
Global dim Stairs(10,100) as My_Stairs
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.
local dim keylocks(10,100) as My_keylocks
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
Global all_monsters as integer
Function check_all_monsters()
for all_monsters=1 to 100
blah blah code here
next
Endfunction
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.
local all_monsters as integer
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.
local dim keylocks(10,100) as My_keylocks
local dim stairs(10,100) as My_stairs
local dim doors(10,100) as My_doors
local dim alcoves(10,100) as My_alcoves
local dim blades(10,100) as My_blades
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:
local dim keylocks(10,100) as My_keylocks
local dim stairs(10,100) as My_stairs
local dim doors(10,100) as My_doors
local dim alcoves(10,100) as My_alcoves
local dim blades(10,100) as My_blades
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.
Open File Block "Interface.eob",1,""
LOAD image from block 1, "Background.bmp",Interface
LOAD image from block 1, "Gargoyle1aa.bmp",Gargoyle1a
LOAD image from block 1, "Gargoyle1bb.bmp",Gargoyle1b
LOAD image from block 1, "Hand.bmp",Hand
LOAD image from block 1, "Panel1.bmp",Panel
LOAD image from block 1, "Face01f.bmp",Face01f
LOAD image from block 1, "Face01m.bmp",Face01m
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.