Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by k_ivan. 04/25/26 19:13
ZorroGPT
by TipmyPip. 04/25/26 16:09
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
400 free seamless texture pack downl. here !
by NeoDumont. 04/08/26 19:55
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (AndrewAMD), 3,688 guests, and 20 spiders.
Key: Admin, Global Mod, Mod
Newest Members
valino, juergenwue, VladMak, Geir, ondrej
19209 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 | 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