Discuss Scratch
- Discussion Forums
 - » Help with Scripts
 - » Help with a single-sprite project
        
         
- RedFaceplant
 - 
                            
						
						
                            Scratcher
                        
						
						 
48 posts
Help with a single-sprite project
I'm trying to do a game using only 1 sprite - its a nice challenge. I was just wondering if there is any way to make a sprite point toward the origin (0,0) from any space on the coordinate plain. I think there is a geometry equation for this, but nothing I know of works for this (calculating the angle on a triangle using the sprite's X and Y coordinates). if it helps it's a clone that needs to point toward (0,0) from somewhere picked randomly onto the coordinate plain. Thanks!
-Red
                        
                        
                    -Red
- asivi
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Help with a single-sprite project
You can have the main sprite at (0, 0) and use
To get that block you can create a temporary sprite and drag androp it to your Sprite from there, after done you can delete the temporary sprite.
                        
                        
                    point towards [ v]
To get that block you can create a temporary sprite and drag androp it to your Sprite from there, after done you can delete the temporary sprite.
- RedFaceplant
 - 
                            
						
						
                            Scratcher
                        
						
						 
48 posts
Help with a single-sprite project
You can have the main sprite at (0, 0) and usepoint towards [ v]
To get that block you can create a temporary sprite and drag androp it to your Sprite from there, after done you can delete the temporary sprite.
yes, but in the same sprite it cannot select itself using that block or a clone of itself, and a clone cannot select a clone using that block.
- asivi
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Help with a single-sprite project
You can have the main sprite at (0, 0) and usepoint towards [ v]
To get that block you can create a temporary sprite and drag androp it to your Sprite from there, after done you can delete the temporary sprite.
yes, but in the same sprite it cannot select itself using that block or a clone of itself, and a clone cannot select a clone using that block.
Well, this project is saying other thing https://scratch.mit.edu/projects/194221391/
However, here is a CB that calculates direction for two points by using a trigonometric function:
define diection point1 (x1) (y1) point2 (x2) (y2)
set [direction v] to (([atan v] of (((x2) - (x1)) / ((y2) - (y1)))) + ((180) * <(y1) > (y2)>))
Last edited by asivi (March 30, 2018 04:01:11)
- TheParadoxScratcher
 - 
                            
						
						
                            Scratcher
                        
						
						 
75 posts
Help with a single-sprite project
You don't have to get it from another sprite. There's an easier way.You can have the main sprite at (0, 0) and usepoint towards [ v]
To get that block you can create a temporary sprite and drag androp it to your Sprite from there, after done you can delete the temporary sprite.
yes, but in the same sprite it cannot select itself using that block or a clone of itself, and a clone cannot select a clone using that block.
Well, this project is saying other thing https://scratch.mit.edu/projects/194221391/
However, here is a CB that calculates direction for two points by using a trigonometric function:define diection point1 (x1) (y1) point2 (x2) (y2)
set [direction v] to (([atan v] of (((x2) - (x1)) / ((y2) - (y1)))) + ((180) * <(y1) > (y2)>))
point towards (join [sprite] [])
- deck26
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Help with a single-sprite project
The point is they only want to use one sprite - that requires a separate sprite or clone which is what @asivi has already suggested.You don't have to get it from another sprite. There's an easier way.You can have the main sprite at (0, 0) and usepoint towards [ v]
To get that block you can create a temporary sprite and drag androp it to your Sprite from there, after done you can delete the temporary sprite.
yes, but in the same sprite it cannot select itself using that block or a clone of itself, and a clone cannot select a clone using that block.
Well, this project is saying other thing https://scratch.mit.edu/projects/194221391/
However, here is a CB that calculates direction for two points by using a trigonometric function:define diection point1 (x1) (y1) point2 (x2) (y2)
set [direction v] to (([atan v] of (((x2) - (x1)) / ((y2) - (y1)))) + ((180) * <(y1) > (y2)>))point towards (join [sprite] [])
- asivi
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Help with a single-sprite project
You don't have to get it from another sprite. There's an easier way.The point is they only want to use one sprite - that requires a separate sprite or clone which is what @asivi has already suggested.point towards (join [] [Sprite name])
Hi @deck26, i think you missunderstood to @TheParadoxScratcher; probably they is talking about to use the name of the single(the only one in the project) parent Sprite,.Since such block is available in any Sprite @TheParadoxScratche
 suggestion is right.Last edited by asivi (March 30, 2018 16:57:10)
- deck26
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Help with a single-sprite project
@asivi - if there's only one sprite it can't point to itself. You already covered the case of a clone printing to the parent sprite. And no need to use join to get the name of the sprite since it can be hard-coded. So I still don't see how that suggestion fits.
                        
                            Last edited by deck26 (March 30, 2018 17:22:06)
- GoldyIsland
 - 
                            
						
						
                            Scratcher
                        
						
						 
100 posts
Help with a single-sprite project
I'm trying to do a game using only 1 sprite - its a nice challenge. I was just wondering if there is any way to make a sprite point toward the origin (0,0) from any space on the coordinate plain. I think there is a geometry equation for this, but nothing I know of works for this (calculating the angle on a triangle using the sprite's X and Y coordinates). if it helps it's a clone that needs to point toward (0,0) from somewhere picked randomly onto the coordinate plain. Thanks!Draw with pen; that's the best I can offer without seeing the project
-Red
- asivi
 - 
                            
						
						
                            Scratcher
                        
						
						 
1000+ posts
Help with a single-sprite project
Coming back the original question
Let the parent hidden at (0, 0) then use in clone _point towards_ “parent”
You spent 1 clone so you can create 300 cloned sprites yet.
Do you need a clone pointing to other clone? Send the parent to coordinates of the other clone and use such block again, after you get the direction make the parent go back to (0, 0).
The point of my response was that you are not forced to use maths at all. It can be applied to get distances too, doing use of the sensing block (distance to _).
That is all.
Greetings.
                        
                        
                    …it's a clone that needs to point toward (0,0) from somewhere picked randomly onto the coordinate plain. Thanks!
Let the parent hidden at (0, 0) then use in clone _point towards_ “parent”
You spent 1 clone so you can create 300 cloned sprites yet.
Do you need a clone pointing to other clone? Send the parent to coordinates of the other clone and use such block again, after you get the direction make the parent go back to (0, 0).
The point of my response was that you are not forced to use maths at all. It can be applied to get distances too, doing use of the sensing block (distance to _).
That is all.
Greetings.
- TheParadoxScratcher
 - 
                            
						
						
                            Scratcher
                        
						
						 
75 posts
Help with a single-sprite project
@asivi - if there's only one sprite it can't point to itself. You already covered the case of a clone printing to the parent sprite. And no need to use join to get the name of the sprite since it can be hard-coded. So I still don't see how that suggestion fits.It's a technique the often used in cloning

- Discussion Forums
 - » Help with Scripts
 - 
            » Help with a single-sprite project 
         
            



