Animated textures

About advanced scenes, and the Thyme scripting language used in Algodoo.

Animated textures

Postby Kilinich » Sat Jan 09, 2010 10:29 pm

Here you are. Function for make animated texture.

Code: Select all
Scene.my.ATx := (tx, cols, rows, fps)=>{[tx(0)/cols, tx(1), (.5+math.toInt(sim.time*fps))/cols, tx(3), tx(4)/rows, (-.5-math.toInt(sim.time*fps)/cols)/rows, tx(6), tx(7), tx(8)]}


Rating: rated 8.4
Filesize: 0.7 MB
Comments: 15
Ratings: 16
download


And here it is advanced version - play animated texture once after "start" time and stop on last frame (for example in can be used on spawned geometry):

Code: Select all
Scene.my.ATx1 := (tx, cols, rows, fps, start)=>{(sim.time-start) < (1.0*cols*rows/fps) ? [tx(0)/cols, tx(1), (.5+math.toInt((sim.time-start)*fps))/cols, tx(3), tx(4)/rows, (-.5-math.toInt((sim.time-start)*fps)/cols)/rows, tx(6), tx(7), tx(8)] : [tx(0)/cols, tx(1), -.5/cols, tx(3), tx(4)/rows, .5/rows, tx(6), tx(7), tx(8)]}
Last edited by Kilinich on Mon Jul 05, 2010 6:56 pm, edited 3 times in total.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Animated textures

Postby RicH » Sun Jan 10, 2010 6:43 am

Wow. :clap:
Millions of voices suddenly cried out in terror, and were suddenly silenced. Something terrible has happened.
User avatar
RicH
[Funniest Person 2010]
 
Posts: 2043
Joined: Tue Sep 01, 2009 9:01 am

Re: Animated textures

Postby niffirg1 » Mon Jan 11, 2010 11:58 pm

Dang that is cool
User avatar
niffirg1
 
Posts: 376
Joined: Mon Aug 31, 2009 10:31 pm
Location: The Great American South!

Re: Animated textures

Postby Rideg » Tue Jan 12, 2010 8:23 am

Woow :o .That was just plain awesomness! can't understand it though.. :clap:
Image
make sure to check out my work.
User avatar
Rideg
 
Posts: 948
Joined: Tue Dec 15, 2009 5:17 pm
Location: Östersund, Sweden

Re: Animated textures

Postby KarateBrot » Tue Jan 12, 2010 12:35 pm

Rideg wrote:Woow :o .That was just plain awesomness! can't understand it though.. :clap:


the function is repositioning an image that includes all animation frames. you can see the image on the left side of the animation
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: Animated textures

Postby link0007 » Tue Jan 12, 2010 2:52 pm

I don't know much about dedicated animation programs, but you could output these kinds of images by using GameMaker's built-in sprite editor. You can load animated gifs, and save them as a strip (in bmp format).
Link: "Surely somebody hates Walter Cronkite.."
Sonic: "Probably.. But somebody hates everyone."
:D
User avatar
link0007
 
Posts: 408
Joined: Thu Jun 11, 2009 2:45 pm

Re: Animated textures

Postby Kilinich » Tue Jan 12, 2010 3:33 pm

Kilinich wrote:Now make image with frames (any size any col/row), apply it on geometry and set textureMatrix property to:
{scene.my.atx(default_textureMatrix, cols, rows, fps)}


Important: Always use float values in default texturematrix (0.0 not 0, 1.0 not 1)!
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Animated textures

Postby fox11trot » Wed Jan 13, 2010 8:28 am

Ah i see what u mean i like ur script
fox11trot
 
Posts: 62
Joined: Tue Sep 01, 2009 7:25 am


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 2 guests

cron