This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-05-03 23:18:05

iCode-747
Scratcher
Registered: 2009-11-21
Posts: 1000+

I need help with a missile sprite location- I may need trig help...

I have a sprite. It looks like this:

http://lh5.ggpht.com/_mXv3HQnoqXY/S9-RpCgNxCI/AAAAAAAABz4/I_IBu3iqkKU/01.png

I want a missile to go and stay under one of the two 'MAIN CANNON' blocks. I don't know how to go about doing this... I've already tried several methods, but none work.

The missile:

http://lh3.ggpht.com/_mXv3HQnoqXY/S9-RpHMTASI/AAAAAAAABz0/zBw7_Tn3phc/asdsadadsasdadsdsadas.gif

I'm pretty sure that I'll need to use trig. That's why I put it under Advanced... Mods, move this to your discretion.

Please help!


-End Transmission-

Offline

 

#2 2010-05-04 00:12:59

iCode-747
Scratcher
Registered: 2009-11-21
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

bump!


-End Transmission-

Offline

 

#3 2010-05-04 02:02:47

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

One thing - excellent sprite!

About your problem:
    • Paddle2See's Trigonometry Cannon
    • archmage's Trig-less Cannon (has the same effect)

You can download the projects and study the scripts.  smile


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#4 2010-05-04 10:59:41

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

Well if they're homing missiles, or you just need the location, you could look here:
http://scratch.mit.edu/projects/juststickman/929222

(there are 3 pixels that have a set distance loop and then at the bottom of wafflebot's script you can see a formula)


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#5 2010-05-04 12:26:26

calebxy
Scratcher
Registered: 2009-12-31
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

You could try to use bezier cures.


I'm making my own Doctor Who series!  big_smile  See the first episode here.
And please join Story Zone!  big_smile

Offline

 

#6 2010-05-04 14:47:43

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

I would help, but personally I have no clue what you want to do... could you try to explain it again, please?


nXIII

Offline

 

#7 2010-05-04 16:55:55

iCode-747
Scratcher
Registered: 2009-11-21
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

nXIII wrote:

I would help, but personally I have no clue what you want to do... could you try to explain it again, please?

Sure.

This is a ship in my video game:

http://lh5.ggpht.com/_mXv3HQnoqXY/S9-RpCgNxCI/AAAAAAAABz4/I_IBu3iqkKU/01.png

Now, under each of the 'MAIN CANNONS' blocks I want there to be a missile.
The missile does fit under the block in Scratch:

http://lh3.ggpht.com/_mXv3HQnoqXY/S9-RpHMTASI/AAAAAAAABz0/zBw7_Tn3phc/asdsadadsasdadsdsadas.gif


Now, I want this missile to stay under the top cannon forever. I don't know how to do this.


The ship is constantly moving around... And turning... And the missile has to simply stay there, facing in the same direction.

Clear?


-End Transmission-

Offline

 

#8 2010-05-04 17:15:54

AddZero
Scratcher
Registered: 2007-08-11
Posts: 100+

Re: I need help with a missile sprite location- I may need trig help...

What do those MAIN CANNONS block do?

So the script you showed is for the ship, but you want another block to control the missiles?

So you want the cannon to turn with the ship.  if you want it always pointing up, just have it go in the same location of the ship.

still don't understand what you mean by stay under forever... below the ship on the screen, or under the ship, even if the ship is upside down. (in that case it would be above the ship, on the screen.)

Not sure what you're trying to do yet.

can you upload the project somewhere?


http://scratch.mit.edu/static/icons/buddy/524717_med.png?t=2010-06-15+09%3A48%3A36

Offline

 

#9 2010-05-04 17:25:58

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

iCode-747 wrote:

nXIII wrote:

I would help, but personally I have no clue what you want to do... could you try to explain it again, please?

Sure.

This is a ship in my video game:

http://lh5.ggpht.com/_mXv3HQnoqXY/S9-Rp … kKU/01.png

Now, under each of the 'MAIN CANNONS' blocks I want there to be a missile.
The missile does fit under the block in Scratch:

http://lh3.ggpht.com/_mXv3HQnoqXY/S9-Rp … dsadas.gif


Now, I want this missile to stay under the top cannon forever. I don't know how to do this.


The ship is constantly moving around... And turning... And the missile has to simply stay there, facing in the same direction.

Clear?

Oh, it's like a Scratch-block-space-shooter game, that's what I was missing. Yes, you do need trig for this. Please place your missile in the correct position relative to the ship and give me the coordinates of both; I will give you a mini-script for positioning it.


nXIII

Offline

 

#10 2010-05-04 17:39:01

iCode-747
Scratcher
Registered: 2009-11-21
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

Thanks so much!

I don't have time right now, I'll post it in the next 24 hours.


-End Transmission-

Offline

 

#11 2010-05-05 04:03:53

iCode-747
Scratcher
Registered: 2009-11-21
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

If the ship is at 0x0y, than the upper missile would be at -2x 16y. The lower missile would be at -2x -23y.

Can you give me equations for both?


-End Transmission-

Offline

 

#12 2010-05-05 16:24:00

iCode-747
Scratcher
Registered: 2009-11-21
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

Uh... Bump?


-End Transmission-

Offline

 

#13 2010-05-05 16:52:50

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

You don't really need trig.

Do this for the missiles.

go to ship
point in direction (ship direction-90) //plus 90 for the other one
move (10) steps //or however many steps
point in direction (ship direction)
//code for firing or whatever


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#14 2010-05-05 16:57:48

iCode-747
Scratcher
Registered: 2009-11-21
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

archmage wrote:

You don't really need trig.

Do this for the missiles.

go to ship
point in direction (ship direction-90) //plus 90 for the other one
move (10) steps //or however many steps
point in direction (ship direction)
//code for firing or whatever

I do.


The ship will be rotating and moving around at the same time, and the missile will be pushed around a lot. I already tried that, and it didn't work.


-End Transmission-

Offline

 

#15 2010-05-05 17:02:40

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

iCode-747 wrote:

If the ship is at 0x0y, than the upper missile would be at -2x 16y. The lower missile would be at -2x -23y.

Can you give me equations for both?

OK, then, let's bring out some trig...

(-2, 16)





  (0, 0)

So, the angle is -7.1250163489017975619533008412068 from 0, and the magnitude is... 16.124515496597099304733226460608, so the position of the first missile would be
x: ((16.124515496597099304733226460608) * sin((direction of ship) - (7.1250163489017975619533008412068))) y: ((16.124515496597099304733226460608) * cos((direction of ship) - (7.1250163489017975619533008412068)))
Try that and see if it works, if it does I'll do the other one.

Last edited by nXIII (2010-05-05 17:02:45)


nXIII

Offline

 

#16 2010-05-05 17:18:08

iCode-747
Scratcher
Registered: 2009-11-21
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

It didn't work. The missile was way off.

Sorry, but I can't get you a screenshot at this time.


-End Transmission-

Offline

 

#17 2010-05-05 17:33:01

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

iCode-747 wrote:

It didn't work. The missile was way off.

Sorry, but I can't get you a screenshot at this time.

I would love if I could get the project and just play around with it a bit.

Ugh, I keep getting distracted after getting the 60-second rule, posting something, then getting the 60-second rule again when I come back >.>

EDIT: OOOOOOOOOOOOOOOOOOOOOOOOOOOOHHHHHHHHH, I forgot the 'x position of ship' that you have to add to the x and y....

here it is: http://scratch.mit.edu/projects/nXIII/1030050

Last edited by nXIII (2010-05-05 18:03:02)


nXIII

Offline

 

#18 2010-05-06 03:38:20

calebxy
Scratcher
Registered: 2009-12-31
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

Try bezier cures. http://www.create-games.com/article.asp?id=1866


I'm making my own Doctor Who series!  big_smile  See the first episode here.
And please join Story Zone!  big_smile

Offline

 

#19 2010-05-06 13:27:56

Ratty1967UK
Scratcher
Registered: 2007-05-16
Posts: 88

Re: I need help with a missile sprite location- I may need trig help...

with a bit of careful positioning of your sprite costume centre points you could do the whole thing quite easily and leave scratch to do all the scary trigonometry for you!  smile

hopefully this little example will help you get there...
http://scratch.mit.edu/projects/Ratty1967UK/1031871

Last edited by Ratty1967UK (2010-05-06 13:28:21)

Offline

 

#20 2010-05-06 19:48:11

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

Ratty1967UK wrote:

with a bit of careful positioning of your sprite costume centre points you could do the whole thing quite easily and leave scratch to do all the scary trigonometry for you!  smile

hopefully this little example will help you get there...
http://scratch.mit.edu/projects/Ratty1967UK/1031871

1. Trig is awesomesauce, not scary.
2. I've already solved the problem two posts upward of this...


nXIII

Offline

 

#21 2010-05-06 20:39:37

Ratty1967UK
Scratcher
Registered: 2007-05-16
Posts: 88

Re: I need help with a missile sprite location- I may need trig help...

nXIII wrote:

Ratty1967UK wrote:

with a bit of careful positioning of your sprite costume centre points you could do the whole thing quite easily and leave scratch to do all the scary trigonometry for you!  smile

hopefully this little example will help you get there...
http://scratch.mit.edu/projects/Ratty1967UK/1031871

1. Trig is awesomesauce, not scary.
2. I've already solved the problem two posts upward of this...

lol - i love trig... just not everyone's cup of tea... and with a bit of lateral thinking there was no need for it at all  wink  besides... there's always more than one way to skin a scratch cat!  tongue

Last edited by Ratty1967UK (2010-05-06 20:41:10)

Offline

 

#22 2010-05-07 16:45:05

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

Ratty1967UK wrote:

nXIII wrote:

Ratty1967UK wrote:

with a bit of careful positioning of your sprite costume centre points you could do the whole thing quite easily and leave scratch to do all the scary trigonometry for you!  smile

hopefully this little example will help you get there...
http://scratch.mit.edu/projects/Ratty1967UK/1031871

1. Trig is awesomesauce, not scary.
2. I've already solved the problem two posts upward of this...

lol - i love trig... just not everyone's cup of tea... and with a bit of lateral thinking there was no need for it at all  wink  besides... there's always more than one way to skin a scratch cat!  tongue

Or a ScratchFrame  tongue


nXIII

Offline

 

#23 2010-05-07 16:46:43

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: I need help with a missile sprite location- I may need trig help...

nXIII wrote:

Ratty1967UK wrote:

nXIII wrote:


1. Trig is awesomesauce, not scary.
2. I've already solved the problem two posts upward of this...

lol - i love trig... just not everyone's cup of tea... and with a bit of lateral thinking there was no need for it at all  wink  besides... there's always more than one way to skin a scratch cat!  tongue

Or a ScratchFrame  tongue

ROLF  tongue


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

Board footer