Jump to content


Photo
- - - - -

Thesnidr's Grid Distortion


  • Please log in to reply
36 replies to this topic

#1 TheSnidr

TheSnidr

    That guy

  • Global Moderators
  • 2939 posts
  • Version:GM:Studio

Posted 24 August 2009 - 02:29 PM

  • Title: TheSnidr's Grid Distortion Effect
  • Description: Creates a grid and lets you distort it. Can also be textured.
  • GM Version: GM 7
  • Registered: yes
  • File Type: gmk
  • File Size: 68kb
  • File Link: Host-a | YoYo
Additional Info
This is a dynamic grid engine very similar to geometry wars!
It was updated to version 2 21/9/10, download old version here:
Host-a

Version 2 has been almost completely rewritten, and with Sapidus3's tips, it's a lot faster. Geometry is now stable, as opposed to before ^^
I've removed the implode script, as it now is the same as an explosion with negative force

Posted Image
Old picture: http://i26.tinypic.com/mjq0zl.jpg

Use arrowkeys to change room.

The grid can be any size, but too many cells might slow your game down.

Edited by TheSnidr, 13 July 2011 - 04:59 PM.

  • 4

#2 dadio

dadio

    I miss my cupcake

  • YoYo Games Staff
  • 1975 posts
  • Version:GM:Studio

Posted 25 August 2009 - 02:19 PM

Ooh! Nice little example there!
Yeah, could be cool for texturing with a face & "distorting" (like a 2D version of Mario's head in Mario64).

Pretty much all your examples are really groovy tbh!
Keep 'em coming :whistle:
  • 0

#3 TheSnidr

TheSnidr

    That guy

  • Global Moderators
  • 2939 posts
  • Version:GM:Studio

Posted 26 August 2009 - 12:39 PM

Thank you!

The engine is highly customizable. In the _update script, the second argument decides how fast the points in the grid should move back to their starting point (if they have been moved). Make it a low number to make it look like syrup.
You can decide yourself how many cells the grid contains, how big it is, and the radius and strength of the "_explode" and "_implode" scripts.

It seems it is similar here to how it is in the WIP section, people won't download without a picture, so I added one to the first post.
  • 0

#4 Newly Discovered

Newly Discovered

    Harmonious Genius

  • GMC Member
  • 2475 posts
  • Version:GM8

Posted 28 August 2009 - 02:27 AM

wow that is really cool!
this would make an insanely awesome topdown water effect, you should give it a shot!
you could probably be able to create some sweet water ripples as well.

good luck if you try! I know I wont.
  • 0

#5 pubby8

pubby8

    GMC Member

  • New Member
  • 577 posts

Posted 29 August 2009 - 03:34 AM

I wrote an engine for something similar to this last year. xD I'm actually writing a game on it right now :whistle:
distort image


Nice effect.
  • 0

#6 commander of games

commander of games

    Kaos Kreator

  • GMC Member
  • 2883 posts
  • Version:GM:Studio

Posted 31 August 2009 - 12:46 AM

This is fun XD! I went online and got some face images of people(Bill Gates and stuff) and distorted them! This could make an intresting little game thing.
  • 0

#7 RamboFox

RamboFox

    Tainted Fortune

  • New Member
  • 992 posts

Posted 01 September 2009 - 01:29 AM

"Almost like in Geometry Wars"
How about EXACTLY like geometry wars - I think they used a combination of textures and warped 3d models to render a quick, and efficient grid distortion effect.
Looks like you replicated their' method in GM :)

Nicely done *thumbsup*
  • 0

#8 Newly Discovered

Newly Discovered

    Harmonious Genius

  • GMC Member
  • 2475 posts
  • Version:GM8

Posted 14 October 2009 - 07:40 PM

I had an idea on another way you could use this, but I'm not entirely sure how to go about it.
if you like the idea, maybe you could give it a try.

you'd select an area and create the grid. you'd texture the grid with a surface of that area. then distort it!
I was thinking you could easily create refractions, like heat from a flame or maybe water.

think it could work?
  • 0

#9 TheSnidr

TheSnidr

    That guy

  • Global Moderators
  • 2939 posts
  • Version:GM:Studio

Posted 15 October 2009 - 02:47 PM

Yeah, maybe! Good idea.
I'll look into it when I get the time, but I believe it should be possible.

Edited by TheSnidr, 20 October 2009 - 06:36 PM.

  • 0

#10 TheSnidr

TheSnidr

    That guy

  • Global Moderators
  • 2939 posts
  • Version:GM:Studio

Posted 20 October 2009 - 06:57 PM

Yeah, maybe! Good idea.
I'll look into it when I get the time, but I believe it should be possible.

I just uploaded a new version!
I've made an example of how to use the engine for, for example, heatwaves (thanks to Newly Discovered for the idea!)
I added a script that lets you create a texture index of a specified area on the screen. You can then use the texture in the draw_grid scripts.
Posted Image
As always, use the arrow keys to move between the rooms. The first room has no controls, use the mouse in the two other rooms.
  • 0

#11 Newly Discovered

Newly Discovered

    Harmonious Genius

  • GMC Member
  • 2475 posts
  • Version:GM8

Posted 20 October 2009 - 09:22 PM

very cool! not exactly what I was looking for, but it's still awesome looking. nice job!
this is actually a very powerful effect.

aw I see...it only captures the screen once. too bad it leaks!

Edited by Newly Discovered, 20 October 2009 - 09:38 PM.

  • 0

#12 LoopStan

LoopStan

    North-See Developer

  • GMC Member
  • 1398 posts

Posted 31 October 2009 - 07:33 PM

This is really cool! Good job, I needed a script and such just like this.
  • 0

#13 Shadowrend

Shadowrend

    Master of Shadows

  • GMC Member
  • 2902 posts
  • Version:GM8

Posted 12 March 2010 - 10:58 PM

Pretty cool.Posted Image
  • 0

#14 TheSnidr

TheSnidr

    That guy

  • Global Moderators
  • 2939 posts
  • Version:GM:Studio

Posted 21 September 2010 - 05:05 PM

The engine has been almost completely rewritten!
It's much faster, and the geometry is stable now, as opposed to before!
Instead of just moving back to their initial positions, the vertexes now bounce instead, giving it a much more dynamic feel

Thanks to Sapidus3 for tips on how to improve speed
  • 0

#15 CaptainLepidus

CaptainLepidus

    GMC Member

  • GMC Member
  • 850 posts
  • Version:GM:HTML5

Posted 22 September 2010 - 12:25 AM

Try putting this picture into it:http://www.swisseduc...bble-mf9330.jpg

It creates quite a cool effect.
  • 0

#16 saim

saim

    GMC Member

  • GMC Member
  • 1087 posts

Posted 10 February 2011 - 02:04 AM

Am I too late to comment? It is awesome! Really really cool!
But I lack understanding. Can you comment things step-by-step? I got lost on the creation of the grid! (the for loop, to be more precise)
Or can I ask for info by private messages? I'm really interested in this effect, and it seems that it would take a while until I fully understand everything.
  • 0

#17 MudbudGoldfish

MudbudGoldfish

    Indie Game Dev Team

  • New Member
  • 494 posts
  • Version:GM8

Posted 10 February 2011 - 04:57 AM

wow, that was a bump..... This reminds me of the Nintendo DSI's picture changeing thing
  • 0

#18 TheSnidr

TheSnidr

    That guy

  • Global Moderators
  • 2939 posts
  • Version:GM:Studio

Posted 10 February 2011 - 07:55 PM

Never too late to comment, and every bump is much appreciated! Even though there are no posts in my engine topics, I usually update the engines regularly.

As for commenting the engine.. you want me to comment what's happening inside the scripts? I'm not sure people would care, but I can give you a brief explanation here.
Basically the for-loops initialize the points that the grid is made of.
Each point's variables are double arrays, where the first index (eg_ind) is the grid index (so that the user can make multiple grids without messing up the variables) and the second index (eg_dots[eg_ind]) is the index of the point.
Each point has the following variables:
eg_dsx= start x
eg_dsy= start y
eg_dx= x-value
eg_dy= y-value
eg_vx= horizontal speed
eg_vy= vertical speed
Also, eg_dots increases for each loop, giving each point a unique index.
The explode-script loops through the points closest to the explosion area and checks the distance and direction, then uses sine to achieve a smooth displacement.
The update scripts loop through all points, adding the speed variables to their position variables, and forces the points back towards their starting positions.

Unnderstand better now?
  • 0

#19 saim

saim

    GMC Member

  • GMC Member
  • 1087 posts

Posted 11 February 2011 - 11:29 AM

you want me to comment what's happening inside the scripts? I'm not sure people would care

I don't know about other people, but I love fully commented tutorials. But I understand how boring it can be to explain something that the code itself is supposed to explain.

Unnderstand better now?

MUCH better. Although I can't open the file right now, it explains in general lines what I remember from it. I'll re-read this as soon as I'm able to open the file, but I'm sure it will make a lot more sense, now.
Thank you! Again, that's a wonderful effect!
  • 0

#20 bluesy_92

bluesy_92

    GMC Member

  • New Member
  • 49 posts

Posted 01 March 2011 - 10:56 PM

I'm having trouble editing the engine to work when I create an explosion in another instance, rather than the one that is handling the grid. It has something to do with eg_vx not being recognized as a variable. I know all variables were declared as global in the create code, because I checked your script. How can I fix this?

EDIT: By editing the create script to set the variable as global, it works fine now. Sorry I did not see this sooner. You can ignore this post :-)

Edited by bluesy_92, 01 March 2011 - 11:20 PM.

  • 0

#21 teej

teej

    The PIXEL'er

  • GMC Member
  • 841 posts
  • Version:GM8

Posted 22 March 2011 - 09:00 AM

Nice effect, it could be useful for something. :):snitch:
  • 0

#22 ninja_x

ninja_x

    GMC Member

  • GMC Member
  • 276 posts

Posted 14 April 2011 - 04:18 AM

Awesome effect! I was able to make a distorting bomb shock-wave, something I've wanted to do for a while now, by combining this with background_create_from_screen().
Views were tricky until I figured out to draw the grid at (view_xview,view_yview) and to create the explosion effect at (-view_xview,-v_yview)

One suggestion:
in eg_explode there's the line:

eg_vx[a0,i]+=(eg_dsx[a0,i]+lengthdir_x(dist,dir)-eg_dx[a0,i])/5;
eg_vy[a0,i]+=(eg_dsy[a0,i]+lengthdir_y(dist,dir)-eg_dy[a0,i])/5;
Since "5" here is effectively the damping of the effect, maybe you should include it as an argument? (The argument would stored into a variable before the loop of course, and that variable would be used in the loop rather than referring to the argument for the sake of performance, of course.)
  • 0

#23 Dark Matter

Dark Matter

    RPG Expert

  • GMC Member
  • 3196 posts
  • Version:GM:Studio

Posted 14 April 2011 - 09:57 AM

(The argument would stored into a variable before the loop of course, and that variable would be used in the loop rather than referring to the argument for the sake of performance, of course.)

I think "argumentn" is going to be just as quick as "var n; n = argumentn".
  • 0

#24 ninja_x

ninja_x

    GMC Member

  • GMC Member
  • 276 posts

Posted 17 April 2011 - 07:27 AM

(The argument would stored into a variable before the loop of course, and that variable would be used in the loop rather than referring to the argument for the sake of performance, of course.)

I think "argumentn" is going to be just as quick as "var n; n = argumentn".


Oh, my bad. I always kind of assumed "argument" was slower since it was passing the value by reference every time or something, but now that I think about it I don't really know why I assumed that.
  • 0

#25 xot

xot

    GMC Dismember

  • Retired Staff
  • 4772 posts
  • Version:GM:Studio

Posted 17 April 2011 - 08:34 AM

In my experience, using argument is generally faster than using a temporary variable. For cases where the variable is accessed many times (in a loop, for instance) the difference can be significant. GM8.1 has made some changes to argument handling and it is possible this is no longer be the case.
  • 0

#26 vertex67

vertex67

    GMC Member

  • GMC Member
  • 515 posts

Posted 13 July 2011 - 03:58 PM

wow, this is soo much better than the first version (which i have been using in my WIP for the past year).
The velocity variables, eg_vx and eg_vy were not declared in the create script, so it threw errors until i added them, but seriously, amazing work!

btw, I was able to implement a very nice ripple effect by layering an implode on top of an explode, with the implode radius a bit smaller.
  • 0

#27 deluksic

deluksic

    GMC Member

  • GMC Member
  • 54 posts
  • Version:GM8

Posted 03 September 2011 - 10:03 PM

Realy good engine.. I see u used startx and y variables to move dots back in place, but what if u use relative position of other dots that are conected... u'd get a wave effect wich would be cooler than this... i cant use your engine cause i dont realy understand it well but u could rewrite it in this way and show us the result!
  • 0

#28 Osmium

Osmium

    Graphic Artist

  • GMC Member
  • 308 posts
  • Version:GM:Studio

Posted 07 September 2011 - 12:51 PM

Nice example! Might look a little pixelated at times but still amazing. :smile:
  • 0

#29 lolmister

lolmister

    GMC Member

  • New Member
  • 4 posts
  • Version:Mac

Posted 22 February 2012 - 06:23 PM

This looks amazing, but sadly since i have a mac I cannot use it... im just wondering what is done in the draw event. Im trying to do a similar distortion effect, but im having problems. So if I could see an example it could help clear things up for me.

Edited by lolmister, 22 February 2012 - 06:23 PM.

  • 0

#30 thecatlover1996

thecatlover1996

    GMC Member

  • GMC Member
  • 3 posts
  • Version:GM8

Posted 27 June 2012 - 08:05 PM

*bump* ^^

I was wondering if there would be a possiblity to have this distortion effect on the surface of the game itself, not just a background or a created surface.
I've tried some things, but it works quite slow and I was wondering if someone has done this already?
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users