Advertisement
pastamaker

robot

Jun 15th, 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,600,600,1,"+alwaysontop")
  11. ;~ gui,1: show,,gui1
  12.  
  13. types:=["idle","slide"]
  14.  
  15. slide:=[]
  16.  
  17.  
  18.  
  19.  
  20. n:=10
  21.  
  22. scale:=0.33
  23.  
  24. photos := new Asset
  25.  
  26. photos.set(types,n,scale)
  27.  
  28. Alex := new Ninja
  29.  
  30. alex.set(0,0,0,100,1,1,1,photos)
  31.  
  32. loop  {
  33.     ;~ if(getkeystate("1"))
  34.         ;~ alex.look:=1
  35.     ;~ if(getkeystate("2"))
  36.         ;~ alex.look:=2
  37.    
  38.     index:=mod(a_index,types.length())
  39.     if(index=0)
  40.         index:=types.length()
  41.    
  42.    
  43.    
  44.  
  45.  
  46.  
  47.     loop 10 {
  48.        
  49.     Sleep 1000/24
  50.    
  51.     alex.phase:=A_Index
  52.     alex.setv()
  53.     alex.setxy()
  54.  
  55.     alex.setlook()
  56.     alex.settype()
  57.     alex.setmap()
  58.    
  59.     alex.stop()
  60.     Gdip_GraphicsClear(popUp.g)
  61.     fill_boxX(popup.g,"000000",0,0,popup.w,popup.h)
  62.     ;~ map:=photos.asset[look][type][phase]
  63.    
  64.     ;~ ToolTip,% map
  65.     ;~ Gdip_GetImageDimensions(map,  w,  h)
  66.  
  67.     ;~ Gdip_DrawImage(popup.g, map, 0,0,w, h)
  68.    
  69.     alex.draw(popUp.g)
  70.    
  71.     UpdateLayeredWindow(popUp.hwnd, popUp.hdc, popUp.x, popUp.y, popUp.w, popUp.h)
  72.     }
  73. }
  74.  
  75.  
  76. return
  77.  
  78.  
  79. 1::
  80. return
  81. 2::
  82. return
  83.  
  84.  
  85.  
  86.  
  87. class Ninja {
  88.    
  89.     set(x,y,g,hight,look,type,phase,asset){
  90.        
  91.         this.asset:=asset
  92.         this.x:=x
  93.         this.y:=y
  94.         this.vx:=0
  95.         this.vy:=0
  96.         this.g:=g
  97.         this.hight:=hight
  98.         this.look:=look
  99.         this.type:=type
  100.         this.phase:=phase
  101.         this.setmap()
  102.        
  103.     }
  104.     setVx(){
  105.         vx:=5
  106.         if(getkeystate("a"))
  107.             this.vx:=-vx
  108.         if(getkeystate("d"))
  109.             this.vx:=vx
  110.     }
  111.         setVy(){
  112.         vy:=5
  113.         if(getkeystate("w"))
  114.             this.vy:=-vy
  115.         if(getkeystate("s"))
  116.             this.vy:=vy
  117.     }
  118.     setv(){
  119.         this.setvx()
  120.         this.setvy()
  121.     }
  122.     stopX(){
  123.         this.vx:=0
  124.     }
  125.     stopY(){
  126.         this.vy:=0
  127.     }
  128.     stop(){
  129.         this.stopx()
  130.         this.stopy()
  131.     }
  132.     gVY(){
  133.         this.vy+=this.g
  134.     }
  135.     setX(){
  136.         this.x+=this.vx
  137.     }
  138.     sety(){
  139.         this.y+=this.vy
  140.     }
  141.     setxy(){
  142.         this.setx()
  143.         this.sety()
  144.    
  145.     }
  146.     setMap(){
  147.         look:=this.look
  148.         asset:=this.asset
  149.         type:=this.type
  150.         phase:=this.phase
  151.         this.map:=asset.asset[look][type][phase]
  152.    
  153.         Gdip_GetImageDimensions(this.map,  w,  h)
  154.         this.w:=w
  155.         this.h:=h
  156.     }
  157.     setlook(){
  158.         if(this.vx > 0)
  159.             this.look := 1
  160.         if(this.vx < 0)
  161.             this.look := 2
  162.     }
  163.     SETTYPE(){
  164.        
  165.         IF(this.vx <> 0  && this.vy=0)
  166.             this.type:= 2
  167.         IF(this.vx = 0 && this.vy=0)
  168.             this.type:= 1
  169.  
  170.     }
  171.     draw(g){
  172.         Gdip_DrawImage(g, this.map, THIS.X,this.y, this.w, this.h)
  173.        
  174.     }
  175.    
  176. }
  177.  
  178. class Asset {
  179.  
  180.     set(types,n,scale){
  181.         a1:=[],a2:=[]
  182.         b:=[a1,a2]
  183.         this.asset:=b
  184.         loop % types.MaxIndex() {
  185.             Array:=[]
  186.             fillArrayMap(Array , types[a_index],n, scale)
  187.             this.asset[1].Insert(Array)
  188.        
  189.             Array2:=[]
  190.             loop % n {
  191.                 Array2[A_Index]:=reverseMap(Array[A_Index])
  192.            
  193.             }
  194.            
  195.            
  196.             this.asset[2].Insert(Array2)
  197.         }
  198.    
  199.        
  200.     }
  201.  
  202. }
  203.  
  204.  
  205.  
  206.  
  207. reverseMap(map){
  208.     Gdip_GetImageDimensions(map,  w,  h)
  209.     newMap := Gdip_CreateBitmap(w, h)                      
  210.     g := Gdip_GraphicsFromImage(newMap)
  211.     Gdip_DrawImage(g, map, w,0, -w, h)
  212.     return newmap  
  213. }
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226. fillArrayPng(byref array,string,n){
  227.     loop % n {
  228.         i:=A_Index
  229.         tempStr=%string% (%i%).png
  230.         Array[A_Index]:=tempStr
  231.         ;~ ToolTip,% Array[A_Index]
  232.         ;~ Sleep 250
  233.  
  234.        
  235.     }
  236. }
  237.  
  238. fillArrayMap(byref Array, string,n, scale){
  239.    
  240.     fillArrayPng(array,string,n)
  241.     loop % n {
  242.         map:=Array[A_Index]
  243.         Map:=Gdip_CreateBitmapFromFile(map)
  244.         map:=GDIP_SCALE(Map,1/SCALE)
  245.         Array[A_Index]:=Map
  246.        
  247.     }
  248.  
  249.    
  250. }
  251. a::
  252. return
  253. s::
  254. return
  255. d::
  256. return
  257. w::
  258. return
  259. x::
  260. Layered_Window_ShutDown(popUp)
  261. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement