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

#1 2007-07-26 14:33:04

Sawman3
Scratcher
Registered: 2007-07-19
Posts: 97

FPS Help

I am currently working one a First Person Shooter using the Scratch language, and up till about yesterday everything was working very smoothly.  however, there seems to be an issue when triggering my cherub monster when using a *when I receive {broadcast}* block.  i have it set up so that it looks like this:

*when I receive {broadcast}
if {key} pressed
etc.

unfortunately, it will only perform the rest of its functions (etc.) if miraculously the {key} is pressed at the exact same moment as it reveives the {broadcast}  So far I have found no way to create a *if x has occured* *when x is pressed* setup that is successful.

Does anyone have suggestions on how to do this or something similar?  A huge amount of time and effort has gone into this project and I don't want to have change its settup and overall complexity now if it can be avoided...

Thanks!


"These are the old days, the glory days...they're back."

Offline

 

#2 2007-07-26 15:43:00

AngelEyra
Scratcher
Registered: 2007-07-19
Posts: 100+

Re: FPS Help

We need to see what sends the broadcast to understand what is going on here. But what you can do is use a variable as a boolean. (What I do is make a variable, make it 0 for false, and 1 for true.) That way, when "event x" occurs, you set the variable to 1. And you can change "if (key) pressed" to "if (variable) = 1"

But...

Why are you putting an if block in a broadcast receiver? I normally do all logic (control blocks) around the "broadcast" block, unless the broadcast is called under more than one circumstance (not recommended).

eyra


AngelEyra's . MyScratchR . Blog
Think with portals
Sorry, Companion Cube... I didn't mean to...

Offline

 

#3 2007-07-26 16:31:29

Sawman3
Scratcher
Registered: 2007-07-19
Posts: 97

Re: FPS Help

AngelEyra: The broadcast is sent by an enemy after it is shot and killed.  Then it is picked up by the next enemy in line.  Then when the player moves forward, as long as that broadcast has been received, the next enemy will appear.  The variable settup does work, I've tried it, but its not as smooth as I'd like it to be.  In earlier situations in the game, I've found that using broadcasts often works as a smoother equivalent to variable manipulations--otherwise I would just use the variable as you suggested.  Thanks, tho.


"These are the old days, the glory days...they're back."

Offline

 

#4 2007-07-26 16:33:47

Sawman3
Scratcher
Registered: 2007-07-19
Posts: 97

Re: FPS Help

So I need the *if* block because of the control command for moving forwards.


"These are the old days, the glory days...they're back."

Offline

 

#5 2007-07-28 15:32:49

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: FPS Help

Change it to a wait until block.

When I recieve [broadcast]
wait until (key pressed)
(Spawn new monster)


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#6 2007-07-28 21:03:22

Sawman3
Scratcher
Registered: 2007-07-19
Posts: 97

Re: FPS Help

thanx--im an idiot for not thinking of that...and it'll definently be smoother than what i have set up now.  thanx


"These are the old days, the glory days...they're back."

Offline

 

#7 2007-07-29 11:58:20

DrJim
Scratcher
Registered: 2007-05-26
Posts: 100+

Re: FPS Help

Sawman3 wrote:

thanx--im an idiot for not thinking of that...

You're only an idiot if you keep banging your head against a wall when there is help available.  Frequently the most obvious things - in hindsight - are the most difficult to see.

Offline

 

#8 2007-08-01 18:09:55

Sawman3
Scratcher
Registered: 2007-07-19
Posts: 97

Re: FPS Help

lol. thanx.


"These are the old days, the glory days...they're back."

Offline

 

#9 2007-08-01 20:48:45

AngelEyra
Scratcher
Registered: 2007-07-19
Posts: 100+

Re: FPS Help

Well, I guess I know that there's a "wait until" block now  tongue .


AngelEyra's . MyScratchR . Blog
Think with portals
Sorry, Companion Cube... I didn't mean to...

Offline

 

#10 2007-08-04 20:56:21

Sawman3
Scratcher
Registered: 2007-07-19
Posts: 97

Re: FPS Help

haha...good


"These are the old days, the glory days...they're back."

Offline

 

#11 2007-08-04 21:52:58

mel500
Scratcher
Registered: 2007-05-18
Posts: 1

Re: FPS Help

hi so how do you use broadccast.  roll   smile  please help me

Offline

 

#12 2007-08-04 22:19:23

natalie
Scratch Team
Registered: 2007-03-07
Posts: 100+

Re: FPS Help

For help with broadcast, please see: http://scratch.mit.edu/forums/viewtopic.php?pid=5019#p5019

Offline

 

#13 2007-08-05 14:11:58

Sawman3
Scratcher
Registered: 2007-07-19
Posts: 97

Re: FPS Help

also if you dont want to watch a tutorial: for a function on a sprite (for example, when key right arrow pressed) select the block that says *broadcast* followed by a blank space the word new.  type in whatever you want the name of that broadcast to be.  then for another sprite, or even the same one, you can choose a *when I receive (broadcast)* block and have it perform whatever action you want when it revieves that message.  in my experience, they seem to work smoother than variable manipulations and are more versatile.  Hope that helps!


"These are the old days, the glory days...they're back."

Offline

 

Board footer