Log In  

Cart #yoduzefuze-0 | 2022-12-25 | Code ▽ | Embed ▽ | No License


I need help with how I want the player to move. I want the movement of the game to be mouse based, i.e I want the player to jump up left when moving cursor to the left of the slime and jump up right when mouse is to the right of the slime. How would I be able to achive this? I've tried to test something if it'll work, and it didn't.
What I tried was
if stat(34)==1 and (on_ground or jump<2) and SX==8 and sy==8 and mouse.x<x then
on_ground=false
jump+=1
dy=dy-1
sfx(0)
end
This doesn't work since whenever the X cord for the mouse is less then the slime X, or x, it still jumps. Is there something I'm not thinking of that could work?

P#122970 2022-12-25 00:21 ( Edited 2022-12-25 00:22)

1

Very simply, @Dawnoboo, you want to calculate the distance the mouse has traveled between two tightly timed points. If in fact the button is released, that becomes the speed, direction, and inertia of the object released.

P#122975 2022-12-25 00:54

Would I make that calculation with Sin() or Cos() @dw817

P#122978 2022-12-25 02:24

@Dawnoboo the x velocity would be cos() of the direction and the y velocity would be sin() of the direction

P#122979 2022-12-25 02:30

Well it could be cos() or sin(), @ooooggll. Yet that is not required.

A simple coefficient with gravity would work.

I'm headed to midnight mass right now but if no-one writes any code to demonstrate this principle I will do so on Christmas Day.

And - Happy Holidays everyone ! 🎄

P#122980 2022-12-25 02:50

Thank you so much, I'll make sure to check it out tomorrow, happy holidays to you as well!!!

P#122983 2022-12-25 03:46

Good afternoon and Merry Christmas, @Dawnoboo.

You will find your heavily documented code to do just this HERE:

https://www.lexaloffle.com/bbs/?tid=50827

P#123017 2022-12-25 18:07

Thank you so much!!! This really helps with the movement, happy holidays!

P#123020 2022-12-25 19:39

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-20 01:01:03 | 0.102s | Q:23