I Wanna Community
Fangames => Game Design => Programming Questions => Topic started by: PikachuLPer on July 14, 2016, 06:13:06 PM
-
How do i make like spikes when i jump it comes out the floor and if i jump again it goes back to the floor like in boshy?
Thanks
-
So, being the logical but not entirely efficient coder I am, I compiled this little sinewave-based object according to what I assumed your demand is (jump-enabled in and out spikes). The code is here: (pre-hotfix please look down) https://pastebin.com/8v18zg58 (https://pastebin.com/8v18zg58)
The downfall as far as I can tell is that it doesn't properly transition if you jump fast enough, but it should never "break" or throw an error by any means. I'll get working on a better version, though. Tell me how you like the one I showed.
Edit: If they aren't going in and out fast enough to your liking, go to the sineAngle code and change the "+4" to a higher number, preferably between 10 and 15.
EditEdit: If you're using studio, there's gonna be some variable-related errors. If that happens, put in the Create Event as follows:
transitioning=0;
way=0;
sineAngle=0;
And that should be it..?
EditEditEditings!!!EditSuperEditVersionCyberHitBoxEdition:
I suppose I really should get better at actually thinking about what my stuff does. Okay, so set "way=1" in the creation CODE of spikes that are on the second wave of jumping, and copy THIS hotfix code instead: https://pastebin.com/a0LmTW3q (https://pastebin.com/a0LmTW3q)
-
there is a problem with that script
___________________________________________
FATAL ERROR in
action number 1
of Create Event
for object spikeDownMove:
COMPILATION ERROR in code action
Error in code at line 9:
x=lerp(sX,tX,1);
^
at position 8: Unknown function or script: lerp
-
Shite! I always forget that people don't have the lerp function for some reason. I wonder why.
Anyways, just make a script called "lerp" I suppose, and put this in it:
return (argument0+(argument1*argument2)-(argument0*argument2));
-
Im trying that for spike down but if i jump it goes to the left? and then back if i hold the jump button its just moving left and back without stopping if i let the button go it stops.
-
Holy mother of typos I think I'm about to give myself an aneurysm looking at some of the typos and missed parts of code.
First, use this create event instead for spikes:
Downward spikes:
tY=y-32;
tX=x;
Upward spikes:
tY=y+32;
tX=x;
Leftward spikes:
tY=y;
tX=x+32;
Rightward spikes:
tY=y;
tX=x-32
Next up, to fix the held-down thing, change the keyboard_check_direct to keyboard_check_pressed. I am actually not sure how it works out, though. You see why all these errors come up because I don't actually test code which I write for other people ;;
-
Thanks now its works :atkHappy: