As per my last blog post, I was trying to refresh my skills. I was partially following the old Matharoo tutorial and the Peyton Burnham rpg tutorial, when I kept running into walls.
It's been hours and I've gone nowhere!
All the code I had written in my TXT file was trash. Literally none of it worked even though it was a near 1 to 1 copy of the tutorial with some names adjusted for clarity. (moveSpeed instead of move_speed) I thought I understood the math, so adjusting some names and cross referencing both of the tutorials should've worked.
NOPE, nothing. It wouldn't even take the inputs. It was like it had no code.
So I recreated each of the old tutorials band for band and I still get nowhere. With my limited knowledge, the only way I could make that work was by copying the 8-way movement from the GML manual. It seemed like it was working, and I was happy even if it was a little stretched out. I tinkered around with the x and y values for speed and thought I was doing alright.
Now I'm trying to avoid using too many variables because I assumed that's where the problem was. I move onto collision, and I cannot get the math to function without custom variables. What the manual gave me was a giant If, Else monster, but it worked and was easy to read. Easy to read doesn't equal easy to work with, and I learned this the hard way when I had to scrap my previous work because I couldn't work around it.
The modified manual code was something like this, but without the "moveSpeed".
//controls and movement speedif keyboard_check(vk_left) or keyboard_check(ord("A")){x += - 1 - moveSpeed;}if keyboard_check(vk_right) or keyboard_check(ord("D")){x += + 1 + moveSpeed;}if keyboard_check(vk_up) or keyboard_check(ord("W")){y += - 1 - moveSpeed;}if keyboard_check(vk_down) or keyboard_check(ord("S")){y += + 1 + moveSpeed;}if keyboard_check(vk_shift){moveSpeed = moveSpeed * 1.1;}
I had added the movespeed thing on (with the variable defined as 1) so I could add in that last Shift to Sprint thing in. Trying to do that was a huge headache too because I had to keep tweaking the math equations so that the player wouldn't fly off screen at mach Jesus. Almost none of this mattered, because it all had to go anyways.