|
Author |
Topic: simple gravity sketches (Read 3587 times) |
|
arielm
|
Re: simple gravity sketches
« Reply #1 on: Dec 14th, 2003, 9:31pm » |
|
nice! concerning my oop tutorial: i didn't talk about the "constructor" concept, which can be quite useful, here's how it can be applied to your "lines_7b.pde" example: when you initialize your object-instances, it goes like: Code: for (int i = 0; i < count; i++) { myThings[i] = new Thing(); myThings[i].x = random(0, width); myThings[i].y = random(0, height); myThings[i].init_x = myThings[i].x; myThings[i].init_y = myThings[i].y; myThings[i].x2 = myThings[i].x; myThings[i].y2 = myThings[i].y; myThings[i].x3 = myThings[i].x; myThings[i].y3 = myThings[i].y; myThings[i].make_color(); myThings[i].this_thing = i; } |
| instead, you could have a "constructor", placed inside your class declaration, as follow: Code:Thing(float myX, float myY, int myI) { x = init_x = x2 = x3 = myX; y = init_y = y2 = y3 = myY; make_color(); this_thing = myI; } |
| then, in order to initialize your object instances, it would go as follow: Code:for (int i = 0; i < count; i++) { myThings[i] = new Thing(random(0, width), random(0, height), i); } |
| useful no?
|
Ariel Malka | www.chronotext.org
|
|
|
REAS
|
Re: simple gravity sketches
« Reply #2 on: Dec 16th, 2003, 7:12pm » |
|
I'm a fan of #3.
|
|
|
|
Andrew
|
Re: simple gravity sketches
« Reply #3 on: Dec 17th, 2003, 11:08am » |
|
really? I thought that was the worst one. I guess I've always preferred things that (at least try to) disguise what's actually happening and that one sort of just lets it all hang out there... some latent programming-confidence-issues maybe. hah! hey, thanks so much for your help (again) ariel. that really does clean things up, andrew
|
|
|
|
mflux
|
Re: simple gravity sketches
« Reply #4 on: Dec 19th, 2003, 3:09pm » |
|
I like 7.
|
|
|
|
Questor
|
Re: simple gravity sketches
« Reply #5 on: Dec 28th, 2003, 3:34am » |
|
I liked 3 very much as well, very modern art-esque. The dark ones are also eerily cool. Awesome!
|
|
|
|
|