Question about for next loops hierarchy in PlayBasic

Started by takis76, March 29, 2009, 03:02:05 PM

Previous topic - Next topic

takis76

Hi ,
I have one strange question , that I have seen in all kind of basics.

When I am using one For Next loop and I want to scan a big piece of code , things not goes well.

I use the same code in c++ and working.

I will explain what I want to do

I have one type which holds one big ammount of Doors which are in one big map.


Lets say this code is my code of my Type which holds my amount of doors



Type My_Activated_Doors
Door_x as integer //The position of activated door to be opened
Door_y as integer
State as integer //1 Opening 2 closing 0 closed
Delay as integer //How long each Frame is open
Frame as integer //current Frame of the door

EndType

//             Level,Number of doors
Dim Activated_Doors(20,200) as My_Activated_Doors


The array Activated_Doors is a 2 dimentional data Type array which hold all doors in my all levels
The prototype of the Activated_Doors Variable (20,200) means 20 levels and 200 doors for each level in the big map.


The idea is , your are in the labyrinth and you arrived in a corridoor with 3 doors. These 3 doors operates by one button in front of
the door.

I press one of these 3 buttons and I open one door. One door is open. I will explain all mechanism and what I try to explain and
I will try to explain my problem.

I have predefined the position of these 3 doors in the map with the next code.


Activated_Doors(1,1).Door_x=6
Activated_Doors(1,1).Door_y=5

Activated_Doors(1,2).Door_x=8
Activated_Doors(1,2).Door_y=5

Activated_Doors(1,3).Door_x=11
Activated_Doors(1,3).Door_y=5



As we know we are in a corridor the doors are near each other.

The Activated_Doors array which is a data Type tell us
We are at level 1 the first argument of parenthesis and the second argument tell us the number of each door.
So the previous code tells to us , on the level 1 the door number 1 is at the position 6 horizontal and 5 vertical.

Our map is a big square map like a chess and each dimention have 24 squares horizontal and 24 squares vertical.

So the previous code tells to us the position of these 3 doors.

The player , in fact the party of players is another data Type variable.
The code below discribes the code which initializes my party as a Data Type.




Type MyParty
Direction as integer
Level as integer
x as integer
y as integer
EndType

Dim Party as MyParty




As you see the Direction member of the type means where my party is facing North - South - East - West
The level member of the type means , in which level is the party on , in my example I am on level 1 (Level 1 map)
The x and y variables are the position of my party as a data type on the map.


If my party is facing to the North the Direction member variable takes the value of 1
If my party is facing to the south the Direction member variable takes the value of 2
If my party is facing to the East the Direction member variable takes the value of 3
If my party is facing to the West the Direction member variable takes the value of 4

Previously I said , I have my doors on the map in specific positions.


Activated_Doors(1,1).Door_x=6
Activated_Doors(1,1).Door_y=5

Activated_Doors(1,2).Door_x=8
Activated_Doors(1,2).Door_y=5

Activated_Doors(1,3).Door_x=11
Activated_Doors(1,3).Door_y=5



If I assume I am in front of the first door and I am facing to the North , the door faces against me to the South.
If I am in front of the first door , my party position according to info you have so far must be



Party.x=6
Party.y=6




and the position of the door number 1 on the level 1 is


Activated_Doors(1,1).Door_x=6
Activated_Doors(1,1).Door_y=5


So the party is at the 6,6 square and the door is at the 6,5 the second dimension is the vertical axis
And If my party if walking in front and facing to the north the party will advance at the same square of the door
at the posision 6,5 , in fact the vertical variable of the vertical axis of the party decreasing if you are walking to the north
the party will reach the north side of the map at posision 6,1.

But the door in front of me is closed and does not allow me to pass through , I need to open it first before the player reach the same
square with the door and pass through and advance to the north until reach the north side of the map the possition 6,1 of the map and

continue the trip in the labyrinth.

The door is in front and the button is on the right side of the casing of the door and waits the player to push.

The code below tell to us



  if (Party.Direction=1) //If Party facing NORTH
    if (mousex()>=267 and mousex()<=278 and mousey()=>106 and mousey()<=117) //Select the button



The party is facing to the north because the Direction member variable of the data type Party is 1
And then check my mouse posision on the screen , this is the posision of the button a small square button at the right side of the

door case.

Before all of this I check if my mouse button is pressed with this code.


  if (mouse_pressed=1) //If mouse pressed


The varibale mouse_pressed take the value from the Function MouseButton() from Playbasic.

When I am pressing the mouse button in the area 267,278-106,117 then the button is pressed and I need to open the specific door in
front of the player no other door.

So there is a big mechanism of source code which , scans all doors in my level in all levels with 2 for next loops.

Before I post all the code I will discribe all mechanism and I will tell all Idea how my doors are working.

======The main Idea how my doors are working.=========

Each door closed or opened , have an animation sequence , each door is like a slide door like an elevetor door or double door.
Each part of door , opens seperately the left part of the door move to the left and the right part of the door moves to the right.
Until all the door will wide open needs four steps of animation until all door is widely opened.

The animation of the door in the data Type is as frame. The member variable frame stores the value of the animation of the door.


Activated_Doors(All_Levels,All_Doors).Frame=0 //Animation 1 totaly closed
Activated_Doors(All_Levels,All_Doors).Frame=1 //Animation 2 semi open
Activated_Doors(All_Levels,All_Doors).Frame=2 //Animation 3 semi open
Activated_Doors(All_Levels,All_Doors).Frame=3 //Animation 4 semi open
Activated_Doors(All_Levels,All_Doors).Frame=4 //Animation 5 widely opened


So , I am scanning my doors with 2 for next loops.



  for All_Levels=1 to 200 //check all world 20 levels 200 doors per level
   for All_Doors=1 to 200


   next All_Doors
  next All_Levels


In this code there will be all mechanism how my doors are working , opening and closing.

Each door have one member variable as state.
The state member variable stores the state of the door. when the player push the button the variable takes the variable 1
that means , you have push the button and the door take the state 1 which means , the door now is opening and the opening sequence
now is running and you are see the slide door opening.
There is a timer in my code which delays some milisecond each animation to see the door open sequentially.
When the state variable take the value of one , another member variable of the data type with name frame increases until the door
opens widely and the frame take the value of 4.


Activated_Doors(All_Levels,All_Doors).State=1 //my door take the state 1 ready to open



Activated_Doors(All_Levels,All_Doors).Frame=3 //my door is the frame 3 of animation


So far so good the door reach the frame 4 and now is at the state 2 , that means , the door is now widely opened and if the button
will pressed again , the closing sequence will begins and decrease the value of frames and the door now is closing until to reach the
value of frame 0 , that means the door is totaly closed.

Each door opens slowlly , not very slow but opens not very fast so you have the time to open and other 2 door that are near in the
corridor as I have said at the beginning.

Now this is my problem.

If I open one of these 3 doors , the door will start to open slowly and I will open another one , and another one.
So I have now all doors in the state 1 and all doors now must is opening.

All af my code is bellow.



Activated_Doors(1,1).Door_x=6
Activated_Doors(1,1).Door_y=5

Activated_Doors(1,2).Door_x=8
Activated_Doors(1,2).Door_y=5

Activated_Doors(1,3).Door_x=11
Activated_Doors(1,3).Door_y=5

//Mouse Function for Pressing Door01 Button to open Door01



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/////
if (mouse_pressed=1) //If mouse pressed

for All_Levels=0 to 20 //check all world 20 levels 100 doors per level
for All_Doors=0 to 20

//Activated_Doors(All_Levels,All_Doors).Delay=(Timer()-T8)/100
//if (Activated_Doors(All_Levels,All_Doors).Delay>3) then

Activated_Doors(All_Levels,All_Doors).Delay=0:T8=Timer()

if (Party.Direction=1) //If Party facing NORTH
if (mousex()>=267 and mousex()<=278 and mousey()=>106 and mousey()<=117) //Select the

button

if Party.x=Activated_Doors(All_Levels,All_Doors).Door_x and

Party.y-1=Activated_Doors(All_Levels,All_Doors).Door_y //if you are in front of the door
//playsound Button01

if Activated_Doors(All_Levels,All_Doors).State=0 //if Closed
Activated_Doors(All_Levels,All_Doors).State=1 //open
////////playsound Button01
//exit
//goto AFTER_MOUSE_FUNCTIONS:
continue
endif
if Activated_Doors(All_Levels,All_Doors).State=1 //if opened
Activated_Doors(All_Levels,All_Doors).State=2 //close
//////playsound Button01
//exit
//goto AFTER_MOUSE_FUNCTIONS:
continue
endif
if Activated_Doors(All_Levels,All_Doors).State=2 //if opened
Activated_Doors(All_Levels,All_Doors).State=1 //close
////////playsound Button01
//exit
//goto AFTER_MOUSE_FUNCTIONS:
continue
endif

endif

endif

endif
endif


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/////

next All_Doors
next All_Levels

AFTER_MOUSE_FUNCTIONS:

for All_Levels=0 to 20 //check all world 20 levels 100 doors per level
for All_Doors=0 to 20

Activated_Doors(All_Levels,All_Doors).Delay=(Timer()-T8)/100

if Activated_Doors(All_Levels,All_Doors).State=1
if (Activated_Doors(All_Levels,All_Doors).Delay>3) then

Activated_Doors(All_Levels,All_Doors).Delay=0:T8=Timer():Activated_Doors(All_Levels,All_Doors).Frame=Activated_Doors(All_Levels,All_Do

ors).Frame+1
if Activated_Doors(All_Levels,All_Doors).Frame>4
Activated_Doors(All_Levels,All_Doors).Frame=4
//continue
endif
endif
if Activated_Doors(All_Levels,All_Doors).State=2
if (Activated_Doors(All_Levels,All_Doors).Delay>3) then

Activated_Doors(All_Levels,All_Doors).Delay=0:T8=Timer():Activated_Doors(All_Levels,All_Doors).Frame=Activated_Doors(All_Levels,All_Do

ors).Frame-1
if Activated_Doors(All_Levels,All_Doors).Frame<0
Activated_Doors(All_Levels,All_Doors).Frame=0
Activated_Doors(All_Levels,All_Doors).State=0
//continue
endif
endif


next All_Doors
next All_Levels





text 20,230,""+digits$(mousex(),3)+" "+digits$(mousey(),3)+" "+str$(mousebutton())+str$(mouse_pressed)


//for All_Doors=1 to 2
Text 0,150,"Door1 X:"+str$(Activated_Doors(1,1).Door_x)+" Door1 Y:"+str$(Activated_Doors(1,1).Door_y)+"

State:"+str$(Activated_Doors(1,1).State)+" Delay:"+str$(Activated_Doors(1,1).Delay)+" Frame:"+str$(Activated_Doors(1,1).Frame)
Text 0,160,"Door2 X:"+str$(Activated_Doors(1,2).Door_x)+" Door2 Y:"+str$(Activated_Doors(1,2).Door_y)+"

State:"+str$(Activated_Doors(1,2).State)+" Delay:"+str$(Activated_Doors(1,2).Delay)+" Frame:"+str$(Activated_Doors(1,2).Frame)
Text 0,170,"Door3 X:"+str$(Activated_Doors(1,3).Door_x)+" Door3 Y:"+str$(Activated_Doors(1,3).Door_y)+"

State:"+str$(Activated_Doors(1,3).State)+" Delay:"+str$(Activated_Doors(1,3).Delay)+" Frame:"+str$(Activated_Doors(1,3).Frame)





At the end of the code , I put a text which shows each of these 3 doors in each frame.



Global Variables


Global All_Levels,All_Doors
Global T8
global mouse_pressed



The data type of the party


Type MyParty
Direction as integer
Level as integer
x as integer
y as integer
EndType

Dim Party as MyParty




The data type of the doors


Type My_Activated_Doors
Door_x as integer //The position of activated door to be opened
Door_y as integer
State as integer //1 Opening 2 closing 0 closed
Delay as integer //How long each Frame is open
Frame as integer //current Frame of the door

EndType

Dim Activated_Doors(20,200) as My_Activated_Doors


Also there are some sound effects which I have rem them because in another part of a code which loads the sound effect I have not

posted.


My problem is when I am opening one door and the I open another one , the previous door is stop opening
And if the first door is opens and I will try to open another door , the other door is not open.
If I close the first of the 3 doors and I have previously open some other door , when the first door is opening the other door stops
open or pauses.
If I close the first door the other paused door continues to open and with little words I cant open all door at the same time of
if some of the 3 doors is still opening and is the opening or closing sequence and you try to open onother door , the sequence is
stops and start the new door opening and if you try to close the previous door , the door is not working.
You need to close the first door , and when the first door is closed , then the sequence of the other door continues.

Is like you are not able to run 3 variables at once , of the language have some hierarchy of the jobs.

I thing if all is in the for next loop , means everything in this loop will executed together.

I have create this code in "c" and working. I thing I explained well what I mean.

If this will not help , I will post all the game to see what I try to make.


takis76

I upload the game here to see the problem.

http://eob4.fileave.com/eob4.zip

kevin

#2
 FOR/NEXT loop structures BASIC you don't have mutpile conditions or iterators.    This doesn't mean you can't, you either have exit conditions with extra counters, or use a Repeat,UNtil  or While/EndWhile structures.

Only picked through the code and there's room for improvement

* ImageQuantity 2000000..   Why on earth expand the image tables to  2 million slots, if it only uses a few hundred.   While i don't recall the size of the image structure off hand,  but this will cost a fortune in terms memory.  

 * Way too many globals..

PlayBASIC Code: [Select]
Global W0001_01,W0001_02,W0001_03,W0001_04,W0001_05,W0001_06,W0001_07,W0001_08,W0001_09,W0001_10,W0001_11,W0001_12,W0001_13,W0001_14,W0001_15,W0001_16,W0001_17,W0001_18,W0001_19,W0001_20,W0001_21,W0001_22,W0001_23
Global W0002_01,W0002_02,W0002_03,W0002_04,W0002_05,W0002_06,W0002_07,W0002_08,W0002_09,W0002_10,W0002_11,W0002_12,W0002_13,W0002_14,W0002_15,W0002_16,W0002_17,W0002_18,W0002_19,W0002_20,W0002_21,W0002_22,W0002_23
Global W0003_01,W0003_02,W0003_03,W0003_04,W0003_05,W0003_06,W0003_07,W0003_08,W0003_09,W0003_10,W0003_11,W0003_12,W0003_13,W0003_14,W0003_15,W0003_16,W0003_17,W0003_18,W0003_19,W0003_20,W0003_21,W0003_22,W0003_23
Global W0004_01,W0004_02,W0004_03,W0004_04,W0004_05,W0004_06,W0004_07,W0004_08,W0004_09,W0004_10,W0004_11,W0004_12,W0004_13,W0004_14,W0004_15,W0004_16,W0004_17,W0004_18,W0004_19,W0004_20,W0004_21,W0004_22,W0004_23
Global W0005_01,W0005_02,W0005_03,W0005_04,W0005_05,W0005_06,W0005_07,W0005_08,W0005_09,W0005_10,W0005_11,W0005_12,W0005_13,W0005_14,W0005_15,W0005_16,W0005_17,W0005_18,W0005_19,W0005_20,W0005_21,W0005_22,W0005_23
Global W0006_01,W0006_02,W0006_03,W0006_04,W0006_05,W0006_06,W0006_07,W0006_08,W0006_09,W0006_10,W0006_11,W0006_12,W0006_13,W0006_14,W0006_15,W0006_16,W0006_17,W0006_18,W0006_19,W0006_20,W0006_21,W0006_22,W0006_23
Global W0007_01,W0007_02,W0007_03,W0007_04,W0007_05,W0007_06,W0007_07,W0007_08,W0007_09,W0007_10,W0007_11,W0007_12,W0007_13,W0007_14,W0007_15,W0007_16,W0007_17,W0007_18,W0007_19,W0007_20,W0007_21,W0007_22,W0007_23
Global W0008_01,W0008_02,W0008_03,W0008_04,W0008_05,W0008_06,W0008_07,W0008_08,W0008_09,W0008_10,W0008_11,W0008_12,W0008_13,W0008_14,W0008_15,W0008_16,W0008_17,W0008_18,W0008_19,W0008_20,W0008_21,W0008_22,W0008_23
Global W0009_01,W0009_02,W0009_03,W0009_04,W0009_05,W0009_06,W0009_07,W0009_08,W0009_09,W0009_10,W0009_11,W0009_12,W0009_13,W0009_14,W0009_15,W0009_16,W0009_17,W0009_18,W0009_19,W0009_20,W0009_21,W0009_22,W0009_23
Global W0010_01,W0010_02,W0010_03,W0010_04,W0010_05,W0010_06,W0010_07,W0010_08,W0010_09,W0010_10,W0010_11,W0010_12,W0010_13,W0010_14,W0010_15,W0010_16,W0010_17,W0010_18,W0010_19,W0010_20,W0010_21,W0010_22,W0010_23


Global W0011_01,W0011_02,W0011_03,W0011_04,W0011_05,W0011_06,W0011_07,W0011_08,W0011_09,W0011_10,W0011_11,W0011_12,W0011_13,W0011_14,W0011_15,W0011_16,W0011_17,W0011_18,W0011_19,W0011_20,W0011_21,W0011_22,W0011_23
Global W0012_01,W0012_02,W0012_03,W0012_04,W0012_05,W0012_06,W0012_07,W0012_08,W0012_09,W0012_10,W0012_11,W0012_12,W0012_13,W0012_14,W0012_15,W0012_16,W0012_17,W0012_18,W0012_19,W0012_20,W0012_21,W0012_22,W0012_23
Global W0013_01,W0013_02,W0013_03,W0013_04,W0013_05,W0013_06,W0013_07,W0013_08,W0013_09,W0013_10,W0013_11,W0013_12,W0013_13,W0013_14,W0013_15,W0013_16,W0013_17,W0013_18,W0013_19,W0013_20,W0013_21,W0013_22,W0013_23
Global W0014_01,W0014_02,W0014_03,W0014_04,W0014_05,W0014_06,W0014_07,W0014_08,W0014_09,W0014_10,W0014_11,W0014_12,W0014_13,W0014_14,W0014_15,W0014_16,W0014_17,W0014_18,W0014_19,W0014_20,W0014_21,W0014_22,W0014_23




  This would be just as easily represented by a single 2D array and for/next to init it.

PlayBASIC Code: [Select]
  Dim Walls(14,23)

Then a for/next to initial them

Currentmage=1000100
For Wall=1 to 14
For lp=1 to 23
Walls(Thiswall,lp)=CurrentImage+lp
next
CurrentImage=CurrentImage+100
next



etc

takis76

Quote
ImageQuantity 2000000..   Why on earth expand the image tables to  2 million slots, if it only uses a few hundred.   While i don't recall the size of the image structure off hand,  but this will cost a fortune in terms memory.

I increase the image table to 2000000 because , the format of my walls is like this

if put number 1 because in I didn't put the number is it not possible to have this format of number 000107

The format number of my walls is like this:

the first ace is lefted alone the second 4 figure number from 0001 to 9999 are all the walls I use in the game this is the number in quotes.

1-"0001"-01

This number "0001" to "9999" are different kind of walls , from 0001 - 0100 are the castle wall graphics
from 0101 - 0200 are the dungeon wall graphics , from 0201 - 0301 are the mines wall graphics etc..

so I need numbers like 1002201

1-001-"01" the 2 figure number in the quotes mean I have from 01 - to 23 numbers this means , all possitions off walls that presents on the screen are 23. For example,

If we assume you are in one square and arround you there are walls. Each wall possition have a number.

The front wall is the number 4 one square in front of you
The left wall at the left most square of the player possition is the number 01 and the right wall at the most right square of the player possition is the number 02 ect...

So the number format as an image format that I need to load all of these images in memory is like these.


1-"Wall kind"-"Wall possition"

1000101 the left wall position 01 , castle graphics
1000102 the right wall position 02 , castle graphics
1000103 the front upper left position 03 , castle graphics
.
.
.
1000123 the last far away position of wall 23 , castle graphics

Then the number increases by one the new number is
1000201 this means this is the second kind of wall ta the possition 01
1000202 until 23
.
.
.
1000223 the middle number with 4 figure digits are all possible walls in the game

1"0002"23 this means

1"0002"23 is the last possition of castle wall flipped
1"0003"23 is the last possition of castle wall with a window
1"0004"23 is the last possition of castle wall with Stairs UP
1"0005"23 is the last possition of castle wall with Stairs DOWN
1"0006"23 is the last possition of castle wall with a lever switch down
1"0007"23 is the last possition of castle wall with a lever switch up

All graphics , like , buttons , levers , furnitures , windows , lamps , textures , dungeons and everything
are in these 4 figure numbers and the possition all each of all these graphics are in the 2 figure numbers from 01 to 23.

10007"23" I don't know , but with this the way how my engine is working.

Also I have a lots of globals , each graphic loads in one image index and each image loads with LoadImage "W001-04.bmp",W0001_04 function.

How do I use the repeat and until loops , I tried and my programm stucks in the loop.


the doors code:


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (mouse_pressed=1) //If mouse pressed

Repeat
Repeat
//While All_Levels<20 //check all world 20 levels 100 doors per level
//While All_Doors<20


//Activated_Doors(All_Levels,All_Doors).Delay=(Timer()-T8)/100
//if (Activated_Doors(All_Levels,All_Doors).Delay>3) then Activated_Doors(All_Levels,All_Doors).Delay=0:T8=Timer()

if (Party.Direction=1) //If Party facing NORTH
if (mousex()>=267 and mousex()<=278 and mousey()=>106 and mousey()<=117) //Select the button

if Party.x=Activated_Doors(All_Levels,All_Doors).Door_x and Party.y-1=Activated_Doors(All_Levels,All_Doors).Door_y //if you are in front of the door
//playsound Button01

if Activated_Doors(All_Levels,All_Doors).State=0 //if Closed
Activated_Doors(All_Levels,All_Doors).State=1 //open
playsound Button01
//exit
//goto AFTER_MOUSE_FUNCTIONS:
continue
endif
if Activated_Doors(All_Levels,All_Doors).State=1 //if opened
Activated_Doors(All_Levels,All_Doors).State=2 //close
playsound Button01
//exit
//goto AFTER_MOUSE_FUNCTIONS:
continue
endif
if Activated_Doors(All_Levels,All_Doors).State=2 //if opened
Activated_Doors(All_Levels,All_Doors).State=1 //close
playsound Button01
//exit
//goto AFTER_MOUSE_FUNCTIONS:
continue
endif

endif

endif

endif
endif
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Activated_Doors(All_Levels,All_Doors).Delay=(Timer()-T8)/100

if Activated_Doors(All_Levels,All_Doors).State=1
if (Activated_Doors(All_Levels,All_Doors).Delay>3) then Activated_Doors(All_Levels,All_Doors).Delay=0:T8=Timer():Activated_Doors(All_Levels,All_Doors).Frame=Activated_Doors(All_Levels,All_Doors).Frame+1
if Activated_Doors(All_Levels,All_Doors).Frame>4
Activated_Doors(All_Levels,All_Doors).Frame=4
//continue
endif
endif
if Activated_Doors(All_Levels,All_Doors).State=2
if (Activated_Doors(All_Levels,All_Doors).Delay>3) then Activated_Doors(All_Levels,All_Doors).Delay=0:T8=Timer():Activated_Doors(All_Levels,All_Doors).Frame=Activated_Doors(All_Levels,All_Doors).Frame-1
if Activated_Doors(All_Levels,All_Doors).Frame<0
Activated_Doors(All_Levels,All_Doors).Frame=0
Activated_Doors(All_Levels,All_Doors).State=0
//continue
endif
endif

AFTER_MOUSE_FUNCTIONS:

///showind Frames//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if Activated_Doors(All_Levels,All_Doors).Frame=0
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,1)=10
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,2)=10
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,3)=10
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,4)=10
endif
if Activated_Doors(All_Levels,All_Doors).Frame=1
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,1)=11
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,2)=11
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,3)=11
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,4)=11
endif
if Activated_Doors(All_Levels,All_Doors).Frame=2
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,1)=12
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,2)=12
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,3)=12
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,4)=12
endif
if Activated_Doors(All_Levels,All_Doors).Frame=3
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,1)=13
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,2)=13
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,3)=13
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,4)=13
endif
if Activated_Doors(All_Levels,All_Doors).Frame=4
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,1)=14
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,2)=14
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,3)=14
Levels(Party.level,Activated_Doors(All_Levels,All_Doors).Door_x,Activated_Doors(All_Levels,All_Doors).Door_y,4)=14
endif

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Until All_Doors<20
Until All_Levels<20



I replace the for next with Repeat Until and the programm hungs.

Could you know what do I do?







If I want to load each image in specific image slot , I need to load in specific number format to know what Image I use each time.

I will try your code , is shorter than the all of thes Globals.
Thank you very much for these information.







kevin

#4
QuoteI increase the image table to 2000000 because , the format of my walls is like this

 This costs you  130 meg (2,000,000 * 68bytes) at least of memory for the image structure alone, without even loading the graphics.  

 Your images only use a range of a few thousand,  so you could still use the same approach, except prior to rendering subtract the 1,000,000 from them to bring them into a more reasonable range, or use it as an array index.


 Ie.

  Id= 1000101

  ImageINdex=(ID-1000000)+1000

 Which would let them be stored from base index of 1000 onwards.


 Looking at the code snippet, where do you assign "All_Doors, All_Level " and more importantly, where to you increase them in order to iterate the loops  ?  They seem to be infinite.

PlayBASIC Code: [Select]
   Counter=1
Repeat
print Counter
Counter=Counter+1
UNtil Counter>10



 I think what you really want is two nested FOR/NEXT loops


PlayBASIC Code: [Select]
   For Level=0 to NumberOfLevels
For Room=0 to NumberOfRooms
do stuff to room

next Room
Next Level





takis76

Quote
I think what you really want is two nested FOR/NEXT loops

I had already have tow nested for next loops , but when I opened and closed my doors and when I tried to
open more than one door together the doors does not open or when I open the first door and the second door is not finished its animation the first door stop open , or you must close the first door and then the second door is opened.

In few words , is like the for next loop is not able to make multiple jobs at the same time.
If I want to open and close 20 different doors an the same time , the language does not manipulate all jobs as multitasking.


I have upload the game , download it from this link to see what is happened if you want. :)

http://eob4.fileave.com/eob4.zip




kevin



QuoteIn few words , is like the for next loop is not able to make multiple jobs at the same time.
If I want to open and close 20 different doors an the same time , the language does not manipulate all jobs as multitasking.

   Nothing about this statement is accurate. 


takis76

So I am not able to create my game with this language at all. :(

kevin


  Of course you can,  The problem is not the language it's your understanding and implementation within the language. 

  See -> Handling Multiple Animations using Timer()



takis76

according to my code , how to scan all my doors and levels with the timer and make them open and close.
I saw your code , but I didn't understand it.
?