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

#1 2012-04-24 18:07:00

Laserjl
Scratcher
Registered: 2011-11-13
Posts: 19

1s 1s

how do you make a 1s 1s?


http://scratch.mit.edu/projects/Laserjl/2856013

Offline

 

#2 2012-04-24 19:49:34

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

Re: 1s 1s

Basically, you have one sprite that has one loop inside of it.  During each repetition of the loop, the sprite changes costume and goes to different locations on the screen and stamps.  If those different locations are represented by variables, and the variables change as well during the loop, it looks like a moving object. 

Here's an example 1s1s pong game I just made up (I haven't tried it, so don't count on it working). 

Let's say the ball is 30 x 30 pixels, and the paddle is 80 pixels wide. 

when gf clicked
set [Paddle.X v] to (0)
set [Paddle.Y v] to (-150)
set [Ball.X v] to (0)
set [Ball.Y v] to (0)
set [Ball.Speed v] to (10)
set [Ball.InitialDirection v] to (pick random (-180) to (180))
set [Ball.Velocity.X v] to (([cos v] of (Ball.InitialDirection)) * (Ball.Speed))
set [Ball.Velocity.Y v] to (([sin v] of (Ball.InitialDirection)) * (Ball.Speed))
forever
  change [Ball.X v] by (Ball.Velocity.X)
  change [Ball.Y v] by (Ball.Velocity.Y)
  if <key [right arrow v] pressed?>
    change [Paddle.X v] by (5)
  end
  if <key [left arrow v] pressed?>
    change [Paddle.X v] by (-5)
  end
  if <(Paddle.X) > (200)>
    set [Paddle.X v] to (200)
  end
  if <(Paddle.X) < (-200)>
    set [Paddle.X v] to (-200)
  end
  if <(Ball.Y) < (Paddle.Y)>
    if <((Ball.X) - (Paddle.X)) < (40)>
      set [Ball.Y v] to (Paddle.Y)
      set [Ball.Velocity.Y v] to ((-1) * (Ball.Velocity.Y))
    else
      stop all
    end
  end
  if <(Ball.Y) > (165)>
    set [Ball.Y v] to (165)
    set [Ball.Velocity.Y v] to ((-1) * (Ball.Velocity.Y))
  end
  if <(Ball.X) > (225)>
    set [Ball.X v] to (225)
    set [Ball.Velocity.X v] to ((-1) * (Ball.Velocity.X))    
  end
  if <(Ball.X) < (-225)>
    set [Ball.X v] to (-225)
    set [Ball.Velocity.X v] to ((-1) * (Ball.Velocity.X))    
  end
  clear
  go to x: (Paddle.X) y: (Paddle.Y)
  switch to costume [Paddle v]
  stamp
  go to x: (Ball.X) y: (Ball.Y)
  switch to costume [Ball v]
  stamp
end

Offline

 

#3 2012-04-24 20:15:22

Laserjl
Scratcher
Registered: 2011-11-13
Posts: 19

Re: 1s 1s

Thanks, but I want a platformer.Though I will still try it.


http://scratch.mit.edu/projects/Laserjl/2856013

Offline

 

#4 2012-04-24 22:16:34

chanmanpartyman
Scratcher
Registered: 2011-05-30
Posts: 500+

Re: 1s 1s

Set up the positions as variables then do what you would regularly do except stamp when you need to.

Offline

 

#5 2012-04-25 08:36:16

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

Re: 1s 1s

check out the game "LINE" for the first big 1s1s platforner.


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

Offline

 

#6 2012-04-25 09:02:02

James07
Scratcher
Registered: 2012-04-04
Posts: 500+

Re: 1s 1s

one sprite one script


http://trinary.site40.net/images/scratchrank.php?username=James07

Offline

 

#7 2012-04-29 00:50:33

darthvader111
Scratcher
Registered: 2010-03-12
Posts: 45

Re: 1s 1s

Here is a 1s1s launcher game that I made:

http://scratch.mit.edu/projects/darthvader111/1124532

~Any ideas you got from this? Scripts?

Last edited by darthvader111 (2012-04-29 00:50:53)

Offline

 

#8 2012-04-29 02:12:16

corfeur12
Scratcher
Registered: 2011-09-22
Posts: 5

Re: 1s 1s

any ideas how to make a continuous sound loop for 1s1s?

Offline

 

#9 2012-04-30 13:54:39

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

Re: 1s 1s

amcerbu wrote:

Basically, you have one sprite that has one loop inside of it.  During each repetition of the loop, the sprite changes costume and goes to different locations on the screen and stamps.  If those different locations are represented by variables, and the variables change as well during the loop, it looks like a moving object. 

Here's an example 1s1s pong game I just made up (I haven't tried it, so don't count on it working). 

Let's say the ball is 30 x 30 pixels, and the paddle is 80 pixels wide. 

when gf clicked
set [Paddle.X v] to (0)
set [Paddle.Y v] to (-150)
set [Ball.X v] to (0)
set [Ball.Y v] to (0)
set [Ball.Speed v] to (10)
set [Ball.InitialDirection v] to (pick random (-180) to (180))
set [Ball.Velocity.X v] to (([cos v] of (Ball.InitialDirection)) * (Ball.Speed))
set [Ball.Velocity.Y v] to (([sin v] of (Ball.InitialDirection)) * (Ball.Speed))
forever
  change [Ball.X v] by (Ball.Velocity.X)
  change [Ball.Y v] by (Ball.Velocity.Y)
  if <key [right arrow v] pressed?>
    change [Paddle.X v] by (5)
  end
  if <key [left arrow v] pressed?>
    change [Paddle.X v] by (-5)
  end
  if <(Paddle.X) > (200)>
    set [Paddle.X v] to (200)
  end
  if <(Paddle.X) < (-200)>
    set [Paddle.X v] to (-200)
  end
  if <(Ball.Y) < (Paddle.Y)>
    if <((Ball.X) - (Paddle.X)) < (40)>
      set [Ball.Y v] to (Paddle.Y)
      set [Ball.Velocity.Y v] to ((-1) * (Ball.Velocity.Y))
    else
      stop all
    end
  end
  if <(Ball.Y) > (165)>
    set [Ball.Y v] to (165)
    set [Ball.Velocity.Y v] to ((-1) * (Ball.Velocity.Y))
  end
  if <(Ball.X) > (225)>
    set [Ball.X v] to (225)
    set [Ball.Velocity.X v] to ((-1) * (Ball.Velocity.X))    
  end
  if <(Ball.X) < (-225)>
    set [Ball.X v] to (-225)
    set [Ball.Velocity.X v] to ((-1) * (Ball.Velocity.X))    
  end
  clear
  go to x: (Paddle.X) y: (Paddle.Y)
  switch to costume [Paddle v]
  stamp
  go to x: (Ball.X) y: (Ball.Y)
  switch to costume [Ball v]
  stamp
end

Whew! That scratchblocking must've taken a while!

when i receive [1s1s scratchblocks]
 switch to costume [script]
 wait [a really really long time] seconds
 stamp
 say [that took a while!]


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

Offline

 

#10 2012-04-30 16:06:48

Laserjl
Scratcher
Registered: 2011-11-13
Posts: 19

Re: 1s 1s

when gf clicked
say [1s 1s]


http://scratch.mit.edu/projects/Laserjl/2856013

Offline

 

#11 2012-05-02 05:01:51

Jem12
Scratcher
Registered: 2012-04-20
Posts: 100+

Re: 1s 1s

Just so you know (as you probably do) 1s1s Doesn't need to be a looooooong script and stuff it can just be

[scratchblock]
when space clicked
change colour!!
[/scratchblocks]

cool


"In the begging the universe was created, this made a lot of people angry and was widly regarded as a bad move" ~  Douglas Adams ~ The resturant at the end of the universe

Offline

 

Board footer