Skip to content

Instantly share code, notes, and snippets.

@1j01
Last active June 7, 2018 04:32
Show Gist options
  • Save 1j01/e898d73d3b90b90e3bcf05122c65e155 to your computer and use it in GitHub Desktop.
Save 1j01/e898d73d3b90b90e3bcf05122c65e155 to your computer and use it in GitHub Desktop.
An old code doodle made in GameMaker 8.0 GML, of phantasmagorical circuitry. See the output here: https://imgur.com/a/ze0tV4o
var f,t,w,h,c,l,wires;
f=10; //cell size
c=2/5; //circle size
l=1/5; //line width
t=4;//only used here
w=128*t;
h=128*t;
wires=100; //"amount of wires"
if !(variable_global_exists("onemorepixel")){
global.onemorepixel=surface_create(w,h);
}
if !(variable_global_exists("onemorepixel_grid")){
global.onemorepixel_grid=ds_grid_create(w/5,h/5);
}
if !(surface_exists(global.onemorepixel)){
global.onemorepixel=surface_create(w,h);
surface_set_target(global.onemorepixel);
draw_clear_alpha($500000,true)
}else {
if(surface_get_width(global.onemorepixel)!=w
||surface_get_height(global.onemorepixel)!=h){
surface_free(global.onemorepixel);
global.onemorepixel=surface_create(w,h);
surface_set_target(global.onemorepixel);
draw_clear_alpha(c_green,1);
ds_grid_destroy(global.onemorepixel_grid);
global.onemorepixel_grid=ds_grid_create(w/f,h/f);
}else
surface_set_target(global.onemorepixel);
}
if !(variable_global_exists("onemorepixel_x")) global.onemorepixel_x=50;
if !(variable_global_exists("onemorepixel_y")) global.onemorepixel_y=50;
if !(variable_global_exists("onemorepixel_xd")) global.onemorepixel_xd=0;
if !(variable_global_exists("onemorepixel_yd")) global.onemorepixel_yd=1;
if !(variable_global_exists("onemorepixel_zd")) global.onemorepixel_zd=1;
////////////////////////////////////////////////
if(random(50)<2)global.onemorepixel_zd=!global.onemorepixel_zd;
if(random(500)<2)global.onemorepixel_zd+=1;
/*if(global.onemorepixel_zd>1)
draw_surface_stretched_ext(global.onemorepixel,4/2,4/2,w-4,h-4,c_white,1);
else */if(global.onemorepixel_zd)
draw_surface_stretched_ext(global.onemorepixel,1,1,w-2,h-2,c_white,1);
//draw_surface_part_ext(global.onemorepixel,w/4+w/8,h/4+h/8,w/4+w/8,h/4+h/8,w/4-1,h/4-1,1.02,1.02,-1,1);
if(global.onemorepixel_zd)ds_grid_clear(global.onemorepixel_grid,0);
repeat wires {
/*if(random(50)<2){
var tmp;
tmp=global.onemorepixel_xd;
global.onemorepixel_xd=global.onemorepixel_yd;
global.onemorepixel_yd=tmp;
}
if(random(50)<2){
global.onemorepixel_xd=choose(-1,0,1);
//oo=choose(-1,0,1);
oo=global.onemorepixel_xd==0;
if(random(50)<1)oo=choose(-1,0,1);
global.onemorepixel_yd=choose(-1*oo,0,1*oo);
}*/
if(random(50)<2 && ((global.onemorepixel_xd-global.onemorepixel_yd)==0)){
var tmp;
tmp=global.onemorepixel_xd;
global.onemorepixel_xd=global.onemorepixel_yd;
global.onemorepixel_yd=tmp;
}
//if(random(50)<2)global.onemorepixel_xd=choose(-1,0,1);
if(random(15)<2)global.onemorepixel_xd=min(1,max(-1,global.onemorepixel_xd+choose(-1,1)));
if(random(15)<2)global.onemorepixel_yd=min(1,max(-1,global.onemorepixel_yd+choose(-1,1)));
/*if(random(5)<2)global.onemorepixel_xd=-global.onemorepixel_xd;
if(random(5)<2)global.onemorepixel_yd=-global.onemorepixel_yd;*/
xp=global.onemorepixel_x;
yp=global.onemorepixel_y;
global.onemorepixel_x+=global.onemorepixel_xd*f;
global.onemorepixel_y+=global.onemorepixel_yd*f;
if(ds_grid_get(global.onemorepixel_grid,global.onemorepixel_x/f,global.onemorepixel_y/f)){
global.onemorepixel_x=xp;
global.onemorepixel_y=yp;
if(random(10)<5)
global.onemorepixel_xd=min(1,max(-1,global.onemorepixel_xd+choose(-1,1)));
else
global.onemorepixel_yd=min(1,max(-1,global.onemorepixel_yd+choose(-1,1)));
}else{
ds_grid_set(global.onemorepixel_grid,global.onemorepixel_x/f,global.onemorepixel_y/f,1);
}
draw_line_width_color(xp,yp,global.onemorepixel_x,global.onemorepixel_y,l*f,c_orange,c_yellow);
if(random(50)<1){
if(global.onemorepixel_x!=xp || global.onemorepixel_y!=yp)
draw_circle_color(global.onemorepixel_x,global.onemorepixel_y,c*f,c_yellow,c_yellow,1);
global.onemorepixel_x=irandom(w/f)*f;
global.onemorepixel_y=irandom(h/f)*f;
//if(ds_grid_region-____-)
draw_circle_color(global.onemorepixel_x,global.onemorepixel_y,c*f,c_yellow,c_yellow,0);
//f=choose(5,5,5,10,15);
}
}
if(random(100)<2){
draw_set_color($20A010);
draw_set_alpha(0.1);
draw_rectangle(0,0,w,h,0);
}
if(random(10)<2){
draw_set_alpha(0.9);
draw_set_color($204010);
draw_rectangle(0,0,w-1,h-1,1);
draw_set_color(choose(0,c_white,c_silver,c_silver));
draw_rectangle(1,1,w-2,h-2,1);
}
////////////////////////////////////////////////
global.AUTORUN_EXPORT=surface_start+string(global.onemorepixel)+surface_end;
//var o,i;
o=object_create();
//global.autorun_lastmod="[never]";
global.realoadtime=1; //steps
i=instance_create(o,o,o);
//i.hk=ord('R');
i.hk=vk_f9;i.hk_c=0;i.hk_a=0;
i.runthis=working_directory+"\gml\uneplanet.gml";
i.runthis=working_directory+"\gml\generate.gml";
i.runthis=working_directory+"\gml\generatesplines.gml";
i.runthis=working_directory+"\gml\generateboss.gml";
i.runthis=working_directory+"\gml\onemorepixel.gml";
persistent=true;
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
object_event_add(o,ev_step,0,"
if( 0
|| ((global.realoadtimer>global.realoadtime)&&global.realoadtime)
|| (keyboard_check_direct(hk)&&!global.kpr)
|| (mouse_check_button_pressed(mb_middle))
){
global.realoadtimer=0;global.kpr=keyboard_check_direct(hk);
(2).TEXT='';
if!file_exists(runthis){
with 2 print(runthis+' does not exist')
}else{
global.AUTORUNNING=true;
execute_file(runthis,'');
global.AUTORUNNING=false;
if variable_global_exists('AUTORUN_EXPORT')
(2).TEXT=global.AUTORUN_EXPORT;
//else with(2)print('NO GLOBAL AUTORUN_EXPORT');
with 2 scr_draw (2)(2).DRAWTEXTPREV=(2).DRAWTEXT2;
}
}
global.realoadtimer+=1;global.kpr=keyboard_check_direct(hk);
")global.realoadtimer=0global.kpr=0object_set_persistent(o,persistent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment