Author Topic: Little Spike Thing question  (Read 1832 times)

PikachuLPer

  • Wannabe
  • Posts: 18
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 51.0.2704.106 Chrome 51.0.2704.106
    • View Profile
  • Playstyle: Keyboard
Little Spike Thing question
« 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

i like games

lawatson

  • The Kid
  • Posts: 331
  • I do things and I make things.
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 51.0.2704.103 Chrome 51.0.2704.103
    • View Profile
  • Playstyle: Keyboard
Re: Little Spike Thing question
« Reply #1 on: July 14, 2016, 09:01:19 PM »
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

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
« Last Edit: July 14, 2016, 09:11:50 PM by lawatson »
(click to show/hide)

smoke weed everyday

PikachuLPer

  • Wannabe
  • Posts: 18
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 51.0.2704.106 Chrome 51.0.2704.106
    • View Profile
  • Playstyle: Keyboard
Re: Little Spike Thing question
« Reply #2 on: July 15, 2016, 09:39:38 AM »
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

i like games

lawatson

  • The Kid
  • Posts: 331
  • I do things and I make things.
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 51.0.2704.103 Chrome 51.0.2704.103
    • View Profile
  • Playstyle: Keyboard
Re: Little Spike Thing question
« Reply #3 on: July 15, 2016, 12:18:23 PM »
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));
(click to show/hide)

smoke weed everyday

PikachuLPer

  • Wannabe
  • Posts: 18
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 51.0.2704.106 Chrome 51.0.2704.106
    • View Profile
  • Playstyle: Keyboard
Re: Little Spike Thing question
« Reply #4 on: July 15, 2016, 12:41:28 PM »
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.

i like games

lawatson

  • The Kid
  • Posts: 331
  • I do things and I make things.
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 51.0.2704.103 Chrome 51.0.2704.103
    • View Profile
  • Playstyle: Keyboard
Re: Little Spike Thing question
« Reply #5 on: July 15, 2016, 02:13:44 PM »
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 ;;
(click to show/hide)

smoke weed everyday

PikachuLPer

  • Wannabe
  • Posts: 18
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 51.0.2704.106 Chrome 51.0.2704.106
    • View Profile
  • Playstyle: Keyboard
Re: Little Spike Thing question
« Reply #6 on: July 15, 2016, 02:24:02 PM »
Thanks now its works  :atkHappy:

i like games