Question and help: Angles, Bitmap and Player Position

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

Victor ManuelMR M
Topic author, Count
Count
Avatar
Victor ManuelMR M
Topic author, Count
Count
Age: 21
Reputation: 155
Posts: 241
Joined: 7 Feb 2018

Post #1by Victor ManuelMR » 15 Jun 2020, 0:34

Well, I'm working with bitmap, but I don't have much idea of how it works exactly.
For example: I'm making a Bullet Bill Launcher that changes angles, depending on the player's position.
Bitmap Help.png

Bitmap(1).rotatang is very confusing, (even if its function is already rotating) I don't know how I could use it to change angles depending on the player's location (x, y)...
npc-233.png
npc-233.png (690 Bytes) Viewed 1030 times
Last edited by Victor ManuelMR on 21 Oct 2020, 19:55, edited 2 times in total.
Image
[1.4.5] - Dream Team at The Challenging Portals:
Image

HugoMDM M
Our friend
Our friend
Avatar
HugoMDM M
Our friend
Our friend
Age: 22
Reputation: 71
Posts: 79
Joined: 17 Apr 2016
YouTube Youtube channel URL

Post #2by HugoMDM » 16 Jun 2020, 1:30

Rotatang works on radians

Pi = 180 degress
Pi/2 = 90 degress
Pi*2 = 360 degress
I make good scripts for everyone c:
Scripting YT channel
https://www.youtube.com/channel/UChaWgDsfMCqJzeV0bmDs-Mw?view_as=subscriber

Victor ManuelMR M
Topic author, Count
Count
Avatar
Victor ManuelMR M
Topic author, Count
Count
Age: 21
Reputation: 155
Posts: 241
Joined: 7 Feb 2018

Post #3by Victor ManuelMR » 16 Jun 2020, 5:26

Spoiler
Victor ManuelMR wrote:Well, I'm working with bitmap, but I don't have much idea of how it works exactly.
For example: I'm making a Bullet Bill Launcher that changes angles, depending on the player's position.
Bitmap Help.png

Bitmap(1).rotatang is very confusing, (even if its function is already rotating) I don't know how I could use it to change angles depending on the player's location (x, y)...
npc-233.png

Find a way (Thanks to Monad): and everyone who helped in the post

Code: Select all

bitmap(1).rotatang = angle(.x - char(1).x, char(1).y - .y) + pi/2


IN DEGREES by SetaYoshi

Code: Select all

script angle(width as double, height as double, return double)
 return 2*pi*getangle(param(width), param(height))
Image
[1.4.5] - Dream Team at The Challenging Portals:
Image

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

Post #4by Monad » 20 Jun 2020, 2:12

Actually the mathematically accurate way to do this is the following:

Code: Select all

do

with bitmap(1)
   .rotatang = atan2(.desty + 0.5 * .scrheight - (char(1).y + 0.5 * char(1).pheight), .destx + 0.5 * .scrwidth - (char(1).x + 0.5 * char(1).pwidth))
end with

call sleep(1)
loop

script atan2(y as double, x as double, return double)
   return 2 * pi * getangle(y, x)
end

Note that in the example I'm using a bitmap, so you if use an NPC instead you will have to do some adaptations, but the logic keeps the same.


Return to “TeaScript”

Who is online (over the past 5 minutes)

Users browsing this forum: 1 guest