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

#1 2012-12-02 22:02:26

archlordtroller
New Scratcher
Registered: 2012-12-02
Posts: 8

Programming games

I have joined a special school that has advanced computer education. We are to make a scene or games with scratch. This is my first time using scratch and I wanted to ask a question. Is it possible to make sort of a toggle/trigger? My idea is that a cannon/gun shoots projectiles at you sprite. When the projectile reaches the edge of your sprite than the background would change and you would have lost a life. Is it possible to make it so that if a projectile hits even the edge of your sprite than your background would change? Please answer quickly. I probably have around 1-2 months but I have no experience so I want a head start. all help would be appreciated.

Offline

 

#2 2012-12-02 22:10:01

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Programming games

First of all, I am quite jealous of your opportunity to join such a school  tongue

Secondly, is this what you want:
When a sprite is touched by another (the cannon ball), the background changes and a variable decreases by one

For the main-character sprite use this:

when gf clicked
forever
wait until <not<touching [cannon-ball v]?>> // stops sprite from double-counting the same shot
wait until <touching [cannon-ball v]?>
broadcast [change background v]
change [health v] by (-1)
And for the background/stage:

when I receive [change background v]
switch to costume [costume1 v]


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#3 2012-12-02 22:13:19

archlordtroller
New Scratcher
Registered: 2012-12-02
Posts: 8

Re: Programming games

yikes  thank you so much for the quick response. I think this will help a ton. Also I'm not that proud of going into the school. The school is pretty great but I had to pass a test to make it. I failed it and I was one of the first on the waiting list. A few weeks later I found out that I was off the waiting list and in the program. There was only one celebration I wanted that day and it came true. NON STOP EATING OF INSTANT NOODLES FOR THE WHOLE DAY!

Offline

 

#4 2012-12-03 08:57:07

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Programming games

I wish my school had programming classes. ;_;

I mean it does have Scratch (6/7 grades) and Web Design but they leave out Java and stuff!


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#5 2012-12-03 11:45:54

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Programming games

mythbusteranimator wrote:

I wish my school had programming classes. ;_;

I mean it does have Scratch (6/7 grades) and Web Design but they leave out Java and stuff!

My state has an online school, so I'm taking Java I online and the rest of my classes at a physical high school.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#6 2012-12-03 11:48:59

mythbusteranimator
Scratcher
Registered: 2012-02-28
Posts: 1000+

Re: Programming games

MoreGamesNow wrote:

mythbusteranimator wrote:

I wish my school had programming classes. ;_;

I mean it does have Scratch (6/7 grades) and Web Design but they leave out Java and stuff!

My state has an online school, so I'm taking Java I online and the rest of my classes at a physical high school.

You get to take Java?  sad


http://www.foxtrot.com/comics/2012-04-01-fdb37077.gif
clicky

Offline

 

#7 2012-12-03 18:18:29

archlordtroller
New Scratcher
Registered: 2012-12-02
Posts: 8

Re: Programming games

Um I'm sort of stuck on something else. I want to have enough cannonballs to that there is only one space that your sprite can move to to dodge it. E.g pretend that each o is a cannon ball and ^^ is the sprite i want it sort of like this
ooooooooooooooo   oooooooooooooooooooooooooooooooooooooooooooooooooooo


                         ^^

I want the space where a a cannon ball won't fall to randomize each time please help and sorry for the long message. (P.S how do you have a signature under each post?)

Offline

 

#8 2012-12-03 18:31:05

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Programming games

archlordtroller wrote:

(P.S how do you have a signature under each post?)

Signatures are a scratcher feature; meaning you'll have to become a scratcher before getting one, though if you're active for atleast a month, you should become a scratcher after your wait. And for when you do become a scratcher, just click the Profile button at the top of any forum page, go to Personality, and you'll be able to create your signature.  smile

And just to say, if no one answers your first question by tomorrow, I'll try and answer it.

Anyway, I hope that this answers your second question! And welcome to scratch! I wish you good luck on learning how to code!

Last edited by ErnieParke (2012-12-03 20:00:52)


http://i46.tinypic.com/35ismmc.png

Offline

 

#9 2012-12-03 19:29:48

archlordtroller
New Scratcher
Registered: 2012-12-02
Posts: 8

Re: Programming games

Thank you so much. This website is so nice and inclusive. I wish every forum I went to was this active and empathetic.

Offline

 

#10 2012-12-03 21:38:09

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Programming games

mythbusteranimator wrote:

You get to take Java?  sad

Yes, my physical high school really only offers one programming class, but, as I mentioned above, the online high school offers Java I.  In my opinion, it is quite similar to C (which I know vaguely) and, to a much lesser extent, JavaScript (which I know fairly well).


archlordtroller wrote:

Um I'm sort of stuck on something else. I want to have enough cannonballs to that there is only one space that your sprite can move to to dodge it. E.g pretend that each o is a cannon ball and ^^ is the sprite i want it sort of like this
ooooooooooooooo   oooooooooooooooooooooooooooooooooooooooooooooooooooo

                         ^^
I want the space where a a cannon ball won't fall to randomize each time please help and sorry for the long message. (P.S how do you have a signature under each post?)

Ah, this will be much more difficult.  There is really no way to script cannon balls without using multiple sprites, and even then the scripts that fire them are more complex than the simple collision script above.

Anywhere:

when gf clicked
forever
broadcast [fire v] and wait
wait (3) secs // interval between firings
For first cannon ball:
when I receive [fire v]
go to [cannon v]
point towards [main-character v] // or wherever they should aim
show
repeat until<touching [edge v]?>
move (4) steps
end
hide
For the second cannon ball:
when I receive [fire v]
go to [cannon v]
point towards [main-character v] // or wherever they should aim
wait (0.5) secs // increase the time for each cannon ball so the fire in sequence
show
repeat until<touching [edge v]?>
move (4) steps
end
hide
Between two cannon balls, simply leave a large gap of time (I'm making a guesstimate of 1-2 seconds, but it depends on the speed of your main sprite, the speed of the cannon balls (4 in the above example) etc.)

Edit: if ErnieParke of someone else wants to check my script that'd be great  smile

Last edited by MoreGamesNow (2012-12-03 21:40:00)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#11 2012-12-04 20:30:15

archlordtroller
New Scratcher
Registered: 2012-12-02
Posts: 8

Re: Programming games

im sorry but there is one more thing. I wanted my main character to move by following the mouse. I did that so far and I made the cannon ball follow the main character. However i have to go into each separate script to start there actions. I can't press the green start flg on the top right corner. i have to go to each sprite's script and press the green flach in the script

Offline

 

#12 2012-12-04 20:38:02

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Programming games

archlordtroller wrote:

im sorry but there is one more thing. I wanted my main character to move by following the mouse. I did that so far and I made the cannon ball follow the main character. However i have to go into each separate script to start there actions. I can't press the green start flg on the top right corner. i have to go to each sprite's script and press the green flach in the script

Could you post your scripts or upload your project so that I can help hunt down what's going wrong?

MoreGamesNow wrote:

mythbusteranimator wrote:

You get to take Java?  sad

Yes, my physical high school really only offers one programming class, but, as I mentioned above, the online high school offers Java I.  In my opinion, it is quite similar to C (which I know vaguely) and, to a much lesser extent, JavaScript (which I know fairly well).


archlordtroller wrote:

Um I'm sort of stuck on something else. I want to have enough cannonballs to that there is only one space that your sprite can move to to dodge it. E.g pretend that each o is a cannon ball and ^^ is the sprite i want it sort of like this
ooooooooooooooo   oooooooooooooooooooooooooooooooooooooooooooooooooooo

                         ^^
I want the space where a a cannon ball won't fall to randomize each time please help and sorry for the long message. (P.S how do you have a signature under each post?)

Ah, this will be much more difficult.  There is really no way to script cannon balls without using multiple sprites, and even then the scripts that fire them are more complex than the simple collision script above.

Anywhere:

when gf clicked
forever
broadcast [fire v] and wait
wait (3) secs // interval between firings
For first cannon ball:
when I receive [fire v]
go to [cannon v]
point towards [main-character v] // or wherever they should aim
show
repeat until<touching [edge v]?>
move (4) steps
end
hide
For the second cannon ball:
when I receive [fire v]
go to [cannon v]
point towards [main-character v] // or wherever they should aim
wait (0.5) secs // increase the time for each cannon ball so the fire in sequence
show
repeat until<touching [edge v]?>
move (4) steps
end
hide
Between two cannon balls, simply leave a large gap of time (I'm making a guesstimate of 1-2 seconds, but it depends on the speed of your main sprite, the speed of the cannon balls (4 in the above example) etc.)

Edit: if ErnieParke of someone else wants to check my script that'd be great  smile

There's nothin that I can see wrong, though your script is going to stagger the cannonballs so that it looks more like this:

Code:

          O
         O
        O
     O
    O
   O
  O
 O
O


It's probably not exactly what archlordtroller wants, but it'll work.

Last edited by ErnieParke (2012-12-04 20:42:02)


http://i46.tinypic.com/35ismmc.png

Offline

 

#13 2012-12-04 22:02:18

archlordtroller
New Scratcher
Registered: 2012-12-02
Posts: 8

Re: Programming games

how can i add a file. it is a bit complex because there are different scripts for each sprite

Offline

 

#14 2012-12-05 15:05:24

SketchSmozzick
Scratcher
Registered: 2012-06-22
Posts: 8

Re: Programming games

How to upload a project you mean? In scratch press the button to the right of the save button (the share this project button) and enter the details.

Is this the type of thing you're doing? Link to project

Like I mentioned the problem would be (as Erniepark wrote) that there would be staggering with the cannonballs. One possible solution to this is to keep all of the cannonballs in one costume and change the costume as necessary.

A version with them all in one costume: Link to project

Last edited by SketchSmozzick (2012-12-05 15:10:40)

Offline

 

#15 2012-12-05 18:26:01

archlordtroller
New Scratcher
Registered: 2012-12-02
Posts: 8

Re: Programming games

Sorry it is a bit different. I have sprite one following the mouse pointer moving at 6.75 steps while the sprite number 2 is chasing it. I wrote that if they touch the sprite one losses 1 health. But the health doesn't go down by one if they touch

Offline

 

#16 2012-12-05 19:01:50

archlordtroller
New Scratcher
Registered: 2012-12-02
Posts: 8

Re: Programming games

http://scratch.mit.edu/projects/archlordtroller/2960212 that is my project

Offline

 

Board footer