Advertisement
Guest User

some code from tetrode 0.20, now commented!

a guest
Mar 15th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///TETRODE 0.20 ALPHA CODE DUMP
  2. ///CODE FROM CREATE AND STEP EVENT OF PLAYER OBJECT
  3. ///THIS CODE IS THE PROPERTY OF JULIAN DRAKE, AND MAY ONLY BE USED FOR EDUCATIONAL PURPOSES!
  4.  
  5.  
  6. ///CREATE EVENT
  7. audio_stop_sound(titlesong) //stop the title music
  8.  
  9.  
  10. //if custom_textures folder does not exist, make it
  11. if !directory_exists("custom_textures")
  12.    {
  13.    directory_create("custom_textures");
  14.    }
  15. //if scenarios folder does not exist, make it
  16. if !directory_exists("scenarios")
  17.    {
  18.    directory_create("scenarios");
  19.    }
  20.    
  21.    
  22.  
  23.  
  24.  
  25.  
  26. global.worldtype = irandom(1) //set the world type to either:
  27. //0 - normal
  28. //1 - snow
  29.  
  30.  
  31.  
  32. customsprite = false //we are not using a custom sprite
  33.  
  34. global.ammo = 30 //start with 30 bullets
  35.  
  36.  
  37. global.flight = 0 //flight is disabled
  38.  
  39. global.playerr = 255 //player r is 255
  40. global.playerg = 255 //player g is 255
  41. global.playerb = 255 //player b is 255
  42. global.usecolor = false //these values would only take effect if this was true
  43.  
  44. global.currentchest = 0 //we are not in a chest
  45.  
  46. global.timedisplay = 0 //do not display the time
  47. global.minutes = 0; //0 minutes on time display
  48. global.seconds = 0; //0 seconds on time display
  49. global.steps = 0; //0 steps on time display
  50.  
  51.  
  52.  
  53. global.rave = "false" //not in rave mode
  54. global.walking = false //not in walk mode (does that even exist?)
  55. global.strictplace = "true" //strict block placement is enabled
  56.  
  57.  
  58. cat1chance = 10 //how many normal cataracts spawn per night
  59. cat2chance = 3 //how many super cataracts spawn per night
  60.  
  61. c1ts = cat1chance //sets "c1ts" to "cat1chance". forget what this does :p
  62. c2ts = cat2chance //sets "c2ts" to "cat2chance". forget what this does :p
  63. global.EDN_hour = -1 //start game at night
  64.  
  65. global.dbmp = true //something?
  66.  
  67.  
  68. global.init = false //something with checking world status?
  69. global.spawnt = -1 //spawn timer?
  70. global.dl = false //do not decrease lag yet
  71. global.debug = 0 //we are not in debug mode
  72. dis = false //something
  73. global.ci = false //something
  74. global.moving = false //are we moving?
  75. global.consoletheme = "cmd" //sets the default dev console theme to green and black
  76. global.inconsole = false //we are not in the console
  77. global.cod = "" //something
  78. global.ps = "" //something
  79. global.iff = 0 //something
  80. num = 0 //i think this is the screenshot number?
  81. stc = 0 //no idea what this is
  82. global.freeslot = false //no free slots are in the inventory (will be set to the right value when game starts)
  83. global.blevel = 25 //mining laser bullet counter (gui only)
  84. global.blevel2 = 16 //handgun bullet counter
  85. global.blevel3 = 50 //assault rifle bullet counter
  86. if global.set = false{ //if these variables have not yet been set...
  87.     ///Initialize Variables
  88. grav = 1; //gravity
  89. hsp = 0; //horizontal speed (don't change)
  90. vsp = 0; //vertical speed (don't change)
  91. jumpspeed = 15; //vertical change
  92. movespeed = 4; //horizontal change
  93. dir = "right" //face dir
  94. health = 100 //health
  95. global.ss = 0 //selected slot
  96.  
  97.  
  98. //global.inv = inventory array
  99. global.inv[0,0] = 0 //inv slot 1 id
  100. global.inv[0,1] = 1 //inv slot 1 quantity
  101. global.inv[1,0] = 9 //inv slot 2 id
  102. global.inv[1,1] = 1 //inv slot 2 quantity
  103. global.inv[2,0] = -1 //inv slot 3 id
  104. global.inv[2,1] = 0 //inv slot 3 quantity
  105. global.inv[3,0] = -1 //inv slot 4 id
  106. global.inv[3,1] = 0 //inv slot 4 quantity
  107. global.inv[4,0] = -1 //inv slot 5 id
  108. global.inv[4,1] = 0 //inv slot 5 quantity
  109. alarm[0] = 3 //starts the assault rifle/mining laser shoot loop
  110. global.wegood = true //humorous name for the same thing as "global.set"
  111. global.set = true //we are now done loading the player's core variables
  112. }
  113.  
  114.  
  115.  
  116. if global.gm = "superhot" //if in superhot gamemode, start with a handgun
  117.     {
  118. global.inv[0,0] = 4
  119. global.inv[0,1] = 1
  120. global.inv[1,0] = -1
  121. global.inv[1,1] = 0
  122. global.inv[2,0] = -1
  123. global.inv[2,1] = 0
  124. global.inv[3,0] = -1
  125. global.inv[3,1] = 0
  126. global.inv[4,0] = -1
  127. global.inv[4,1] = 0
  128.     }
  129. if global.gm = "crashed" //if in crashlanded gamemode, give some materials
  130.     {
  131. global.ammo = 300
  132. global.inv[0,0] = 3
  133. global.inv[0,1] = 1
  134. global.inv[1,0] = 8
  135. global.inv[1,1] = 1
  136. global.inv[2,0] = 48
  137. global.inv[2,1] = 200
  138. global.inv[3,0] = 27
  139. global.inv[3,1] = 15
  140. global.inv[4,0] = 1
  141. global.inv[4,1] = 50
  142.     }
  143. if global.gm = "skyblock" //if in skyblock gamemode, give pickaxe, mining laser, and metal blocks
  144.     {
  145. global.inv[0,0] = 0
  146. global.inv[0,1] = 1
  147. global.inv[1,0] = 1
  148. global.inv[1,1] = 8
  149. global.inv[2,0] = -1
  150. global.inv[2,1] = 0
  151. global.inv[3,0] = -1
  152. global.inv[3,1] = 0
  153. global.inv[4,0] = -1
  154. global.inv[4,1] = 0
  155.     }
  156.  
  157. ///Item Defs
  158. //yo yo listen up we gon' define some items
  159.  
  160. global.nummax = 9
  161. global.iname[0] = "Pickaxe"
  162. global.iname[1] = "Metal Block"
  163. global.iname[2] = "Ship Wall"
  164. global.iname[3] = "Diamond Pickaxe"
  165. global.iname[4] = "9mm Handgun"
  166. global.iname[5] = "Grass Block"
  167. global.iname[6] = "Dirt Block"
  168. global.iname[7] = "Stone Block"
  169. global.iname[8] = "Assault Rifle"
  170. global.iname[9] = "Mining Laser"
  171. global.iname[10] = "Monster Claw"
  172. global.iname[11] = "Coal"
  173. global.iname[12] = "Copper Ingot"
  174. global.iname[13] = "Wooden Planks"
  175. global.iname[14] = "Diamond"
  176. global.iname[15] = "Wooden Bucket"
  177. global.iname[16] = "Iron Bucket"
  178. global.iname[17] = "Feather"
  179. global.iname[18] = "Gold Ingot"
  180. global.iname[19] = "Health Potion"
  181. global.iname[20] = "Iron Ingot"
  182. global.iname[21] = "Water Bucket"
  183. global.iname[22] = "Leaf"
  184. global.iname[23] = "Leather"
  185. global.iname[24] = "Raw Meat"
  186. global.iname[25] = "Cooked Meat"
  187. global.iname[26] = "Raw Steak"
  188. global.iname[27] = "Cooked Steak"
  189. global.iname[28] = "Oil"
  190. global.iname[29] = "Copper Ore"
  191. global.iname[30] = "Diamond Ore"
  192. global.iname[31] = "Gold Ore"
  193. global.iname[32] = "Iron Ore"
  194. global.iname[33] = "Etherium Ore"
  195. global.iname[34] = "Stone"
  196. global.iname[35] = "Wooden Logs"
  197. global.iname[36] = "Sand"
  198. global.iname[37] = "Acidic Solution"
  199. global.iname[38] = "Quantum Powder"
  200. global.iname[39] = "Stick"
  201. global.iname[40] = "Steel Ingot"
  202. global.iname[41] = "Tokamak Reactor"
  203. global.iname[42] = "Energy Trasmitter"
  204. global.iname[43] = "Wire Spool"
  205. global.iname[44] = "Pocket Knife"
  206. global.iname[45] = "Battery Block"
  207. global.iname[46] = "Solar Panel"
  208. global.iname[47] = "Wrench"
  209. global.iname[48] = "Wood Block"
  210. global.iname[49] = "Caustic Tentacle"
  211. global.iname[50] = "Railgun"
  212. global.iname[51] = "Flare Gun"
  213. global.iname[52] = "Metal Plate"
  214. global.iname[53] = "Stone Generator"
  215. global.iname[54] = "Chest"
  216. global.iname[55] = "Sign"
  217. global.iname[56] = "Furnace"
  218. global.iname[57] = "Ammo Clip"
  219. global.iname[58] = "Sniper Rifle"
  220. global.iname[59] = "Bricks"
  221. global.iname[60] = "Potato Knish"
  222. global.iname[61] = "Mining Drill"
  223. global.iname[62] = "Molten Rock"
  224.  
  225. ///Crafting Defs (not used)
  226. global.recipes[0,0] = 13
  227. global.recipes[0,1] = 35
  228.  
  229. ///Achievement Progress (says "we have not gotten these achivements yet")
  230. global.achive1unlocked = false
  231. global.achive2unlocked = false
  232.  
  233.  
  234.  
  235. //STEP EVENT
  236.  
  237.  
  238. if place_meeting(x,y+2,obj_mrock) //if on molten rock...
  239.     {
  240.     health = health - 1 //decrease health
  241.     }
  242. if health < 1 //if you die by this...
  243.     {
  244.     global.cod = "toohot" //your cause of death was "toohot"
  245.     }
  246.  
  247. //if place_meeting (x,y,fluid_water) or place_meeting(x,y-1,fluid_water)
  248. //{
  249. //if !keyboard_check(vk_shift)
  250.    // {
  251.     //vsp = -3
  252.    // }
  253. //}
  254.  
  255.  
  256. //if we have not finished the loading process and are in skyblock, start generating some islands
  257. if global.dl = false
  258.     {
  259.     if global.gm = "skyblock"{
  260.     instance_create(irandom(room_width),irandom(room_height),island_gen)
  261.     }}
  262.  
  263. //code for the time counter
  264. global.steps += 1;
  265. if global.steps >= room_speed
  266. {
  267. global.steps = 0;
  268. global.seconds += 1;
  269.  
  270. if global.seconds >= 60
  271. {
  272. global.seconds = 0;
  273. global.minutes += 1;
  274. }
  275. }
  276.  
  277. //set the custom player sprites
  278. if customsprite = false{
  279.  
  280. if global.char = "human"
  281.     {
  282.     if global.walking = true
  283.         {
  284.         sprite_index = human
  285.         }
  286.     if global.walking = false
  287.         {
  288.         sprite_index = humanidle
  289.         }
  290. if global.char = "tetrode"
  291.     {
  292.     sprite_index = sprite0
  293.     }
  294. if global.char = "cat1"
  295.     {
  296.     sprite_index = cat1
  297.     }
  298.     }}
  299.  
  300. //if it's night, spawn some cataracts
  301. if object_exists(obj_EDN){
  302. if global.EDN_hour = 0
  303.     {
  304.     cx = irandom(room_width)
  305.     cy = irandom(room_height)
  306.     if c1ts != 0
  307.         {
  308.         c1ts = c1ts - 1
  309.         if place_free(cx,cy)
  310.             {
  311.             if cy >= room_height/2
  312.                 {
  313.             instance_create(cx,cy,obj_cat1)
  314.                 }
  315.             }
  316.         else
  317.             {
  318.             c1ts = c1ts + 1
  319.             }
  320.         }
  321.         if c2ts != 0
  322.         {
  323.         c2ts = c2ts - 1
  324.         if place_free(cx,cy)
  325.             {
  326.             instance_create(cx,cy,obj_cat2)
  327.             }
  328.             if cy >= room_height/2
  329.                 {
  330.             instance_create(cx,cy,obj_cat1)
  331.                 }
  332.         else
  333.             {
  334.             c2ts = c2ts + 1
  335.             }
  336.         }
  337.     }}
  338. if global.EDN_hour = 1
  339.     {
  340.     c1ts = cat1chance
  341.     c2ts = cat2chance
  342.     }
  343.  
  344.  
  345. //set stats for cataract playertype
  346. if global.char = "cat1"
  347.     {
  348.     grav = 0
  349.     movespeed = 2
  350.     jumpspeed = 15
  351.     }
  352. //set stats for human playertype
  353. if global.char = "human"
  354.     {
  355.     grav = 1
  356.     movespeed = 4
  357.     jumpspeed = 10
  358.     }
  359.  
  360. //if we're using a custom sprite, make our sprite that sprite
  361. if customsprite = true
  362.     {
  363.     sprite_index = newskinsprite
  364.     }
  365.  
  366. //decreases the level's loading timer
  367. if global.spawnt != 0 or - 1
  368.     {
  369.     global.spawnt = global.spawnt - 1
  370.     }
  371. if global.spawnt = 0
  372.     {
  373.     global.dl = true
  374.     }
  375. if global.ci = true
  376.     {
  377.     if dis = false
  378.         {
  379.         dis = true
  380.         alarm[1] = 5
  381.         }
  382.     }
  383.  
  384. //maintain 60 fps (does this even work?)
  385. if global.gm = "normal"
  386.     {
  387.     if room_speed != real(60)
  388.         {
  389.         room_speed = 60
  390.         }
  391.     }
  392.  
  393. //if we die, go to the "you died" screen
  394. if health < 0
  395.     {
  396.     room_goto(dead)
  397.     }
  398.    
  399. //if we have no gun, our bullets have no damage
  400. global.bdmg = 0
  401.  
  402. //no idea what this does
  403. global.iff = global.iff + 1
  404. if global.iff = 5
  405.     {
  406.     global.iff = 0
  407.     }
  408.  
  409. //loops the var stc (slot to check) through 0-5
  410. stc = stc + 1
  411. if stc = 5
  412.     {
  413.     stc = 0
  414.     }
  415.    
  416. //infinite health in creative mode
  417. if global.gm = "creative"
  418.     {
  419.     health = 100
  420.     }
  421.    
  422. //keep our player in the level's horizontal border
  423. x=clamp(x, 32, room_width-32);
  424. //y=clamp(y, 0, room_height-64);
  425.  
  426. //kill the player if they fall out of the world
  427. if y > room_height
  428.     {
  429.     health = health - 5
  430.     if health < 1
  431.         {
  432.         global.cod = "fall"
  433.         }
  434.     }
  435.  
  436. //Get the player's input
  437. key_right = keyboard_check(ord("D"));
  438. key_left = -keyboard_check(ord("A"));
  439. key_jump = keyboard_check_pressed(vk_space);
  440. key_dec = keyboard_check(vk_shift)
  441. key_rise = keyboard_check(vk_space)
  442.  
  443. //React to inputs
  444. move = key_left + key_right;
  445. hsp = move * movespeed;
  446. if (vsp < 10) vsp += grav;
  447.  
  448. if global.gm != "cat"{
  449. if (place_meeting(x,y+1,blockbase))
  450. {
  451.     vsp = key_jump * -jumpspeed
  452. }
  453. }
  454.  
  455. //flight controls for cataract player
  456. if global.char = "cat1"
  457.     {
  458.     if key_rise
  459.         {
  460.         if place_free(x,y-6)
  461.             {
  462.             y = y - 4
  463.             }
  464.         }
  465.     if key_dec
  466.         {
  467.         if place_free(x,y+6)
  468.             {
  469.             y = y + 4
  470.             }
  471.         }
  472.     }
  473.    
  474. //flight controls for creative mode
  475. if global.gm = "creative"
  476.     {
  477. if global.flight = 1
  478.     {
  479.     grav = 0
  480.         if key_rise
  481.         {
  482.         if place_free(x,y-10)
  483.             {
  484.             y = y - 8
  485.             }
  486.         }
  487.     if key_dec
  488.         {
  489.         if place_free(x,y+10)
  490.             {
  491.             y = y + 8
  492.             }
  493.         }
  494.     }
  495.     else
  496.         {
  497.         grav = 1
  498.         }
  499.     }
  500. //Horizontal Collision
  501. if (place_meeting(x+hsp,y,blockbase))
  502. {
  503.     while(!place_meeting(x+sign(hsp),y,blockbase))
  504.     {
  505.         x += sign(hsp);
  506.     }
  507.     hsp = 0;
  508. }
  509. x += hsp;
  510.  
  511. //Vertical Collision
  512. if (place_meeting(x,y+vsp,blockbase))
  513. {
  514.     while(!place_meeting(x,y+sign(vsp),blockbase))
  515.     {
  516.         y += sign(vsp);
  517.     }
  518.     vsp = 0;
  519. }
  520. y += vsp;
  521.  
  522. if keyboard_check(ord("D"))
  523.     {
  524.     global.walking = true
  525.     dir = "right"
  526.     }
  527. else if keyboard_check(ord("A"))
  528.     {
  529.     global.walking = true
  530.     dir = "left"
  531.     }
  532. else
  533.     {
  534.     global.walking = false
  535.     }
  536.    
  537.  
  538.  
  539.  
  540. //i think this was supposed to shake the ship screen, but it never worked?
  541. if room_get_name(room) = room0
  542.     {
  543.     __view_set( e__VW.XView, 0, x - irandom(5) + irandom(5 ))
  544.     __view_set( e__VW.YView, 0, y - irandom(5) + irandom(5 ))
  545.     }
  546.    
  547.    
  548. //loop the var num 0-5
  549. num = num + 1
  550. if num = 5
  551.     {
  552.     num = 0
  553.     }
  554. if global.inv[num,1] = 0
  555.     {
  556.     global.freeslot = num
  557.     }
  558. else
  559.     {
  560.     global.freeslot = false
  561.     }
  562.    
  563.  
  564.  //handle the bullet damages for the various guns (may need rebalanced!)
  565. if global.inv[global.ss,0] = 4
  566.     {
  567.     global.bdmg = 20
  568.     }
  569. if global.inv[global.ss,0] = 8
  570.     {
  571.     global.bdmg = 10
  572.     }
  573. if global.inv[global.ss,0] = 9
  574.     {
  575.     global.bdmg = 5
  576.     }
  577. if global.inv[global.ss,0] = 44
  578.     {
  579.     global.bdmg = 5
  580.     }
  581.    
  582.    
  583. //handle the "time only moves when you do" aspect of SUPERHOT mode
  584. if global.gm = "superhot"
  585.     {
  586.     if keyboard_check(ord("D")) or keyboard_check(ord("A")) or keyboard_check_pressed(vk_space) or mouse_check_button(mb_left)
  587.         {
  588.         room_speed = real(60)
  589.         }
  590.     if !keyboard_check(ord("D")) and !keyboard_check(ord("A")) and !keyboard_check_pressed(vk_space) and !mouse_check_button(mb_left)
  591.         {
  592.         room_speed = real(2)
  593.         }
  594.     }
  595.    
  596.    
  597.  
  598.  
  599. ///handle core fuctions
  600. if keyboard_check_pressed(ord("R"))
  601.     {
  602.     room_restart();
  603.     }
  604. if keyboard_check_pressed(ord("R")) and keyboard_check(vk_shift)
  605.     {
  606.     game_restart();
  607.     }
  608.  
  609.  
  610. ///lag decreaser 2000
  611. if global.dl = true
  612.     {
  613. //instance_deactivate_object(real_water) //Deactivate water
  614. instance_deactivate_object(itempickup) //Deactivate dropped items
  615. instance_deactivate_object(obj_explosion) //Deactivate explosions
  616. instance_deactivate_object(ebase) //Deactivate entities
  617. instance_deactivate_object(blockwall) //Deactivate walls
  618. instance_deactivate_object(blockbase); //Deactivate blocks
  619. instance_deactivate_object(tmake); //i forget what this is :p
  620.  
  621. instance_activate_region(__view_get( e__VW.XView, 0 ),__view_get( e__VW.YView, 0 ),__view_get( e__VW.WView, 0 ),__view_get( e__VW.HView, 0 ),true); //Activate all instances inside view
  622.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement