Computer Science Canada Crumbling Picture *optimized like I never believed possible* |
Author: | Lapsus Antepedis [ Mon May 16, 2005 11:53 am ] | ||||
Post subject: | Crumbling Picture *optimized like I never believed possible* | ||||
The code has been re optimized to the point where putting the variables in the array actually takes longer than making the stuff fall! ![]() It will work with a picture of any size, and should be compatibe with Turing for 3.1.1 for people like me who have bad install disks... Thank you Mr. Gault!
I wrote this at home one day because one of my friends made a remake of scorched earth that had falling dirt, so I waned to make something fall too. It's fully commented because I felt like it... Beware, you will need a super-ultra-mega fast computer to make more than a few columns fall at a reasonable speed, it's just too hard for a processor to do alone... (my school's brand new P4 dualies can do 25 at once... ^^; ) Anyway, enough of me, here's the code: (you also need the bitmap at the bottom so it actually does something...)
|
Author: | Delos [ Mon May 16, 2005 2:45 pm ] |
Post subject: | |
Very nicely done. A couple of suggestions: Recode without the use of processes. You'll find your programme will run faster. OOT does not handle processes too well. But if you prefer to use them, read up Tony's tutorials on Process Control in the Tutorials section. Otherwise: Begin by breaking the picture down into pixels. Each pixel will be considered a single object. These objects will have x- and y- coords, and of course a colour. Since you have the entire 'picture' stored as these particles, you can control them as you see fit. You could create a function that moves each of them down by some value in the y-direction, then update the screen to show the effects. This would translate to the same effect as what you already have. Of coures, in this method you'd be able to choose whether all of them fall at the same time, or whether they fall one column at a time. Basically, what you have here is the rough, unpolished beginnings of a particle engine. Look around Source Code (and Apps as well mayhaps) for a couple examples. Specifically zylum's and Catalyst's. Good work. + bits. |
Author: | [Gandalf] [ Mon May 16, 2005 8:11 pm ] |
Post subject: | |
Really nice effect - I might use it someday (with your permission, of course ![]() It looks really good when you have at least 20 columns going at once. Try doing all of them at once (I used 500) - cool text effect, and potentially, graphics effect. Anyway, hope too see scorched earth sometime - I really loved that game, played it for like 5 years straight, and then on and off for a while after that ![]() |
Author: | Notoroge [ Mon May 16, 2005 8:55 pm ] |
Post subject: | Re: Crumbling Picture |
Lapsus Antepedis wrote: my school's brand new P4 dualies can do 25 at once... ^^; Not trying to be rude, but it seems like we have a slight case of sloppy programming on our hands. I recall seeing some stuff by catalyst that ran on my school's ugilest computers quite nicely, and most likely had more stuff flying around the screen than that. |
Author: | Lapsus Antepedis [ Tue May 17, 2005 7:13 am ] |
Post subject: | Re: Crumbling Picture |
Notoroge wrote: Not trying to be rude, but it seems like we have a slight case of sloppy programming on our hands. I recall seeing some stuff by catalyst that ran on my school's ugilest computers quite nicely, and most likely had more stuff flying around the screen than that.
Oops... I just remembered the amount of spyware and adware on the school network... ^^; Maybe I'll attempt to run ad-aware to kill some... ![]() the older computers actually work at the same performance level most of the time. ![]() EDIT: I don't really try for fast, efficient code. I just throw these king of things together whenever the idea hits me... That program, for example came into existance a few minutes after I thought of it... I'm not really aiming for clean, fast code. (I'm not that good at it anyways ![]() |
Author: | Delos [ Tue May 17, 2005 2:14 pm ] |
Post subject: | |
Again, despite the cumbersome amounts of adware entangling your computers at school, this particular piece of code could have been done quite some more efficiently. But then, most code is not perfect on a first try. Or a twenty-third for that matter. Two words: Particle Engine. |
Author: | Notoroge [ Tue May 17, 2005 3:20 pm ] |
Post subject: | |
I concur. But yeah, first try is just showing off the idea and making it work like you want. After that you sit there and recode everything bit-by-bit, replacing everything with more efficient code. That's what I do anyways. Usually I just write completely unstructured the first time around. Everything that goes in the file is essentially as-I-go-along programming. Once it's working perfectly, I open a new window and have both sitting side-by-side. Look at every piece of code, and optimize it. Once I'm done, I do it again, then again, and again, etc. Usually, for example a class assignment, I'll go through the code about twenty times. And every time I could find something to optimize. |
Author: | Lapsus Antepedis [ Wed May 18, 2005 7:41 pm ] | ||||
Post subject: | |||||
I rewrote the whole program to use a 2D array and calculate it that way, but I have no I dea if it is faster or not... Also, no processes...
Here is my attempt to make more than one pixel move at once, but it just makes the pixels fall together into a little thing at the bottom that is one pixel tall...
does anyone have any ways to make these work? or any suggestions on something to make of it? feel free to use this code for your own use, but I would like to know what you use it for... |
Author: | Lapsus Antepedis [ Thu May 19, 2005 12:01 pm ] |
Post subject: | |
See the first post for info... |
: |