Advertisement
pastamaker

alexninja 4

Jun 17th, 2018
100
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. ;~ gui,1: show,,gui1
  12.  
  13. types:=["Attack__","Climb_","Dead__","Glide_","Idle__","Jump__","Jump_Attack__","jump_Throw__","Run__","Slide__","Throw__"]
  14.  
  15. slide:=[]
  16.  
  17. backg:= new Back
  18. backg.set()
  19.  
  20.  
  21. n:=10
  22.  
  23. scale:=0.3
  24.  
  25. photos := new Asset
  26.  
  27. photos.set(types,n,scale)
  28.  
  29. Alex := new Ninja
  30.  
  31. alex.set(500,500,20,100,1,1,1,photos,backg)
  32.  
  33. highter:= new Ladder
  34. highter.set(500,20,scale)
  35.  
  36. swords := new Knives
  37.  
  38. swords.set(0.3,backg)
  39.  
  40. k:=2
  41. loop  {
  42.     ;~ if(getkeystate("1"))
  43.         ;~ alex.look:=1
  44.     ;~ if(getkeystate("2"))
  45.         ;~ alex.look:=2
  46.    
  47.  
  48.    
  49.    
  50.  
  51.  
  52.  
  53.     loop 10 {
  54.        
  55.     ;~ Sleep 1000/10
  56.         ;~ alex.setv()
  57.         ;~ alex.setlook()
  58.  
  59.     ;~ alex.setxy()
  60.     ;~ alex.border()
  61.     ;~ alex.settype()
  62.    
  63.     ;~ alex.setmap()
  64.  
  65.    
  66.     ;~ alex.stop()
  67.    
  68.         Sleep 1000/24
  69.  
  70.            
  71.         alex.setv()
  72.     alex.setlook()
  73.  
  74.     alex.setmap()
  75.         alex.setxy()
  76.     alex.border()
  77.     alex.settype()
  78.         if(getkeystate("q") and (alex.vx <> 0 or alex.vy <> 0)){
  79.             x1:=(alex.x1 + alex.x2) / 2
  80.                 y1:=(alex.y1 + alex.y2) / 2
  81.                 vx:=alex.vx*k
  82.                 vy:=alex.vy*k
  83.             swords.add(x1,y1,vx,vy,1)
  84.         }
  85.     alex.stop()
  86.    
  87.     Gdip_GraphicsClear(popUp.g)
  88.     ;~ fill_boxX(popup.g,"000000",0,0,popup.w,popup.h)
  89.     backg.draw(popup.g)
  90.     ;~ map:=photos.asset[look][type][phase]
  91.    
  92.     ;~ ToolTip,% map
  93.     ;~ Gdip_GetImageDimensions(map,  w,  h)
  94.  
  95.     ;~ Gdip_DrawImage(popup.g, map, 0,0,w, h)
  96.    
  97.     highter.draw(popup.g)
  98.     alex.draw(popUp.g)
  99.     swords.move()
  100.     swords.delete()
  101.     swords.draw(popup.g)
  102.     UpdateLayeredWindow(popUp.hwnd, popUp.hdc, popUp.x, popUp.y, popUp.w, popUp.h)
  103.     }
  104. }
  105.  
  106.  
  107. return
  108.  
  109.  
  110. 1::
  111. return
  112. 2::
  113. return
  114.  
  115.  
  116. q::
  117. return
  118.  
  119. class Ninja {
  120.    
  121.     set(x1,y1,g,hight,look,type,phase,asset,Backscene){
  122.        
  123.         this.asset:=asset
  124.         this.x1:=x1
  125.         this.y1:=y1
  126.         This.x2 := x2
  127.         This.y2 := y2
  128.  
  129.         this.vx:=0
  130.         this.vy:=0
  131.         this.g:=g
  132.         this.hight:=hight
  133.         this.look:=look
  134.         this.type:=type
  135.         this.phase:=phase
  136.         this.setmap()
  137.         this.Backscene:=Backscene
  138.     }
  139.     setVx(){
  140.         vx:=20
  141.         if(getkeystate("a"))
  142.             this.vx:=-vx
  143.         if(getkeystate("d"))
  144.             this.vx:=vx
  145.     }
  146.         setVy(){
  147.         vy:=75
  148.         pass:=false
  149.         if(this.vy = 0)
  150.             pass:=true
  151.         this.gVY()
  152.        
  153.         if(getkeystate("w") and pass){
  154.             this.vy:=-vy
  155.         }
  156.         if(getkeystate("s")){
  157.             this.vy:=vy
  158.         }
  159.     }
  160.     setv(){
  161.         this.setvx()
  162.         this.setvy()
  163.     }
  164.     stopX(){
  165.         this.vx:=0
  166.     }
  167.     stopY(){
  168.         this.vy:=0
  169.     }
  170.     stop(){
  171.         this.stopx()
  172.         ;~ this.stopy()
  173.     }
  174.     gVY(){
  175.         this.vy+=this.g
  176.     }
  177.     setX(){
  178.         if(this.look = 1){
  179.             this.x1+=this.vx
  180.             this.x2:=this.x1 + this.w
  181.         }
  182.         if(this.look = 2){
  183.             this.x2+=this.vx
  184.             this.x1:=this.x2 - this.w
  185.         }
  186.     }
  187.     sety(){
  188.        
  189.             this.y2+=this.vy
  190.             this.y1:=this.y2 - this.h
  191.     }
  192.     setxy(){
  193.         this.setx()
  194.         this.sety()
  195.    
  196.     }
  197.     setMap(){
  198.         look:=this.look
  199.         asset:=this.asset
  200.         type:=this.type
  201.         phase:=this.phase
  202.         this.map:=asset.asset[look][type][phase]
  203.    
  204.         Gdip_GetImageDimensions(this.map,  w,  h)
  205.         this.w:=w
  206.         this.h:=h
  207.     }
  208.     setlook(){
  209.         if(this.vx > 0)
  210.             this.look := 1
  211.  
  212.        
  213.         if(this.vx < 0)
  214.             this.look := 2
  215.            
  216.     }
  217.     border(){
  218.         if(this.x1 < this.Backscene.x1){
  219.             this.x1:=this.Backscene.x1
  220.             this.x2:=this.x1 + this.w
  221.             this.vx:=0
  222.         }
  223.         else if(this.x2 > this.Backscene.x2){
  224.             this.x2:=this.Backscene.x2
  225.             this.x1:=this.x2 - this.w
  226.             this.vx:=0
  227.         }
  228.         if(this.y1 < this.Backscene.y1){
  229.             this.y1:=this.Backscene.y1
  230.             this.y2:=this.y1 + this.h
  231.             this.vy:=0
  232.         }
  233.         else if(this.y2 > this.Backscene.y2){
  234.             this.y2:=this.Backscene.y2
  235.             this.y1:=this.y2 - this.h
  236.             this.vy:=0
  237.         }
  238.     }
  239.     SETTYPE(){
  240.        
  241.         IF(this.vy > 0){
  242.             ;~ SoundBeep
  243.             ;~ if(this.type <> 6 )
  244.                 ;~ this.phase:=1
  245.             ;~ else {
  246.                 ;~ if(this.phase < 9)
  247.                     ;~ this.phase++
  248.                
  249.             ;~ }
  250.            
  251.             this.type:= 6
  252.            
  253.                     if(this.type <> 6 )
  254.                 this.phase:=1
  255.             else {
  256.                 if(this.phase <> 9)
  257.                     this.phase+=1
  258.                
  259.             }
  260.         }
  261.        
  262.    
  263.         IF(this.vy < 0) {
  264.                 if(this.type <> 6 )
  265.                 this.phase:=1
  266.             else {
  267.                 if(this.phase <> 9)
  268.                     this.phase+=1
  269.                
  270.             }
  271.            
  272.             this.type:= 6
  273.         ;~ IF(this.vy = 0)
  274.             ;~ this.type:= 1
  275.         }
  276.         IF(this.vx <> 0  && this.vy=0) {
  277.             this.type:= 9
  278.             phase:= mod(this.phase + 1 ,10)
  279.             if(phase = 0)
  280.                 phase:=10
  281.             this.phase:=phase
  282.         }
  283.         IF(this.vx = 0 && this.vy=0) {
  284.             this.type:= 5
  285.             phase:= mod(this.phase + 1 ,10)
  286.             if(phase = 0)
  287.                 phase:=10
  288.             this.phase:=phase
  289.         }
  290.    
  291.  
  292.     }
  293.     draw(g){
  294.    
  295.             Gdip_DrawImage(g, this.map, THIS.X1,this.y1, this.w, this.h)
  296.        
  297.        
  298.     }
  299.    
  300. }
  301.  
  302.  
  303. class Asset {
  304.  
  305.     set(types,n,scale){
  306.         a1:=[],a2:=[]
  307.         b:=[a1,a2]
  308.         this.asset:=b
  309.         loop % types.MaxIndex() {
  310.             Array:=[]
  311.             fillArrayMap(Array , types[a_index],n, scale)
  312.             this.asset[1].Insert(Array)
  313.        
  314.             Array2:=[]
  315.             loop % n {
  316.                 Array2[A_Index]:=reverseMap(Array[A_Index])
  317.            
  318.             }
  319.            
  320.            
  321.             this.asset[2].Insert(Array2)
  322.         }
  323.    
  324.        
  325.     }
  326.  
  327. }
  328.  
  329.  
  330.  
  331.  
  332. reverseMap(map){
  333.     Gdip_GetImageDimensions(map,  w,  h)
  334.     newMap := Gdip_CreateBitmap(w, h)                      
  335.     g := Gdip_GraphicsFromImage(newMap)
  336.     Gdip_DrawImage(g, map, w,0, -w, h)
  337.     return newmap  
  338. }
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351. fillArrayPng(byref array,string,n){
  352.     loop % n {
  353.         i:=A_Index - 1
  354.         tempStr=%string%00%i%.png
  355.         Array[A_Index]:=tempStr
  356.         ;~ ToolTip,% Array[A_Index]
  357.         ;~ Sleep 250
  358.  
  359.        
  360.     }
  361. }
  362.  
  363. fillArrayMap(byref Array, string,n, scale){
  364.    
  365.     fillArrayPng(array,string,n)
  366.     loop % n {
  367.         map:=Array[A_Index]
  368.         Map:=Gdip_CreateBitmapFromFile(map)
  369.         map:=GDIP_SCALE(Map,1/SCALE)
  370.         Array[A_Index]:=Map
  371.        
  372.     }
  373.  
  374.    
  375. }
  376.  
  377.  
  378. class Back {
  379. set(){
  380.         back:=Gdip_CreateBitmapFromFile("back.png")
  381.         this.back:=back
  382.         Gdip_GetImageDimensions(back,  w,  h)
  383.    
  384.         this.w:=w
  385.         this.h:=h
  386.         delta:=14
  387.         This.x1 := delta
  388.         This.x2 := w - delta
  389.         This.y1 := delta
  390.         This.y2 := h - delta
  391.  
  392.    
  393. }
  394. draw(g){
  395.     Gdip_DrawImage(g, this.back, 0,0, this.w, this.h)
  396. }
  397.  
  398. }
  399. class Ladder {
  400.     set(x1,y1,scale){
  401.         map:=map:=Gdip_CreateBitmapFromFile("ladder.png")
  402.         map:=GDIP_SCALE(Map,1/SCALE)
  403.         This.map := map
  404.         Gdip_GetImageDimensions(MAP,  w,  h)
  405.         this.w:=w
  406.         this.h:=h
  407.         This.x1 := x1
  408.         This.x2 := x1  + w
  409.         This.y1 := y1
  410.         This.y2 := y1 + h
  411.  
  412.     }
  413.     draw(g){
  414.         h := This.h
  415.         w := This.w
  416.         map := This.map
  417.         x1 := This.x1
  418.         y1 := This.y1
  419.  
  420.         Gdip_DrawImage(g, map, x1, y1 ,w,h)
  421.     }
  422.     here(hero){
  423.        
  424.         if(   ){
  425.             SoundBeep
  426.             if(hero.look = 1){
  427.             HERO.X1:=THIS.X1
  428.             HERO.X2:=HERO.X1 + HERO.W
  429.             HERO.Y2:=THIS.Y2
  430.             HERO.Y1:=HERO.Y2 - HERO.H
  431.         }
  432.             else if(hero.look = 2){
  433.             HERO.X2:=THIS.X2
  434.             HERO.X1:=HERO.X2 - HERO.W
  435.             HERO.Y2:=THIS.Y2
  436.             HERO.Y1:=HERO.Y2 - HERO.H
  437.         }
  438.         }
  439.     }
  440. }
  441.  
  442.  
  443. class Kunai {
  444. set(x3,y3,vx,vy,scale,phase){
  445.     Map:=Gdip_CreateBitmapFromFile("kunai.png")
  446.     map:=GDIP_SCALE(Map,1/SCALE)
  447.     This.map := map
  448.     this.maps()
  449.     This.x3 := x3
  450.     This.y3 := y3
  451.     this.phase:=phase
  452.    
  453.     This.vx := vx
  454.     This.vy := vy
  455.     w:=this.setOFmaps.w[this.phase]
  456.     h:=this.setOFmaps.h[this.phase]
  457.    
  458.     This.x1 := x3 - w/2
  459.     This.y1 := y3 - h/2
  460.     This.x2 := x3 + w/2
  461.     This.y2 := y3 + h/2
  462.    
  463.  
  464.  
  465.    
  466.  
  467. }
  468. changephase(){
  469.     phase:=mod(this.phase + 2,36)
  470.     if(phase = 0)
  471.         phase := 1
  472.     this.phase:=phase
  473.    
  474. }
  475. move(){
  476.     This.x3 += this.vx
  477.     This.y3 += this.vy
  478.     this.changephase()
  479.     w:=this.setOFmaps.w[this.phase]
  480.     h:=this.setOFmaps.h[this.phase]
  481.     This.x1 := This.x3 - w/2
  482.     This.y1 := This.y3 - h/2
  483.     This.x2 := This.x3 + w/2
  484.     This.y2 := This.y3 + h/2
  485. }
  486. maps(){
  487.     a:=[],b:=[],c:=[]
  488.     this.setOFmaps:={w:a,h:b,map:c}
  489.      loop 36 {
  490.     map0:=this.map
  491.     i:=A_Index - 1
  492.     angle := i*10
  493.     turn_bitmap(map0,angle)
  494.     this.setOFmaps.map.insert(map0)
  495.     Gdip_GetImageDimensions(map0,  w,  h)
  496.     this.setOFmaps.w.insert(w)
  497.     this.setOFmaps.h.insert(h)
  498.    
  499.     }
  500. }
  501. draw(g){
  502.     phase:=this.phase
  503.     w:=this.setOFmaps.w[phase]
  504.     h:=this.setOFmaps.h[phase]
  505.     map:=this.setOFmaps.map[phase]
  506.  
  507.     Gdip_DrawImage(g, map, this.x3 - w/2,this.y3 - h/2, w, h,0,0,w,h)
  508. }
  509.  
  510.  
  511. }
  512. class Knives {
  513. set(scale,backg){
  514.     this.scale:=scale
  515.     This.x1 := backg.x1
  516.     This.x2 := backg.x2
  517.     This.y1 := backg.y1
  518.     This.y2 := backg.y2
  519.  
  520. }
  521. add(x3,y3,vx,vy,phase){
  522.     scale := This.scale
  523.  
  524.     if(this.array.length() = "" )
  525.         this.array:=[]
  526.     knife:= new Kunai
  527.     knife.set(x3,y3,vx,vy,scale,phase)
  528.    
  529.     this.Array.insert(knife)
  530.    
  531. }
  532.  
  533. move(){
  534.         for i,value in this.array {
  535.             value.move()
  536.         }
  537. }
  538.  
  539. delete(){
  540.     x1:=This.x1
  541.     x2:=This.x2
  542.     y1:=This.y1
  543.     y2:=This.y2
  544.    
  545.     for i,value in this.array {
  546.         x1k:=value.x1
  547.         x2k:=value.x2
  548.         y1k:=value.y1
  549.         y2k:=value.y2
  550.    
  551.             if(x1k < x1 or y1k < y1 or x2k > x2 or y2k > y2 )
  552.                 this.array.remove(i)
  553.         }
  554. }
  555. draw(g){
  556.     for i,value in this.array {
  557.             value.draw(g)
  558.         }
  559. }
  560. }
  561.  
  562.  
  563. a::
  564. return
  565. s::
  566. return
  567. d::
  568. return
  569. w::
  570. return
  571. x::
  572. Layered_Window_ShutDown(popUp)
  573. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement