Question and help: Moving Projectile in terms of Speed and Angle (cos and sin)

Description: Internal scripting system of SMBX-38A Engine based on the simple VB-like language
Moderators: Lx Xzit, Yoshi021, 5438A38A, Semi-moderatos, Moderators

HumanReploidJP M
Topic author, Good citizen
Good citizen
Avatar
HumanReploidJP M
Topic author, Good citizen
Good citizen
Age: 23
Reputation: 9
Posts: 30
Joined: 10 Nov 2016
Location: Ponzu Marine Honshou
Website

Post #1by HumanReploidJP » 26 Mar 2020, 18:43

So I've seen the rotating flamethrower since 1.4.1 until it's not included in 1.4.5. That got me thinking if I want to make a projectile that moves at a constant speed and angle.

Spoiler
15852375222998134759906682818726.jpg
This is the concept of cos and sin angle and constant speed. I'm waiting for results based.

I've seen the logic about the sin and cos, in terms of degree angle. So technically like the bouncing podoboo, or the projectile that was shot from a magikoopa from SMW.

So, I would need some help for your coding example, if you must. Let me know,and respond to this reply :to_keep_order: . Thank you.
Hi! I'm back in case some non-SMBX YouTubers are on impact. I'm back to experimenting with TeaScript scripts, yo!

Current Project:
- Super Mario: Star Sighting Paradisland
Next Project (Soon):
- Super Mario: Star Sighting Paradisland Mania

Monad
Passerby
Passerby
Monad
Passerby
Passerby
Reputation: 2
Posts: 2
Joined: 26 Apr 2020

Post #2by Monad » 6 May 2020, 3:57

You can do it by very simple trigonometry

Code: Select all

dim angle as double
dim speed as double

with npc(sysval(param1))
   .xsp = cos(angle) * speed
   .ysp = -sin(angle) * speed


That way you can control an NPC not by two coordinates (cartesian plane) but by its angle and speed, which are respectively equivalent the angle and distance from the center in a polar coordinate system.


Return to “TeaScript”

Who is online (over the past 5 minutes)

Users browsing this forum: 1 guest