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

#1 2012-08-27 19:31:27

tree-hugger
Scratcher
Registered: 2011-11-19
Posts: 38

How should I do this?

So I'm trying to make a game that involves using a lot of the same things over and over on one screen. I was thinking I could use stamping but I'm having trouble... can I still do this with stamping, or should I do something else? Here's what I'm trying to do:
Ok so I have pies and bombs on the screen, they appear randomly. When my sprite touches any pie the pie should disappear, when my sprite touches any bomb it should blow up and the game should be over. I don't think I can do this with stamping, so what should I do instead? I need some ideas  smile

Thanx 4 the help I've gotten already! looks like I won't use stamping, is there any other way though besides making a million pies and bombs (I can do that it's just I'd rather not)?

Last edited by tree-hugger (2012-08-27 20:18:37)


http://oi48.tinypic.com/1y7tjr.jpghttp://oi50.tinypic.com/28tb34j.jpg                     http://oi50.tinypic.com/21c6v74.jpg                    ...ya, I'm weird... REAL weird...
BITBOT ALL THE WAY!!!     Only the WEIRDEST games!     (that's just  a Tree-Hugger thing)

Offline

 

#2 2012-08-27 19:43:34

yuxuan
Scratcher
Registered: 2010-04-01
Posts: 3

Re: How should I do this?

Do not use stamping because you will need each of the bombs to have their own script. Stamping will be deperately hard to work with. Heres some suggestions: make how many bombs or pies you want that would show up on the screen at the same time, use hide and show for disappearing and reappearing.
idk if this would help but good luck  big_smile

Offline

 

#3 2012-08-27 19:53:57

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: How should I do this?

I would think the easiest solution to this kind of problem would be to make the objects of which you have a lot do the sensing, instead of your player sprite.

Try scripting one pie/bomb so it behaves the way you want it to, without scripting stuff specifically for this pie/bomb in the player sprite. You can then duplicate this sprite as much as you like.
For example:

when I receive [start level v] //add this to your bomb sprite(s)
go to x: (pick random (-200) to (200)) y: (pick random (-150) to (150))
show //look like a bomb :)
set size to (100)%
switch to costume [bomb v]
wait until <touching [player v]?>
switch to costume [explode v] //explosion animation
repeat (10)
  change size by (20)
  change [ghost v] effect by (10)
end
broadcast [game over! v]
Your player can then receive the "game over!" broadcast.
You can duplicate bomb sprites like this as many times as you like.

There's also a trick you could use if you'd for example want to control the total amount of bombs in one level.

set [bombs shown v] to (0) //on stage/player
set [total bombs v] to (5) 
broadcast [start level v]
And then, on every bomb/pie...
when I receive [start level v]
if <not <(bombs shown) < (total bombs)>>
  hide
  stop script
end
change [bombs shown v] by (1)
show // add the rest of the script from above here

Last edited by JSO (2012-08-28 05:37:10)


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#4 2012-08-28 04:34:38

BirdByte
Scratcher
Registered: 2012-07-07
Posts: 1000+

Re: How should I do this?

Actually, stamping is perfect for this! All you need is a simple little script and 3 lists.

First, you'll need 2 costumes in a sprite: Bomb and Pie, in that order.
Now, make 3 lists: Type, X, and Y.
Next, a variable: counter.
Let's start off our script. We'll do this:

when gf clicked
delete (all v) of [Type v]
delete (all v) of [X v]
delete (all v) of [Y v]
forever
 clear
 hide
 set [counter v] to [1]
end
Let's start with the stamping script. We'll need to add this to the bottom of the loop:

if <not <(counter) > (length of [Type v])>>
 show
 switch to costume (item (counter) of [Type v])
 go to x: (item (counter) of [X v]) y: (item (counter) of [Y v])
 stamp
 if <touching [player v]?>
  if <(item (counter) of [Type v]) = [1]>
   delete (all v) of [Type v]
   delete (all v) of [X v]
   delete (all v) of [Y v]
   broadcast [game-over v]
  else
   delete (counter) of [Type v]
   delete (counter) of [X v]
   delete (counter) of [Y v]
   broadcast [pie-collected v]
  end
 end
 hide
 change [counter v] by (1)
end
So, our script now looks like this:
when gf clicked
delete (all v) of [Type v]
delete (all v) of [X v]
delete (all v) of [Y v]
forever
 clear
 hide
 set [counter v] to [1]
 if <not <(counter) > (length of [Type v])>>
  show
  switch to costume (item (counter) of [Type v])
  go to x: (item (counter) of [X v]) y: (item (counter) of [Y v])
  stamp
  if <touching [player v]?>
   if <(item (counter) of [Type v]) = [1]>
    delete (all v) of [Type v]
    delete (all v) of [X v]
    delete (all v) of [Y v]
    broadcast [game-over v]
   else
    delete (counter) of [Type v]
    delete (counter) of [X v]
    delete (counter) of [Y v]
    broadcast [pie-collected v]
   end
  end
  hide
  change [counter v] by (1)
 end
end
Now, we right click on the if just below the set counter block and select duplicate. Put it just above the if that you right clicked on. Repeat this process 6 times.

To add more objects, use this script:

add [1] to [Type v] //1 is bomb, 2 is pie. You can use a pick random block here.
add [0] to [X v] //X position of new object. Use pick random block.
add [0] to [Y v] //Y position of new object. Use pick random block.


http://i50.tinypic.com/312u714.jpg

Offline

 

#5 2012-08-28 21:13:02

dvd4
Scratcher
Registered: 2010-06-30
Posts: 1000+

Re: How should I do this?

stamping is good if you want your project to be small,and if their isn't a limit multiple sprites are good (I think that the stamping is better)


I made a mod  big_smile  It's called blook!
http://i49.tinypic.com/16ia63p.png

Offline

 

#6 2012-08-28 21:22:55

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: How should I do this?

You store the locations of the stamps in variables, so the screen can be redrawn at any time.  That's basically how a 1s1s project works: in the "draw" section of the script, the single sprite goes to all the locations in the screen that it needs to and either stamps itself (after switching to the right costume) or uses the pen to draw lines, etc.

Offline

 

#7 2012-08-29 00:35:31

tree-hugger
Scratcher
Registered: 2011-11-19
Posts: 38

Re: How should I do this?

amcerbu wrote:

You store the locations of the stamps in variables, so the screen can be redrawn at any time.  That's basically how a 1s1s project works: in the "draw" section of the script, the single sprite goes to all the locations in the screen that it needs to and either stamps itself (after switching to the right costume) or uses the pen to draw lines, etc.

OHHHHH... ok my life is making a lot more sense!  tongue  That's how 1s1s works! Ok well, I'll do that hope I can make the scripts work! Thanx a lot  big_smile


http://oi48.tinypic.com/1y7tjr.jpghttp://oi50.tinypic.com/28tb34j.jpg                     http://oi50.tinypic.com/21c6v74.jpg                    ...ya, I'm weird... REAL weird...
BITBOT ALL THE WAY!!!     Only the WEIRDEST games!     (that's just  a Tree-Hugger thing)

Offline

 

#8 2012-08-29 00:39:30

Crystlemoon24
New Scratcher
Registered: 2012-05-24
Posts: 54

Re: How should I do this?

Hi tree hugger!!!

Offline

 

#9 2012-08-29 01:15:37

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: How should I do this?

@tree-hugger - Yeah.  You can break up a 1s1s project into a bunch of "broadcast and wait" blocks and "when I receive" hats for ease of readability, or if the 1s1s is lagging too much.  It also helps organize your code. 

If you're using a bunch of bombs, you can have a single "bombs" sprite that holds a list of x positions and a list of y positions.  At any point, it can go to (item 1 of x, item 1 of y) and stamp to draw a bomb, or any item number, for that matter.  When you have to draw the screen, you use a loop to go through all the items in x and y lists and stamp.  This usually requires the project to run in turbo mode.

Last edited by amcerbu (2012-08-29 01:15:58)

Offline

 

#10 2012-08-31 13:15:47

tree-hugger
Scratcher
Registered: 2011-11-19
Posts: 38

Re: How should I do this?

amcerbu wrote:

@tree-hugger - Yeah.  You can break up a 1s1s project into a bunch of "broadcast and wait" blocks and "when I receive" hats for ease of readability, or if the 1s1s is lagging too much.  It also helps organize your code. 

If you're using a bunch of bombs, you can have a single "bombs" sprite that holds a list of x positions and a list of y positions.  At any point, it can go to (item 1 of x, item 1 of y) and stamp to draw a bomb, or any item number, for that matter.  When you have to draw the screen, you use a loop to go through all the items in x and y lists and stamp.  This usually requires the project to run in turbo mode.

Ya... I was trying to do something like that  smile  just needed an idea of how too thanx!


http://oi48.tinypic.com/1y7tjr.jpghttp://oi50.tinypic.com/28tb34j.jpg                     http://oi50.tinypic.com/21c6v74.jpg                    ...ya, I'm weird... REAL weird...
BITBOT ALL THE WAY!!!     Only the WEIRDEST games!     (that's just  a Tree-Hugger thing)

Offline

 

Board footer