Advertisement
pastamaker

knight 1

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