Advertisement
shad0wshayd3_

Pokemon Player Move

Mar 21st, 2014
2,818
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dim pose$(15) : WindowWidth = 600 : WindowHeight = 900 : up = 1 : roam = 1
  2. loadbmp "left_left", "Pokemon Sprites\Player\left_leftfoot.bmp"
  3. loadbmp "left_right", "Pokemon Sprites\Player\left_rightfoot.bmp"
  4. loadbmp "left_stop", "Pokemon Sprites\Player\left_stop.bmp"
  5. loadbmp "right_left", "Pokemon Sprites\Player\right_leftfoot.bmp"
  6. loadbmp "right_right", "Pokemon Sprites\Player\right_rightfoot.bmp"
  7. loadbmp "right_stop", "Pokemon Sprites\Player\right_stop.bmp"
  8. loadbmp "forward_left", "Pokemon Sprites\Player\forward_leftfoot.bmp"
  9. loadbmp "forward_right", "Pokemon Sprites\Player\forward_rightfoot.bmp"
  10. loadbmp "forward_stop", "Pokemon Sprites\Player\forward_stop.bmp"
  11. loadbmp "backward_left", "Pokemon Sprites\Player\backward_leftfoot.bmp"
  12. loadbmp "backward_right", "Pokemon Sprites\Player\backward_rightfoot.bmp"
  13. loadbmp "backward_stop", "Pokemon Sprites\Player\backward_stop.bmp"
  14.  
  15. open "Pokemon Player Walk" for graphics_nf_nsb as #pwalk
  16.   #pwalk, "trapclose [exit]" : #pwalk, "when characterInput [keypress]" : #pwalk, "setfocus"
  17.   #pwalk, "addsprite left_left left_left" : #pwalk, "addsprite forward_left forward_left"
  18.   #pwalk, "addsprite left_right left_right" : #pwalk, "addsprite forward_right forward_right"
  19.   #pwalk, "addsprite left_stop left_stop" : #pwalk, "addsprite forward_stop forward_stop"
  20.   #pwalk, "addsprite right_left right_left" : #pwalk, "addsprite backward_left backward_left"
  21.   #pwalk, "addsprite right_right right_right" : #pwalk, "addsprite backward_right backward_right"
  22.   #pwalk, "addsprite right_stop right_stop" : #pwalk, "addsprite backward_stop backward_stop"
  23.  
  24.   #pwalk, "spritescale left_left 150" : #pwalk, "spritescale forward_left 150"
  25.   #pwalk, "spritescale left_right 150" : #pwalk, "spritescale forward_right 150"
  26.   #pwalk, "spritescale left_stop 150" : #pwalk, "spritescale forward_stop 150"
  27.   #pwalk, "spritescale right_left 150" : #pwalk, "spritescale backward_left 150"
  28.   #pwalk, "spritescale right_right 150" : #pwalk, "spritescale backward_right 150"
  29.   #pwalk, "spritescale right_stop 150" : #pwalk, "spritescale backward_stop 150"
  30.  
  31.   #pwalk, "spritevisible left_left off" : #pwalk, "spritevisible forward_left off"
  32.   #pwalk, "spritevisible left_right off" : #pwalk, "spritevisible forward_right off"
  33.   #pwalk, "spritevisible left_stop off" : #pwalk, "spritevisible forward_stop off"
  34.   #pwalk, "spritevisible right_left off" : #pwalk, "spritevisible backward_left off"
  35.   #pwalk, "spritevisible right_right off" : #pwalk, "spritevisible backward_right off"
  36.   #pwalk, "spritevisible right_stop off" : #pwalk, "spritevisible backward_stop off"
  37.   timer 100, [move]
  38.   wait
  39.  
  40. 'the above code sets up all the player sprites for use
  41. 'loading them, scaling them, and hiding them.
  42.  
  43. 'the following code manages keypresses, which will be configurable in the future
  44.  
  45.   [keypress]
  46.     #pwalk, "\";Inkey$
  47.     select case Inkey$
  48.       case chr$(13) : goto [pSTART] 'enter
  49.  
  50.       case "e" : goto [pA]
  51.       case "E" : goto [pA]
  52.       case chr$(32) : goto [pB] 'space
  53.  
  54.       case "w" : goto [pUP]
  55.       case "W" : goto [pUP]
  56.       case "s" : goto [pDOWN]
  57.       case "S" : goto [pDOWN]
  58.       case "a" : goto [pLEFT]
  59.       case "A" : goto [pLEFT]
  60.       case "d" : goto [pRIGHT]
  61.       case "D" : goto [pRIGHT]
  62.  
  63.       case chr$(8) : goto [pSELECT] 'backspace
  64.  
  65.       case else : wait
  66.     end select : wait
  67.  
  68. 'the next few bits look at factors in game, and tell the program
  69. 'where to go from here, if reading the dex it makes the buttons conform to
  70. 'those commands, if in battle, roaming the world, or in a menu/shop
  71.  
  72.   [pSTART]
  73.     if start = 1 then goto [startgame_menu]
  74.     if menuopen = 1 then goto [menuclose]
  75.     if conver = 1 then goto [nothing]
  76.     if dexread = 1 then goto [nothing]
  77.     if shop = 1 then goto [nothing]
  78.     if shopbuy = 1 then goto [nothing]
  79.     if battle = 1 then goto [nothing]
  80.     if dexuse = 1 then goto [dexsearch]
  81.     if roam = 1 then goto [menuopen]
  82.     open "pkmn_error.txt" for append as #1
  83.       print #1, time$("ms");": unhandled start press"
  84.     close #1
  85.     wait
  86.  
  87.   [pA]
  88.     if start = 1 then goto [startgame_menu]
  89.     if menuopen = 1 then goto [menu_a]
  90.     if conver = 1 then goto [conver_a]
  91.     if dexread = 1 then goto [nextpage_dexread]
  92.     if shop = 1 then goto [buy]
  93.     if shopbuy = 1 then goto [buyfinal]
  94.     if battle = 1 then goto [battle_a]
  95.     if dexuse = 1 then goto [dex_a]
  96.     if roam = 1 then goto [itemup]
  97.     open "pkmn_error.txt" for append as #1
  98.       print #1, time$("ms");": unhandled a press"
  99.     close #1
  100.     wait
  101.  
  102.   [pB]
  103.     if start = 1 then goto [nothing]
  104.     if menuopen = 1 then goto [menu_b]
  105.     if conver = 1 then goto [conver_b]
  106.     if dexread = 1 then goto [dexback]
  107.     if shop = 1 then goto [shopback]
  108.     if shopbuy = 1 then goto [shopbackfinal]
  109.     if battle = 1 then goto [battle_a]
  110.     if dexuse = 1 then goto [dex_b]
  111.     if roam = 1 then goto [nothing]
  112.     open "pkmn_error.txt" for append as #1
  113.       print #1, time$("ms");": unhandled b press"
  114.     close #1
  115.     wait
  116.  
  117.   [pUP]
  118.     if start = 1 then goto [nothing]
  119.     if menuopen = 1 then goto [menu_up]
  120.     if conver = 1 then goto [nothing]
  121.     if dexread = 1 then goto [dexpageup]
  122.     if shop = 1 then goto [shop_up]
  123.     if shopbuy = 1 then goto [nothing]
  124.     if battle = 1 then goto [battle_up]
  125.     if dexuse = 1 then goto [dex_up]
  126.     if roam = 1 then moveflag = 1 : wait
  127.  
  128.     open "pkmn_error.txt" for append as #1
  129.       print #1, time$("ms");": unhandled up press"
  130.     close #1
  131.     wait
  132.  
  133.   [pDOWN]
  134.     if start = 1 then goto [nothing]
  135.     if menuopen = 1 then goto [menu_down]
  136.     if conver = 1 then goto [nothing]
  137.     if dexread = 1 then goto [dexpagedown]
  138.     if shop = 1 then goto [shop_down]
  139.     if shopbuy = 1 then goto [nothing]
  140.     if battle = 1 then goto [battle_down]
  141.     if dexuse = 1 then goto [dex_down]
  142.     if roam = 1 then moveflag = 2 : wait
  143.  
  144.     open "pkmn_error.txt" for append as #1
  145.       print #1, time$("ms");": unhandled down press"
  146.     close #1
  147.     wait
  148.  
  149.   [pLEFT]
  150.     if start = 1 then goto [nothing]
  151.     if menuopen = 1 then goto [nothing]
  152.     if conver = 1 then goto [nothing]
  153.     if dexread = 1 then goto [nothing]
  154.     if shop = 1 then goto [nothing]
  155.     if shopbuy = 1 then goto [buy_dec]
  156.     if battle = 1 then goto [battle_left]
  157.     if dexuse = 1 then goto [nothing]
  158.     if roam = 1 then moveflag = 3 : wait
  159.  
  160.     open "pkmn_error.txt" for append as #1
  161.       print #1, time$("ms");": unhandled left press"
  162.     close #1
  163.     wait
  164.  
  165.   [pRIGHT]
  166.     if start = 1 then goto [nothing]
  167.     if menuopen = 1 then goto [nothing]
  168.     if conver = 1 then goto [nothing]
  169.     if dexread = 1 then goto [nothing]
  170.     if shop = 1 then goto [nothing]
  171.     if shopbuy = 1 then goto [buy_inc]
  172.     if battle = 1 then goto [battle_right]
  173.     if dexuse = 1 then goto [nothing]
  174.     if roam = 1 then moveflag = 4 : wait
  175.  
  176.     open "pkmn_error.txt" for append as #1
  177.       print #1, time$("ms");": unhandled right press"
  178.     close #1
  179.     wait
  180.  
  181. 'the program uses a simple uncontrolled keypress system, so if I'm missing something, it'll write to file
  182.  
  183.   [nothing]
  184.     wait
  185.  
  186.  
  187.  
  188.  
  189.  
  190.   [move]
  191.     if moveflag = 0 then wait
  192.     if moveflag = 1 then
  193.       if lastmove = 1 then #pwalk, "spritexy? forward_stop x y"
  194.       if lastmove = 2 then #pwalk, "spritexy? backward_stop x y"
  195.       if lastmove = 3 then #pwalk, "spritexy? left_stop x y"
  196.       if lastmove = 4 then #pwalk, "spritexy? right_stop x y"
  197.       #pwalk, "spritevisible backward_stop off"
  198.       #pwalk, "spritevisible left_stop off"
  199.       #pwalk, "spritevisible right_stop off"
  200.       #pwalk, "spritexy forward_left ";x;" ";y-(9)
  201.       #pwalk, "spritexy forward_right ";x;" ";y-(18)
  202.       #pwalk, "spritexy forward_stop ";x;" ";y-(28)
  203.       time = time$("ms")
  204.       [up_left4]
  205.         time2 = time$("ms")
  206.         if time2-time < 80 then goto [up_left4]
  207.         #pwalk, "spritevisible forward_stop off"
  208.         #pwalk, "spritevisible forward_left on"
  209.         #pwalk, "drawsprites"
  210.         time = time$("ms")
  211.         [up_right4]
  212.           time2 = time$("ms")
  213.           if time2-time < 80 then goto [up_right4]
  214.           #pwalk, "spritevisible forward_left off"
  215.           #pwalk, "spritevisible forward_right on"
  216.           #pwalk, "drawsprites"
  217.           time = time$("ms")
  218.           [up_stop4]
  219.             time2 = time$("ms")
  220.             if time2-time < 80 then goto [up_stop4]
  221.             #pwalk, "spritevisible forward_right off"
  222.             #pwalk, "spritevisible forward_stop on"
  223.             #pwalk, "drawsprites"
  224.             moveflag = 0 : lastmove = 1
  225.             wait
  226.     end if
  227.  
  228.     if moveflag = 2 then
  229.       if lastmove = 1 then #pwalk, "spritexy? forward_stop x y"
  230.       if lastmove = 2 then #pwalk, "spritexy? backward_stop x y"
  231.       if lastmove = 3 then #pwalk, "spritexy? left_stop x y"
  232.       if lastmove = 4 then #pwalk, "spritexy? right_stop x y"
  233.       #pwalk, "spritevisible left_stop off"
  234.       #pwalk, "spritevisible forward_stop off"
  235.       #pwalk, "spritevisible right_stop off"
  236.       #pwalk, "spritexy backward_left ";x;" ";y+9
  237.       #pwalk, "spritexy backward_right ";x;" ";y+18
  238.       #pwalk, "spritexy backward_stop ";x;" ";y+28
  239.       time = time$("ms")
  240.       [uptimer_left4]
  241.         time2 = time$("ms")
  242.         if time2-time < 80 then goto [uptimer_left4]
  243.         #pwalk, "spritevisible backward_stop off"
  244.         #pwalk, "spritevisible backward_left on"
  245.         #pwalk, "drawsprites"
  246.         time = time$("ms")
  247.         [uptimer_right4]
  248.           time2 = time$("ms")
  249.           if time2-time < 80 then goto [uptimer_right4]
  250.           #pwalk, "spritevisible backward_left off"
  251.           #pwalk, "spritevisible backward_right on"
  252.           #pwalk, "drawsprites"
  253.           time = time$("ms")
  254.           [uptimer_stop4]
  255.             time2 = time$("ms")
  256.             if time2-time < 80 then goto [uptimer_stop4]
  257.             #pwalk, "spritevisible backward_right off"
  258.             #pwalk, "spritevisible backward_stop on"
  259.             #pwalk, "drawsprites"
  260.             moveflag = 0  : lastmove = 2
  261.             wait
  262.     end if
  263.  
  264.     if moveflag = 4 then
  265.       if lastmove = 1 then #pwalk, "spritexy? forward_stop x y"
  266.       if lastmove = 2 then #pwalk, "spritexy? backward_stop x y"
  267.       if lastmove = 3 then #pwalk, "spritexy? left_stop x y"
  268.       if lastmove = 4 then #pwalk, "spritexy? right_stop x y"
  269.       #pwalk, "spritevisible forward_stop off"
  270.       #pwalk, "spritevisible backward_stop off"
  271.       #pwalk, "spritevisible left_stop off"
  272.       #pwalk, "spritexy right_left ";x+8;" ";y
  273.       #pwalk, "spritexy right_right ";x+16;" ";y
  274.       #pwalk, "spritexy right_stop ";x+25;" ";y
  275.       time = time$("ms")
  276.       [right_left4]
  277.         time2 = time$("ms")
  278.         if time2-time < 80 then goto [right_left4]
  279.         #pwalk, "spritevisible right_stop off"
  280.         #pwalk, "spritevisible right_left on"
  281.         #pwalk, "drawsprites"
  282.         time = time$("ms")
  283.         [right_right4]
  284.           time2 = time$("ms")
  285.           if time2-time < 80 then goto [right_right4]
  286.           #pwalk, "spritevisible right_left off"
  287.           #pwalk, "spritevisible right_right on"
  288.           #pwalk, "drawsprites"
  289.           time = time$("ms")
  290.           [right_stop4]
  291.             time2 = time$("ms")
  292.             if time2-time < 80 then goto [right_stop4]
  293.             #pwalk, "spritevisible right_right off"
  294.             #pwalk, "spritevisible right_stop on"
  295.             #pwalk, "drawsprites"
  296.             moveflag = 0 : lastmove = 4
  297.             wait
  298.     end if
  299.  
  300.     if moveflag = 3 then
  301.       if lastmove = 1 then #pwalk, "spritexy? forward_stop x y"
  302.       if lastmove = 2 then #pwalk, "spritexy? backward_stop x y"
  303.       if lastmove = 3 then #pwalk, "spritexy? left_stop x y"
  304.       if lastmove = 4 then #pwalk, "spritexy? right_stop x y"
  305.       #pwalk, "spritevisible forward_stop off"
  306.       #pwalk, "spritevisible backward_stop off"
  307.       #pwalk, "spritevisible right_stop off"
  308.       #pwalk, "spritexy left_left ";x-(8);" ";y
  309.       #pwalk, "spritexy left_right ";x-(16);" ";y
  310.       #pwalk, "spritexy left_stop ";x-(25);" ";y
  311.       time = time$("ms")
  312.       [left_left4]
  313.         time2 = time$("ms")
  314.         if time2-time < 80 then goto [left_left4]
  315.         #pwalk, "spritevisible left_stop off"
  316.         #pwalk, "spritevisible left_left on"
  317.         #pwalk, "drawsprites"
  318.         time = time$("ms")
  319.         [left_right4]
  320.           time2 = time$("ms")
  321.           if time2-time < 80 then goto [left_right4]
  322.           #pwalk, "spritevisible left_left off"
  323.           #pwalk, "spritevisible left_right on"
  324.           #pwalk, "drawsprites"
  325.           time = time$("ms")
  326.           [left_stop4]
  327.             time2 = time$("ms")
  328.             if time2-time < 80 then goto [left_stop4]
  329.             #pwalk, "spritevisible left_right off"
  330.             #pwalk, "spritevisible left_stop on"
  331.             #pwalk, "drawsprites"
  332.             moveflag = 0 : lastmove = 3
  333.             wait
  334.     end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement