FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Programs
(Moderators: fry, REAS)
   adding to values in an array
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: adding to values in an array  (Read 354 times)
Steve

nerdytone WWW Email
adding to values in an array
« on: Oct 29th, 2003, 12:30am »

this is a very simple thing im trying to do here. i have two arrays of 100 values each, storing an x and y value. i have a way of generating a new point for the end of the array, then i shift everthing, so it will continuously draw a line as long as i keep feeding it points. for now ive been feeding it the value points of two images(one for x and one for y). but what i want to do now is have it move in the direction of that point for a given amount of time then after that time is up it will move to a different point. i have everything set up, but when i do this:
 
lineX[counter] += (newX - lineX[counter])/20;
 
lineX[counter] just returns a constant value instead of a slowly changing one. am i doing something wrong here? it seems like this should work(for example this should be getting closer and closer to the value of newX and then when i tell it to newX becomes a different value and it should slowly go towards that). instead, it just becomes the newX value immidiately. im veeerrry confused here, any ideas?
 
thanks a bunch, steve.
 
Bijeoma

myloveiloved
Re: adding to values in an array
« Reply #1 on: Oct 29th, 2003, 2:57am »

more code would help.. tell more about newx and linex. are you incrementing counter? are newx and linex changing values. i would assume all this. but if its not working then something else must be wrong. but i cant tell from the information youve given.
 
 
bryan.
 
Steve

nerdytone WWW Email
Re: adding to values in an array
« Reply #2 on: Oct 29th, 2003, 3:46am »

sorry about that, my source code is here:
 
www.stevegh.com/blunt_2.pde
 
and youll need to replace thumb.jpg(60x50) and thumb2.jpg(100x100) to get it to work. but yea i hope you understand what im tryin to do. thanks.
 
edit: it should move more like this:
 
http://pratt.edu/~shallqui/ccdm/array_draw3.html
 
see how it moves to each location slowly, depending on how great the distance is, instead of just moving there instantly.
« Last Edit: Oct 29th, 2003, 3:57am by Steve »  
toxi

WWW
Re: adding to values in an array
« Reply #3 on: Oct 29th, 2003, 4:22pm »

from your line of code above, i guess the problem is your use of int[] arrays and the resulting rounding issues. if the difference between newX and current value is less than 20, you'll not see any value changes. you'll have to use float values for your lineX array in order to work with fractional numbers.
 
hth, toxi.
 

http://toxi.co.uk/
Steve

nerdytone WWW Email
Re: adding to values in an array
« Reply #4 on: Oct 29th, 2003, 5:10pm »

I found the problem, it was just that i didnt declare the lineX[99] = newX and lineY[99] = newY variables after counter == 99. simple error, but hey i guess we all make em. i am having a problem with alpha right now but i can live with it for now, ill talk to amit about it today in class. thanks anyways!
 
steve
 
Pages: 1 

« Previous topic | Next topic »