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

#1 2007-05-18 17:39:56

tomosh
Scratcher
Registered: 2007-05-17
Posts: 4

Sim Game programming help!

For example: If I wanted the happiness to go up every 10 secs, why wont it work if i:

When Green flag pressed
if timer=10
change happiness by 10

but it doesnt work.

Any suggestions?

tomosh

Offline

 

#2 2007-05-18 17:56:39

Canthiar
Scratcher
Registered: 2007-05-16
Posts: 100+

Re: Sim Game programming help!

Why not this?

When green flag pressed
  Forever
    Wait 10 seconds
      change happiness by 10

Unless you're resetting the timer when you get to 10 you're only going to hit it once.

Offline

 

#3 2007-05-18 18:43:08

paulmedwal
Scratcher
Registered: 2007-03-09
Posts: 100+

Re: Sim Game programming help!

Here is one that resets the timer...you need to use greater than or less than... equal will not work with the timer:

when green flag clicked
        reset timer
        forever
            if timer > 10
                reset timer
                change happiness by 1

Paulmedwal


clutter.scratch.mit.edu Visit the Clutter site to create multi-scene stories and multi-level games with Scratch.

Offline

 

#4 2007-05-19 03:16:14

tomosh
Scratcher
Registered: 2007-05-17
Posts: 4

Re: Sim Game programming help!

You are a hero!

You have made the sim project continue!

tomosh

Offline

 

#5 2007-05-19 03:18:18

tomosh
Scratcher
Registered: 2007-05-17
Posts: 4

Re: Sim Game programming help!

Oh, do you have to reset the timer on:

when green flag clicked
        reset timer
        forever
            if timer > 10
                reset timer
                change happiness by 1

Or can you:

when green flag clicked
        forever
            if timer > 10
                change happiness by 1

Or:

when green flag clicked
        reset timer
        forever
            if timer > 10
                change happiness by 1

Any suggestions?

tomosh

Offline

 

#6 2007-05-19 12:05:23

tammy
Scratcher
Registered: 2007-03-07
Posts: 57

Re: Sim Game programming help!

I think you want the first one (with 2 "reset timer" blocks).  You want the first one because the timer does not automatically reset when the green flag is clicked.  The second one sets the timer back to zero, so you can start all over again and check for when it reaches 10.

Does that help?

-Tammy

Offline

 

Board footer