Advertisement
PinkiePie5892

Help needed, shop icon grid placement

Dec 26th, 2018
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Create Event:
  2. ///Init Shop
  3.  
  4. posIn=x
  5. posOut=x
  6. YposOut=y
  7. YposIn=y
  8.  
  9. shop=false
  10.  
  11. cost1=500
  12. cost2=1250
  13. cost3=10
  14. cost4=20
  15. cost5=2500
  16. cost6=10000000
  17. cost7=50
  18. cost8=100
  19.  
  20. GridWidth=0
  21. layer=2
  22.  
  23. i1=res_shop_tophat
  24. i2=res_shop_blush
  25. i3=res_shop_clicks
  26. i4=res_shop_sec
  27. i5=res_shop_superPaws
  28. i6=res_shop_whatsThis
  29.  
  30. i7=res_shop_empty
  31. i8=res_shop_empty
  32. i9=res_shop_clicksPlus
  33. i10=res_shop_secPlus
  34. i11=res_shop_empty
  35. i12=res_shop_empty
  36.  
  37.  
  38. //Item Setup 0:Sprite, 1:Name, 2:Price, 3:Desc., 4:sold out
  39. Item=ds_grid_create(12,5)
  40.  
  41. Item[# 0,0]=i1
  42. Item[# 0,1]="Tophat"
  43. Item[# 0,2]=cost1
  44. Item[# 0,3]="A snazzy tophat that doubles Paws."
  45. Item[# 0,4]=false
  46.  
  47. Item[# 1,0]=i2
  48. Item[# 1,1]="Blushies"
  49. Item[# 1,2]=cost2
  50. Item[# 1,3]="More Cuteness = More Paws; x2 Paws"
  51. Item[# 1,4]=false
  52.  
  53. Item[# 2,0]=i3
  54. Item[# 2,1]="Stronger Paws"
  55. Item[# 2,2]=cost3
  56. Item[# 2,3]="More Paws per click"
  57. Item[# 2,4]=false
  58.  
  59. Item[# 3,0]=i4
  60. Item[# 3,1]="Helping Paws"
  61. Item[# 3,2]=cost4
  62. Item[# 3,3]="More Paws per second"
  63. Item[# 3,4]=false
  64.  
  65. Item[# 4,0]=i5
  66. Item[# 4,1]="Super Paws"
  67. Item[# 4,2]=cost5
  68. Item[# 4,3]="Allows click and hold, upgrade further to hold longer"
  69. Item[# 4,4]=false
  70.  
  71. Item[# 5,0]=i6
  72. Item[# 5,1]="???"
  73. Item[# 5,2]=cost6
  74. Item[# 5,3]="OwO Whats This?"
  75. Item[# 5,4]=false
  76.  
  77.  
  78. Item[# 6,0]=i7
  79. Item[# 6,1]=""
  80. Item[# 6,2]=""
  81. Item[# 6,3]=""
  82. Item[# 6,4]=false
  83.  
  84. Item[# 7,0]=i8
  85. Item[# 7,1]=""
  86. Item[# 7,2]=""
  87. Item[# 7,3]=""
  88. Item[# 7,4]=false
  89.  
  90. Item[# 8,0]=i9
  91. Item[# 8,1]="Stronger Paws+"
  92. Item[# 8,2]=cost7
  93. Item[# 8,3]="Even More Paws per click"
  94. Item[# 8,4]=false
  95.  
  96. Item[# 9,0]=i10
  97. Item[# 9,1]="Helping Paws+"
  98. Item[# 9,2]=cost8
  99. Item[# 9,3]="Even More Paws per second"
  100. Item[# 9,4]=false
  101.  
  102. Item[# 10,0]=i11
  103. Item[# 10,1]=""
  104. Item[# 10,2]=""
  105. Item[# 10,3]=""
  106. Item[# 10,4]=false
  107.  
  108. Item[# 11,0]=i12
  109. Item[# 11,1]=""
  110. Item[# 11,2]=""
  111. Item[# 11,3]=""
  112. Item[# 11,4]=false
  113.  
  114. Pos[0]=x
  115. Pos[1]=x
  116. Pos[2]=x
  117. Pos[3]=x
  118. Pos[4]=x
  119. Pos[5]=x
  120.  
  121. Pos[6]=x
  122. Pos[7]=x
  123. Pos[8]=x
  124. Pos[9]=x
  125. Pos[10]=x
  126. Pos[11]=x
  127.  
  128. PosY[0]=y
  129. PosY[1]=y
  130. PosY[2]=y
  131. PosY[3]=y
  132. PosY[4]=y
  133. PosY[5]=y
  134.  
  135. PosY[6]=y
  136. PosY[7]=y
  137. PosY[8]=y
  138. PosY[9]=y
  139. PosY[10]=y
  140. PosY[11]=y
  141.  
  142. //Left Pressed Event:
  143. if shop=false {shop=true audio_play_sound(sound_options,0,0)}
  144. else
  145. if shop=true {shop=false audio_play_sound(sound_close,0,0)}
  146.  
  147. Draw Event:
  148. ///Shop Stuff
  149. var i2=0
  150. //Setup Icon Arrangement -- A second for loop was here, but I removed it, hence the var i2=0
  151. for(i=0; i<ds_grid_width(Item); i++;)
  152. {
  153.  
  154. //Draw Shop Icons  
  155.   if Pos[i+(0)]>x+0.25 and PosY[i2]<y+0.25
  156.   {
  157.    draw_sprite(Item[# i+(0),0],0,Pos[i+(0)],PosY[i2])
  158.    //draw_text(Pos[i+(0)],PosY[i2],i+(0)) --Item Placement Debug
  159.    if Item[# i+(0),4]=true {draw_sprite_ext(Item[# i+(0),0],0,Pos[i+(0)],PosY[i2],1,1,0,c_dkgray,1)}
  160.   }
  161.  
  162.   //Draw Notify Icon On Shop Icon If Not Shopping
  163.   if shop=false {if global.Paws>=Item[# i+(0),2] {draw_sprite(res_notify,0,x+sprite_width/2,y-sprite_width/2)} }
  164.  
  165. //Move Shop Icons Out  
  166.   if shop=true
  167.   {
  168.   Pos[i+(0)]=lerp(Pos[i+(0)],(posOut+46)+(34*(i+(0))),0.125)
  169.   PosY[i2]=lerp(PosY[i2],(YposOut)-(34*i2),0.125)
  170.  
  171. //Display Info When Moused Over  
  172.   if (mouse_x>(Pos[i+(0)]-16) and mouse_x<(Pos[i+(0)]-16)+32) and (mouse_y>(PosY[i2]-16) and mouse_y<(PosY[i2]-16)+32)
  173.   {
  174.    draw_set_font(global.font) //Change this, this is a custom font I made
  175.    draw_set_colour(c_white)      
  176.    draw_text(2,PosY[i2]-80,Item[# i+(0),1])  
  177.    ladder(Item[# i+(0),2],"Paws:",2,PosY[i2]-64)  
  178.    draw_text(2,PosY[i2]-48,Item[# i+(0),3])  
  179.    draw_set_font(-1)  
  180.    draw_set_colour(c_white)        
  181.   }
  182.   //Draw Notify Icon On Relative Icons If Shopping
  183.   if global.Paws>=Item[# i+(0),2] and Item[# i+(0),4]=false {draw_sprite(res_notify,0,Pos[i+(0)]+16,PosY[i2]-16)}
  184.  }
  185.   else
  186.   //Move Shop Icons In
  187.   if shop=false
  188.   {
  189.    Pos[i+(0)]=lerp(Pos[i+(0)],posIn,0.125)
  190.    PosY[i2]=lerp(PosY[i2],YposIn,0.125)
  191.   }
  192. }
  193.  
  194. //Buying Stuff
  195. if shop=true
  196. {
  197.  
  198.   if mouse_check_button_pressed(mb_left) and (mouse_x>(Pos[0]-16) and mouse_x<(Pos[0]-16)+32) and (mouse_y>(PosY[0]-16) and mouse_y<(PosY[0]-16)+32)
  199.   {
  200.    if global.Paws>=Shoppe.cost1 and Item[# 0,4]=false {audio_play_sound(sound_buy,0,0) global.Paws-=Shoppe.cost1 global.Tophat=true Item[# 0,4]=true Item[# 0,2]=0 Item[# 0,3]="Sold Out"}
  201.   }
  202.  
  203.   if mouse_check_button_pressed(mb_left) and (mouse_x>(Pos[1]-16) and mouse_x<(Pos[1]-16)+32) and (mouse_y>(PosY[1]-16) and mouse_y<(PosY[1]-16)+32)
  204.   {
  205.    if global.Paws>=Shoppe.cost2 and Item[# 1,4]=false {audio_play_sound(sound_buy,0,0) global.Paws-=Shoppe.cost2 global.Blush=true Item[# 1,4]=true Item[# 1,2]=0 Item[# 1,3]="Sold Out"}
  206.   }
  207.  
  208.   if mouse_check_button_pressed(mb_left) and (mouse_x>(Pos[2]-16) and mouse_x<(Pos[2]-16)+32) and (mouse_y>(PosY[2]-16) and mouse_y<(PosY[2]-16)+32)
  209.   {
  210.    if global.Paws>=Shoppe.cost3 {audio_play_sound(sound_buy,0,0) global.Paws-=Shoppe.cost3 global.PawClick+=1 Shoppe.cost3+=floor(cost3*global.Tax) Item[# 2,2]=cost3}
  211.   }
  212.  
  213.   if mouse_check_button_pressed(mb_left) and (mouse_x>(Pos[3]-16) and mouse_x<(Pos[3]-16)+32) and (mouse_y>(PosY[3]-16) and mouse_y<(PosY[3]-16)+32)
  214.   {
  215.    if global.Paws>=Shoppe.cost4 {audio_play_sound(sound_buy,0,0) global.Paws-=Shoppe.cost4 global.PawSec+=1 Shoppe.cost4+=floor(cost4*global.Tax) Item[# 3,2]=cost4}
  216.   }
  217.  
  218.   if mouse_check_button_pressed(mb_left) and (mouse_x>(Pos[4]-16) and mouse_x<(Pos[4]-16)+32) and (mouse_y>(PosY[4]-16) and mouse_y<(PosY[4]-16)+32)
  219.   {
  220.    if global.Paws>=Shoppe.cost5 {audio_play_sound(sound_buy,0,0) global.Paws-=Shoppe.cost5 OwO.HoldMax+=10 OwO.PawHold=OwO.HoldMax Shoppe.cost5+=floor(cost5*global.Tax) Item[# 4,2]=cost5 }
  221.   }
  222.  
  223.   if mouse_check_button_pressed(mb_left) and (mouse_x>(Pos[5]-16) and mouse_x<(Pos[5]-16)+32) and (mouse_y>(PosY[5]-16) and mouse_y<(PosY[5]-16)+32)
  224.   {
  225.    if global.Paws>=Shoppe.cost6 and Item[# 5,4]=false {audio_play_sound(sound_buy,0,0) global.Paws-=Shoppe.cost6 global.What=true Item[# 5,4]=true Item[# 5,2]=0 Item[# 5,3]="Sold Out"}
  226.   }  
  227.  
  228.   if mouse_check_button_pressed(mb_left) and (mouse_x>(Pos[8]-16) and mouse_x<(Pos[8]-16)+32) and (mouse_y>(PosY[8]-16) and mouse_y<(PosY[8]-16)+32)
  229.   {
  230.    if global.Paws>=Shoppe.cost7 {audio_play_sound(sound_buy,0,0) global.Paws-=Shoppe.cost7 global.PawClick+=2 Shoppe.cost7+=floor(cost3*global.Tax) Item[# 8,2]=cost7}
  231.   }
  232.  
  233.   if mouse_check_button_pressed(mb_left) and (mouse_x>(Pos[9]-16) and mouse_x<(Pos[9]-16)+32) and (mouse_y>(PosY[9]-16) and mouse_y<(PosY[9]-16)+32)
  234.   {
  235.    if global.Paws>=Shoppe.cost8 {audio_play_sound(sound_buy,0,0) global.Paws-=Shoppe.cost8 global.PawSec+=2 Shoppe.cost8+=floor(cost4*global.Tax) Item[# 9,2]=cost8}
  236.   }
  237.    
  238. }
  239.  
  240. draw_self()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement