Skip to content

Instantly share code, notes, and snippets.


Poppy Works PoppyWorks

View GitHub Profile
PoppyWorks / tileset.scm
Last active July 18, 2018 03:28 — forked from MobiDevelop/tileset.scm
GIMP script that adds a bleed and margin to an existing tilesheet/spritesheet. Very useful!
View tileset.scm
(define (script-fu-respace-tiles-addMarginSpacing inImage inLayer tileSize)
(let* (
(margin 1)
(spacing 2)
(duplicatePadding TRUE)
(theWidth (car (gimp-drawable-width inLayer)))
(theHeight (car (gimp-drawable-height inLayer)))
(theMarginX (* 2 margin))
(theMarginY (* 2 margin))
PoppyWorks / setup_language
Last active August 16, 2018 19:08
GML Script. This should allow the use of any language files to be placed in an ISO639 standard named folder. The game should react accordingly based on the user's OS language. Alternatively, you can change global.language manually to test this feature.
View setup_language
//build fonts
global.fnt_textbox = font0;
//get OS Language
global.language = os_get_language();
//Load appropriate langage table for UI via JSON
PoppyWorks / gamepad_color
Created July 23, 2018 00:58
GML Script for changing the color of a DS4 gamepad. Will likely only function on PS4. Will return true upon completion of the color change.
View gamepad_color
var device = argument0;
var color = argument1;
var time = argument2; //(use something like .01)
if color != global.gpColor
var led = merge_color(global.gpColor,color,global.gpColorFader)
global.gpColorFader += time;
PoppyWorks / draw_fade_color
Last active July 23, 2018 16:58
GML script. Will fade the screen to the chosen color. Returns true when done. This can be used to change rooms when it returns. Line 6 can be un-commented to do the fade to color in steps, to simulate old-school style color fading.
View draw_fade_color
alert(0,"Fading..." + "(" + (string(color_fade_alpha)) +"). Cannot pause game." )
can_pause = false;
depth = -100000
var snapped = color_fade_alpha//= floor(color_fade_alpha * 10)/10
draw_rectangle(0, 0, view_xview [0] + view_wview[0], view_yview[0] + view_hview[0], false);
PoppyWorks / setup_audio
Last active August 14, 2018 10:49
GML Script. This sets up all listeners available on a target platform. In the case of PS4, you can use this to play audio on a DS4 speaker. Run before running anything using audio_play_sound_on();. In addition, this fixes GMS games being too quiet or low volume on consoles. Best run in a Create event.
View setup_audio
var lc = audio_get_listener_count();
var masks;
masks[0] = 0;
masks[1] = 0;
masks[2] = 0;
masks[3] = 0;
alert("Number of Audio Listeners: " + string(lc),0)
PoppyWorks / audio_play
Created July 23, 2018 01:34
GML Script. By using this after our setup_listeners(); gist, you can play audio on any listener, fade over time, and loop.
View audio_play
///audio_play(listener,snd_filename,fade in time[ms],loop?)
var listener = argument0;
var sfx = argument1;
var time = argument2;
var loop = argument3;
if gamepad_is_connected(listener)
sfx = audio_play_sound_on(listener, sfx, loop, 0);
else if listener == noone || listener == -1
PoppyWorks / alert
Last active July 27, 2018 02:02
GML Script. A basic multi-level wrapper for the debug/message system used in Gamemaker Studio. Alert will be seen throughout our samples here. When shipping, you can comment the entire script out easily!
View alert
///alert(level[0 to 3],message)
var level = argument0;
var text = argument1;
switch (argument0)
case 0: show_debug_message("DEBUG: "+text); break;
case 1: show_debug_message("ERROR: "+text); break;
case 2: show_message("ALERT: "+text); break;
PoppyWorks / setup_input
Created August 13, 2018 22:16
GML script. Sets up our globals for all input functions in other scripts posted here.
View setup_input
///setup_input(run in a create event!)
var gp_num = gamepad_get_device_count();
for (var i = 0; i < gp_num; i++;)
if gamepad_is_connected(i)
alert("DEBUG: "+ string(gamepad_get_description(i)),0)
PoppyWorks / input_change
Last active August 14, 2018 01:00
GML Script. Knows what OS you are using, and if you are using a gamepad or keyboard/mouse. Use bootstrap after input_change(). Bootstrapper ensures that a gamepad is connected before allowing the user to swap over to gamepad input from Keyboard/mouse.
View input_change
///PC users or PS4 Input
if os_type == os_windows || os_ps4 || os_xboxone
if gamepad_button_check_any(global.gpDevice)
global.KBMuser = false;
if keyboard_check(vk_anykey) || mouse_check_button(mb_any)
global.KBMuser = true;
PoppyWorks / gamepad_button_check_any
Created August 13, 2018 22:18
GML Script. Checks to see if the device number (argument0) was interacted with at all. Used in input_change() to know to swap inputs!
View gamepad_button_check_any
device = argument0;
for ( var i = gp_face1; i < gp_axisrv; i++ )
if ( gamepad_button_check(device , i ) ) return i;
return false;