Pages: 1
I have a sprite. It looks like this:
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:
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!
Offline
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.
Offline
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)
Offline
You could try to use bezier cures.
Offline
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:
Now, under each of the 'MAIN CANNONS' blocks I want there to be a missile.
The missile does fit under the block in Scratch:
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?
Offline
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?
Offline
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.
Offline
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
Offline
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.
Offline
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)
Offline
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)
Offline
Try bezier cures. http://www.create-games.com/article.asp?id=1866
Offline
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!
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
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!
![]()
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...
Offline
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!
![]()
hopefully this little example will help you get there...
http://scratch.mit.edu/projects/Ratty1967UK/10318711. 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
besides... there's always more than one way to skin a scratch cat!
Last edited by Ratty1967UK (2010-05-06 20:41:10)
Offline
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!
![]()
hopefully this little example will help you get there...
http://scratch.mit.edu/projects/Ratty1967UK/10318711. 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
besides... there's always more than one way to skin a scratch cat!
![]()
Or a ScratchFrame
Offline
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
besides... there's always more than one way to skin a scratch cat!
![]()
Or a ScratchFrame
![]()
ROLF
Offline
Pages: 1