Discuss Scratch

oevboev
Scratcher
19 posts

Help wanted with script in my game, Fatal Altitude

Hi All,

I'm totally new to scratch. I made this little game: https://scratch.mit.edu/projects/144923401/

I could use some help though…

Notice that when the plane that come towards the player exits the screen - some of it stays visible(it's tail). If the player collide with the stuck plane tail, the player explode. Sad.

Can someone help me change the code so these planes leaves the screen 100%? The sprite for the oncoming plane is called Airplane2.

Comments and criticism very welcome.

Best wishes,

Andreas
deck26
Scratcher
1000+ posts

Help wanted with script in my game, Fatal Altitude

Scratch doesn't normally let sprites go completely off screen as this can be confusing for new coders although there are tricks you can use to get close to this. However if you're new it might be better to use an easier option such as having a border which the sprite would go behind or hiding the sprite when it gets far enough off screen.
NOVA31
Scratcher
4 posts

Help wanted with script in my game, Fatal Altitude

whenclickedforeveriftouchingEdge?thengotox:175y:pickrandom-100to180stopThis script
I think it's the best fix you can do.

Last edited by NOVA31 (Feb. 14, 2017 09:45:02)

hammer965
Scratcher
100+ posts

Help wanted with script in my game, Fatal Altitude

Perhaps an easy solution is that at the start of the forever loop that controls the plane put in a block that says “show” this makes the plane visible. when the plane gets to the far left of screen tell it to hide.

At the start of the forever loop when the next plane starts it will be visible as the first command is show.
oevboev
Scratcher
19 posts

Help wanted with script in my game, Fatal Altitude

NOVA31 wrote:

whenclickedforeveriftouchingEdge?thengotox:175y:pickrandom-100to180stopThis script
I think it's the best fix you can do.

Done this now - note that it doesn't fix it….
Tomblybobs
Scratcher
56 posts

Help wanted with script in my game, Fatal Altitude

click see inside, add that to the script, remix it and: boom! you have a remixed progect with that in!
deck26
Scratcher
1000+ posts

Help wanted with script in my game, Fatal Altitude

Combine some of those forever loops to make it more efficient.

If you display the x position of the other plane it never goes below -285. So if you check for x being less than -280 you can tell the plane to go back to the right or hide and then reappear at the right after a delay.
deck26
Scratcher
1000+ posts

Help wanted with script in my game, Fatal Altitude

oevboev wrote:

NOVA31 wrote:

whenclickedforeveriftouchingEdge?thengotox:175y:pickrandom-100to180stopThis script
I think it's the best fix you can do.

Done this now - note that it doesn't fix it….
If you stop the script it can only affect the first plane. And if the plane is touching the right edge the ‘touching edge’ will still be true whereas you only care about it reaching the left edge - but touching the left edge would make it disappear too soon, you want at least some of the plane to go over the edge.
Psicore_Coding
Scratcher
50 posts

Help wanted with script in my game, Fatal Altitude

oevboev wrote:

Hi All,

I'm totally new to scratch. I made this little game: https://scratch.mit.edu/projects/144923401/

I could use some help though…

Notice that when the plane that come towards the player exits the screen - some of it stays visible(it's tail). If the player collide with the stuck plane tail, the player explode. Sad.

Can someone help me change the code so these planes leaves the screen 100%? The sprite for the oncoming plane is called Airplane2.

Comments and criticism very welcome.

Best wishes,

Andreas


whenclickedforeveriftouching edge?thenhideThenmakeitgotothestart.Shouldwork.

Last edited by Psicore_Coding (Feb. 14, 2017 15:20:52)

deck26
Scratcher
1000+ posts

Help wanted with script in my game, Fatal Altitude

Psicore_Coding wrote:

oevboev wrote:

Hi All,

I'm totally new to scratch. I made this little game: https://scratch.mit.edu/projects/144923401/

I could use some help though…

Notice that when the plane that come towards the player exits the screen - some of it stays visible(it's tail). If the player collide with the stuck plane tail, the player explode. Sad.

Can someone help me change the code so these planes leaves the screen 100%? The sprite for the oncoming plane is called Airplane2.

Comments and criticism very welcome.

Best wishes,

Andreas


whenclickedforeveriftouching edge?thenhideThenmakeitgotothestart.Shouldwork.
Not if the start position means it is touching the edge.
oevboev
Scratcher
19 posts

Help wanted with script in my game, Fatal Altitude

Thank you everyone, for All your info and suggestions.
I Was Thinking:
Perhaps its posible to some how kill the Sprite from existence a second or so after it touches the left Edge of the screen?

Last edited by oevboev (Feb. 14, 2017 16:36:37)

deck26
Scratcher
1000+ posts

Help wanted with script in my game, Fatal Altitude

oevboev wrote:

Thank you everyone, for All your info and suggestions.
I Was Thinking:
Perhaps its posible to some how kill the Sprite from existence a second or so after it touches the left Edge of the screen?
You can stop a sprite's scripts or hide it or do other things so you need to define ‘kill’ in that sentence. If it's moving at a constant speed the x-coordinate will be under a certain value after a certain amount of time so using the x-value is the easiest option. The only exception is that if the x-value can't go any lower then obviously it then stays at that value so the position would stop changing after a certain amount of time.
Tomblybobs
Scratcher
56 posts

Help wanted with script in my game, Fatal Altitude

deck26 wrote:A constact of speedless.
oevboev
Scratcher
19 posts

Help wanted with script in my game, Fatal Altitude

After the x-value reaches its lowest and the tail of the plane is still visible i Guess i want to make airplane2 disappear. Not through ‘hide’ but so that it cant collide with player.
Sorry if i dont make too much sense. I am new to scripting lingo still.

Last edited by oevboev (Feb. 14, 2017 19:31:58)

deck26
Scratcher
1000+ posts

Help wanted with script in my game, Fatal Altitude

oevboev wrote:

After the x-value reaches its lowest and the tail of the plane is still visible i Guess i want to make airplane2 disappear. Not through ‘hide’ but so that it cant collide with player.
Sorry if i dont make too much sense. I am new to scripting lingo still.
Why not through ‘hide’? It's the obvious way and will stop the player sprite detecting the touch which ghosting won't do. then you show it again when you start again from the right.
jaraeez
Scratcher
100+ posts

Help wanted with script in my game, Fatal Altitude

deck26 wrote:

oevboev wrote:

After the x-value reaches its lowest and the tail of the plane is still visible i Guess i want to make airplane2 disappear. Not through ‘hide’ but so that it cant collide with player.
Sorry if i dont make too much sense. I am new to scripting lingo still.
Why not through ‘hide’? It's the obvious way and will stop the player sprite detecting the touch which ghosting won't do. then you show it again when you start again from the right.

He's right!
nonethenones
Scratcher
100+ posts

Help wanted with script in my game, Fatal Altitude

Tomblybobs wrote:

click see inside, add that to the script, remix it and: boom! you have a remixed progect with that in!

Add what to the script?
oevboev
Scratcher
19 posts

Help wanted with script in my game, Fatal Altitude

jaraeez wrote:

deck26 wrote:

oevboev wrote:

After the x-value reaches its lowest and the tail of the plane is still visible i Guess i want to make airplane2 disappear. Not through ‘hide’ but so that it cant collide with player.
Sorry if i dont make too much sense. I am new to scripting lingo still.
Why not through ‘hide’? It's the obvious way and will stop the player sprite detecting the touch which ghosting won't do. then you show it again when you start again from the right.

He's right!

I did this and it seems to work pretty good! Thanks all!
oevboev
Scratcher
19 posts

Help wanted with script in my game, Fatal Altitude

Hi again,

Another issue - hope someone out there will look at it :-)

Somehow the non-player airplane sometimes is pointing the wrong way: with its nose pointed right. It should point left. I tried to fix this like this:

point in direction (-72 v) - but it doesn't seem to work…

This is the script for the non-player airplane called ‘airplane2’:

when green flag clicked
hide
go to x: (279) y: (41)
wait (pick random (1) to (3)) secs
forever
point in direction (-72 v)
wait (pick random (1) to (3)) secs
show
set volume to (100) %
play sound
set y to (pick random (-180) to (180))
set x to (250)
next costume
repeat (105)
change x by (-10)
end
wait (pick random (1) to (3)) secs
set volume to (20) %
play sound
set y to (pick random (-180) to (180))
set x to (250)
next costume
repeat (105)
change x by (-10)
end
end

Best,

Andreas

PS: how do I paste the code so it looks like the ‘blocks’ from my script in the projects?

Last edited by oevboev (Feb. 15, 2017 08:58:23)

deck26
Scratcher
1000+ posts

Help wanted with script in my game, Fatal Altitude

A costume will appear in the editor as it is when pointing right. If you have a costume that actually points left then direction commands will always misbehave. Not sure why you're using -72 but for different rotation styles that will mean.

No rotation - as it appears in the editor
Left-right - mirror image of how it is in editor
All round - rotated 162 degrees anti clockwise

The blue icon above the text window when typing in the forum (third from right) gives access to scratchblocks. Can be tricky so there's a sticky topic at the top of the forum for practice.

Powered by DjangoBB