Advertisement
pastamaker

swords 1

Jun 16th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. ; #Warn  ; Enable warnings to assist with detecting common errors.
  3. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  4. SetWorkingDir %A_ScriptDir%\png ; easy way to find images
  5.  
  6.  
  7. #SingleInstance,force
  8. SetBatchLines,-1
  9. #Include,<hellbents_gdip>
  10. popUp:=Layered_Window_SetUp(4,50,50,A_ScreenWidth,A_ScreenHeight,1,"+alwaysontop")
  11. backg := new Back
  12. backg.set()
  13. swords := new Knives
  14.  
  15. swords.set(0.3,backg)
  16. press:=0
  17. loop {
  18.     if(press = 0 and GetKeyState("lbutton")){
  19.         MouseGetPos,x1,y1
  20.         press:=1
  21.     }
  22.     if(press = 1 and GetKeyState("lbutton") = 0 ){
  23.         MouseGetPos,x2,y2
  24.    
  25.         vx:=(x2-x1)/3
  26.         vy:=(y2-y1)/3
  27.         swords.add(x1,y1,vx,vy,1)
  28.         press:=0
  29.     }
  30.        
  31.  
  32.  
  33.     Sleep 1000/24
  34.  
  35.     Gdip_GraphicsClear(popUp.g)
  36.     backg.draw(popup.g)
  37.    
  38.     swords.move()
  39.     swords.delete()
  40.     swords.draw(popup.g)
  41.    
  42.     UpdateLayeredWindow(popUp.hwnd, popUp.hdc, popUp.x, popUp.y, popUp.w, popUp.h)
  43.  
  44. }
  45.  
  46. return
  47.  
  48.  
  49.  
  50.  
  51.  
  52. class Kunai {
  53. set(x3,y3,vx,vy,scale,phase){
  54.     Map:=Gdip_CreateBitmapFromFile("kunai.png")
  55.     map:=GDIP_SCALE(Map,1/SCALE)
  56.     This.map := map
  57.     this.maps()
  58.     This.x3 := x3
  59.     This.y3 := y3
  60.     this.phase:=phase
  61.    
  62.     This.vx := vx
  63.     This.vy := vy
  64.     w:=this.setOFmaps.w[this.phase]
  65.     h:=this.setOFmaps.h[this.phase]
  66.    
  67.     This.x1 := x3 - w/2
  68.     This.y1 := y3 - h/2
  69.     This.x2 := x3 + w/2
  70.     This.y2 := y3 + h/2
  71.    
  72.  
  73.  
  74.    
  75.  
  76. }
  77. changephase(){
  78.     phase:=mod(this.phase + 2,36)
  79.     if(phase = 0)
  80.         phase := 1
  81.     this.phase:=phase
  82.    
  83. }
  84. move(){
  85.     This.x3 += this.vx
  86.     This.y3 += this.vy
  87.     this.changephase()
  88.     w:=this.setOFmaps.w[this.phase]
  89.     h:=this.setOFmaps.h[this.phase]
  90.     This.x1 := This.x3 - w/2
  91.     This.y1 := This.y3 - h/2
  92.     This.x2 := This.x3 + w/2
  93.     This.y2 := This.y3 + h/2
  94. }
  95. maps(){
  96.     a:=[],b:=[],c:=[]
  97.     this.setOFmaps:={w:a,h:b,map:c}
  98.      loop 36 {
  99.     map0:=this.map
  100.     i:=A_Index - 1
  101.     angle := i*10
  102.     turn_bitmap(map0,angle)
  103.     this.setOFmaps.map.insert(map0)
  104.     Gdip_GetImageDimensions(map0,  w,  h)
  105.     this.setOFmaps.w.insert(w)
  106.     this.setOFmaps.h.insert(h)
  107.    
  108.     }
  109. }
  110. draw(g){
  111.     phase:=this.phase
  112.     w:=this.setOFmaps.w[phase]
  113.     h:=this.setOFmaps.h[phase]
  114.     map:=this.setOFmaps.map[phase]
  115.  
  116.     Gdip_DrawImage(g, map, this.x3 - w/2,this.y3 - h/2, w, h,0,0,w,h)
  117. }
  118.  
  119.  
  120. }
  121. class Knives {
  122. set(scale,backg){
  123.     this.scale:=scale
  124.     This.x1 := backg.x1
  125.     This.x2 := backg.x2
  126.     This.y1 := backg.y1
  127.     This.y2 := backg.y2
  128.  
  129. }
  130. add(x3,y3,vx,vy,phase){
  131.     scale := This.scale
  132.  
  133.     if(this.array.length() = "" )
  134.         this.array:=[]
  135.     knife:= new Kunai
  136.     knife.set(x3,y3,vx,vy,scale,phase)
  137.    
  138.     this.Array.insert(knife)
  139.    
  140. }
  141.  
  142. move(){
  143.         for i,value in this.array {
  144.             value.move()
  145.         }
  146. }
  147.  
  148. delete(){
  149.     x1:=This.x1
  150.     x2:=This.x2
  151.     y1:=This.y1
  152.     y2:=This.y2
  153.    
  154.     for i,value in this.array {
  155.         x1k:=value.x1
  156.         x2k:=value.x2
  157.         y1k:=value.y1
  158.         y2k:=value.y2
  159.    
  160.             if(x1k < x1 or y1k < y1 or x2k > x2 or y2k > y2 )
  161.                 this.array.remove(i)
  162.         }
  163. }
  164. draw(g){
  165.     for i,value in this.array {
  166.             value.draw(g)
  167.         }
  168. }
  169. }
  170. class Back {
  171. set(){
  172.         back:=Gdip_CreateBitmapFromFile("back.png")
  173.         this.back:=back
  174.         Gdip_GetImageDimensions(back,  w,  h)
  175.    
  176.         this.w:=w
  177.         this.h:=h
  178.         delta:=14
  179.         This.x1 := delta
  180.         This.x2 := w - delta
  181.         This.y1 := delta
  182.         This.y2 := h - delta
  183.  
  184.    
  185. }
  186. draw(g){
  187.     Gdip_DrawImage(g, this.back, 0,0, this.w, this.h)
  188. }
  189.  
  190. }
  191.  
  192.  
  193. x::
  194. Layered_Window_ShutDown(popUp)
  195. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement