Computer Science Canada manipulating the variable |
Author: | Boarder16 [ Sat Jan 03, 2004 11:44 pm ] |
Post subject: | manipulating the variable |
hey this is for my game aswell...here the questions. In one process i am giving a variable a value then right after that i call another process, now this process is listed above the first one. The second(just called) process uses teh same variable and its value for some thing.(to move the bullet shoot, but thats different)... now the variable does not have a value the computer says as might be expected becasuei have run into it before...usually i just cut and paste the moving bullet into the first process..elimianting teh second all together, but i can't this time because it is a movement process....so how can i make it so the variable has the same value just given to it in the first process, in the second... teh variabel IS declared at the top of teh whole program so it should be global...any suggestions?? |
Author: | Dan [ Sun Jan 04, 2004 12:44 am ] |
Post subject: | |
if you posted some of the code it whould be alot easer to help you with your problem. ushely if it is a goblae var it should be acsesable in all parts of the progame. you could be ruing in to porblems if you are forking somting with is reading or wiriting to a var at the same time as another part of your code alougth i think that is very unlikey. you could try making anothr var and just seting that equale to the one you are trying to acses. i whould realy need to see your code. |
Author: | Tony [ Sun Jan 04, 2004 1:09 am ] | ||
Post subject: | |||
you should just initialize a variable to have ANY value just to bypass turing's "possibiliy of fault" security ![]()
you know that you will give that variable a value before it is accessed, but compiler thinks that you might want to try to access it before, so it bitches. This way you just fill it with a garbage value that is to be replaced. |
Author: | Boarder16 [ Sun Jan 04, 2004 8:23 am ] |
Post subject: | |
no i know that part..its fine...i dunno if i explained it aswell as icoudl have...here i'll try and place some code shortly to better show u.. |
Author: | Boarder16 [ Sun Jan 04, 2004 8:33 am ] |
Post subject: | |
oh wait i figured out sumthing that might work...becasue its the bullet movin.. and they r both in processes they can't have the sam variable for the character movement and te bullet movement..cause they want to move differently...so it dosen't matter. i'll still post the final code so u can see |
Author: | Boarder16 [ Sun Jan 04, 2004 8:53 am ] | ||
Post subject: | |||
hey...now i have a different problem lol i think it has umthing to do with the variables changing in the first process..look
there are alot of pics needed obviously b4 it will run good....but if ucan see why the bullet.(drawin one of teh 1st 4 processes, goes to teh end of the screen and keeps erasing the character...NEVER Stopping and erasing teh bullet, and it never seems to exit the loop in the bullet drwing process..could it be somethings wrong in the process that callss the bullets to draw..... anyway tell me what u think...i still want to use this mode of "Transportation" to move the character ![]() |
Author: | Dan [ Sun Jan 04, 2004 8:58 pm ] |
Post subject: | |
well first of all i whould not reamend using so may forks, they are not turly need to make this progame work. you could probly do it much better if it was all in a loop and just used so many forks. it realy starts geting out of contorl when you have so many ruing at the same time. what are you starting by_loc at? b/c you have it set so it has to be escatly 362 (or 82 for othere one) to exit if you can not add 40s on to it to get to that number it will never end. also if this by_loc var is goable one proces is adding to it while the other is taking away. if they run at the same time it will never go anywhere. |
Author: | Boarder16 [ Sun Jan 04, 2004 10:13 pm ] |
Post subject: | |
the by_loc var is started at teh y_loc of the character...the process that uses teh by cannot be called or used before the character one jsut so u know...but i c what umean..if they r both running, and by_loc is dependent on what y_loc is, and y-loc is changing....is taht what u mean... when i run the program the bullet moves fine.. but goes off teh map and goes til l teh screen stops..a nd teh character keeps disappearing.. i'll try procedures instead for the bullets if taht will help... |