Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
2 registered members (3run, AndrewAMD), 623 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
problem with arrays (part 2) #345138
10/23/10 15:08
10/23/10 15:08
Joined: Oct 2010
Posts: 5
M
maddoctor Offline OP
Newbie
maddoctor  Offline OP
Newbie
M

Joined: Oct 2010
Posts: 5
And here I thought that only strings have problems when used in arrays.
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=345108&#Post345108

Now I experience problems with vectors too.
What's the difference between the following lines of code:

1: (coordinates given directly)
Code:
while(1) {   
draw_line(vector(x1,y1,0),NULL,100);
draw_line(vector(x2,y1,0),vector(0,0,255),100);
draw_line(vector(x2,y2,0),vector(0,0,255),100);	draw_line(vector(x1,y2,0),vector(0,0,255),100);	draw_line(vector(x1,y1,0),vector(0,0,255),100);
wait(1);  
 }



2: coordinates in an array (of course I initialize all array contents first: coordinates[0] = vector(x1,y1,0), coordinates[1] = vector(x2,y1,0) etc etc)
Code:
while (1){
draw_line(coordinates[0],NULL,100); 
draw_line(coordinates[1],vector(0,0,255),100);
draw_line(coordinates[2],vector(0,0,255),100);
draw_line(coordinates[3],vector(0,0,255),100);
draw_line(coordinates[4],vector(0,0,255),100);
wait(1);
}



3. 5 different variables containing the same coordinates as above
Code:
while (1){
draw_line(coordinates1,NULL,100); 
draw_line(coordinates2,vector(0,0,255),100);
draw_line(coordinates3,vector(0,0,255),100);
draw_line(coordinates4,vector(0,0,255),100);
draw_line(coordinates5,vector(0,0,255),100);
wait(1);
}



4. recreating the vectors from the above variables (in 3)
Code:
while (1){
draw_line(vector(coordinates1.x,coordinates1.y, 0),NULL,100);
draw_line(vector(coordinates2.x,coordinates2.y, 0),vector(0,0,255),100);
draw_line(vector(coordinates3.x,coordinates3.y, 0),vector(0,0,255),100);
draw_line(vector(coordinates4.x,coordinates4.y, 0),vector(0,0,255),100);
draw_line(vector(coordinates5.x,coordinates5.y, 0),vector(0,0,255),100);
wait(1);
}



All 4 of them should give the same results, correct? However the first one works properly but the others draw the line only for one frame (they appear and then disappear after a few seconds)
I want to use the array option (2) since I want to create a "drawing" application/game were the player will move a cursor to draw lines and I want the array to store the coordinates of all the different positions the player passed through.

The array is created with this command:
VECTOR* coordinates[100];
and the 5 variables:
VECTOR* coordinates1;
VECTOR* coordiantes2;
etc etc

Last edited by maddoctor; 10/23/10 15:21.
Re: problem with arrays (part 2) [Re: maddoctor] #345149
10/23/10 16:02
10/23/10 16:02
Joined: Oct 2009
Posts: 149
Germany
M
muffel Offline
Member
muffel  Offline
Member
M

Joined: Oct 2009
Posts: 149
Germany
I think filling the array is here the problem. perhaps this helps:
-Make array of normal vectors(no pointers)
-fill it with using vec_set

Reason why yours with pointers can't work. vector() creates an temporary vector after sometime its get overwritten

muffel


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1