Author Topic: Post your Code Snippets  (Read 9788 times)

Sudnep

  • Global Moderator
  • Spike Dodger
  • Posts: 124
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 51.0.2704.84 Chrome 51.0.2704.84
    • View Profile
  • Playstyle: Keyboard
Re: Post your Code Snippets
« Reply #15 on: June 19, 2016, 02:52:32 AM »
These are just a bunch of scripts I use for generic effects in avoidance. :) Hopefully someone finds these useful. If you have any problems or errors message me on discord @ Sudnep#2735

The way to use these scripts is to run these scripts is to run scrCreateEvent in the object's create event and then in the step event write whatever scripts you want the object to do within it. An example can be found here: link

(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)

(click to show/hide)

A zip file containing all of the script.gml files and objTrail for studio can be found here: link
« Last Edit: June 19, 2016, 03:08:33 AM by Sudnep »

bananaguy12mhc

  • Guest
Re: Post your Code Snippets
« Reply #16 on: June 19, 2016, 01:31:35 PM »
Thank you so much Sudnep!  :atkHappy:

klazen108

  • Administrator
  • The Kid
  • Posts: 286
  • your a kid now your a squid now
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 51.0.2704.103 Chrome 51.0.2704.103
    • View Profile
    • Delicious-Fruit
  • Playstyle: Keyboard
Re: Post your Code Snippets
« Reply #17 on: August 01, 2016, 10:27:59 PM »
Easy Spotlight Shader - This one's a gmz because it comes with a sprite, shader, script, and example object and room! Shows a super easy method of creating spotlights without needing a huge sprite with a cutout, crazy blend modes, or any other complicated hacks - Just a function called "draw_spotlight"!

Zapmunk

  • Wannabe
  • Posts: 9
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 47.0 Firefox 47.0
    • View Profile
  • Playstyle: Keyboard
Re: Post your Code Snippets
« Reply #18 on: August 09, 2016, 12:40:55 AM »
A little script I wrote to replace gamemaker's tragic lack of a move_contact_object function. Could be a good start for anyone who wants to convert the physics to non-solid blocks like me.

(click to show/hide)

It works more or less like move_contact_solid, except:
  • The direction argument is given in vector component form. This is easy because this is only (supposed) to work for the cardinal directions, and will probably fail if you try to move diagonally with this. Best used with values of -1, 0, or 1 (higher numbers will decrease the step resolution)
  • It can and will move you backwards if you intersect something and attempt to move to contact away from it- if you are checking for contact downwards, and your head is clipped into a ceiling, it will teleport you so your feet are on top of the block you were previously underneath
  • It operates on bounding boxes, so sloped surfaces and anything with precise collision checking is out of the question. Everything will be treated as if it is rectangular.
  • It returns the id of the object you moved to contact with, or noone if you did not collide with anything
  • Due to platforms being children of blocks in the major engines I'm aware of, it will almost certainly royally screw up platform physics. You may need to unparent objBlock from them, and re-create the remaining platform functionality manually.

Zapmunk

  • Wannabe
  • Posts: 9
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Firefox 51.0 Firefox 51.0
    • View Profile
  • Playstyle: Keyboard
Re: Post your Code Snippets
« Reply #19 on: January 28, 2017, 05:53:16 PM »
A fragment shader for converting to and from HSV. Useful for performing color effects.
The shader supplied here replaces the default image_blend functionality with something like the sprite editor's colorize function, but it can be easily be modified to do other HSV-color-space effects. (I recommend against using it for anything that doesn't require hue though, since saturation and volume can both be manipulated directly in RGB color space)

(click to show/hide)
« Last Edit: February 02, 2017, 03:31:27 AM by Zapmunk »

patrickgh3

  • Spike Dodger
  • Posts: 169
  • stay optimistic! :D
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 56.0.2924.87 Chrome 56.0.2924.87
    • View Profile
    • Github
  • Playstyle: Keyboard
Re: Post your Code Snippets
« Reply #20 on: February 20, 2017, 03:46:45 AM »
Updated my nice-feeling push blocks. Fixed some bugs, and made the code simpler. https://tinyurl.com/zx9ra6h