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

#1 2011-04-28 19:31:49

seraine
New Scratcher
Registered: 2011-04-27
Posts: 8

Shooter Problem.

When I put in a fairly normal script that looks something like this onto the bullet sprite:

[blocks]<when green flag clicked>
<go to[ gun]
<show>
<repeat until><touching[ << enemy <or> edge >>
<move( 50 )steps>
<wait( 0.01 )secsc>
<if><touching[ edge]>
<broadcast[ edgetouched]>
<hide>
<change{ enemy health }by( -15][/blocks]

The broadcast edge touched is so the enemy doesn't lose health if you hit the edge. However, this works like it should.

But if the enemy has a script that looks like this:

[blocks]<when green flag clicked>
<show>
<repeat until><( <{ enemy health }> <<> 0 )>
<point towards( hero
<move( 4 )steps>
<wait( 0.05 )secsc>
<switch to costume[ dead[/blocks]

It now works approximately 30-70% of the time. I know it's caused by the movement script, but frankly I have no idea how to fix this.

Any ideas?

Offline

 

#2 2011-04-28 19:38:19

seraine
New Scratcher
Registered: 2011-04-27
Posts: 8

Re: Shooter Problem.

Also, by the movement script, I mean if I take out only the move 4 steps part, it still works right. But if the move 4 steps is in the script, it no longer works right.

Offline

 

#3 2011-04-28 20:13:15

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Shooter Problem.

That's an interesting problem...would you mind posting the project so I can take a look at it?


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#4 2011-04-28 21:18:01

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

Re: Shooter Problem.

The problem is probably that the bullet is moving at 50 step intervals and skipping right over the enemy.


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

Offline

 

#5 2011-04-28 21:21:47

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Shooter Problem.

MoreGamesNow wrote:

The problem is probably that the bullet is moving at 50 step intervals and skipping right over the enemy.

This is most likely the problem.  I suggest replacing the "move 50 steps" block with:
http://i56.tinypic.com/2niyvq.gif
Now it checks at 10 step intervals whether to keep going or not.


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#6 2011-04-28 21:26:54

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

Re: Shooter Problem.

What Kileymeister said, but the "10 steps" part should be the length of the bullet + minimum dimensions of the enemy -1 (or just length of the bullet to be safe)


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

Offline

 

#7 2011-04-28 22:05:26

seraine
New Scratcher
Registered: 2011-04-27
Posts: 8

Re: Shooter Problem.

Thank you! I had never though of that. I tried out your suggestion and it worked out great. Again, thank you!

Offline

 

Board footer