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

#1 2012-08-18 15:51:20

Zangooser
Scratcher
Registered: 2012-03-18
Posts: 1000+

How to make something continue in a direction

Okay, so the game I'm designing is a point-and-click shooter-type-thing. You're fixed in the middle of the screen, the enemies come from offscreen and towards you. You move your mouse and click either on the enemy or in its direction. Let's call the thing that hits and 'kills' the enemy "Bullet". So far, I've been able to make bullet zoom over to the place that's been clicked and kill the enemy, if there's one there. My problem is, the farthest the bullet will go is to where you clicked, so if you clicked just in front of the enemy (not on it or behind it) the bullet will not hit the enemy. I want to know how I can make the bullet sense if it did not hit the enemy and continue in the same direction until it either (a) hits the enemy or (b) touches the edge of the screen.

I am willing to upload the game to show you how far I've gotten, if you'd like to see the thing itself, rather than have it described to you.

Thanks in advance!


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/O0efo.png&link2=http://i.imgur.com/B1KzK.png

Offline

 

#2 2012-08-18 15:56:52

gooeygoo
Scratcher
Registered: 2012-05-07
Posts: 82

Re: How to make something continue in a direction

First of all, you might want this script:

when gf clicked
forever
point in direction [mouse-pointer v]
Now, you might want to make some enemies, if it's a simple shoot game, make ten enemies and add this to each one.
when gf clicked
set [speed v] to [1]
forever
point in direction [player v]
move (speed) steps
now, for the speed script
when gf clicked
forever
wait (seconds until enemies get faster) secs
change [speed v] by [9]
so that's one way, but here's another
when gf clicked
forever
go to x(x) y(y)
point towards [player v]
set [Hit v] to (0)
repeat until <touching [player v]> or <(Hit) = [1]>
move (speed) steps
if <touching [bullet v]>
set [Hit v] to (1)
hide
end
if <touching [player v]>
change [life v] by (-1)
end
end
end 
wait (pick random (1) to (3)) secs
show
end

Last edited by gooeygoo (2012-08-18 16:17:02)


Play meh games, dont beh shy!!!
http://scratch.mit.edu/users/gooeygoo

Offline

 

#3 2012-08-18 16:41:29

Zangooser
Scratcher
Registered: 2012-03-18
Posts: 1000+

Re: How to make something continue in a direction

@ gooeygoo
Like I said, I've already started designing the game, and I've gotten pretty far on it. I won't be able to incorporate the first three scripts without changing nearly every part of the game I have done so far.

As for the last script: if I were to use it, what sprite would it go on? The enemy? The player? The bullet?


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/O0efo.png&amp;link2=http://i.imgur.com/B1KzK.png

Offline

 

#4 2012-08-18 16:43:13

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: How to make something continue in a direction

Another way:  download this and look at the one-player scripts.  Look at the blue bullet's scripts, I mean.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#5 2012-08-18 17:17:25

Zangooser
Scratcher
Registered: 2012-03-18
Posts: 1000+

Re: How to make something continue in a direction

Firedrake969 wrote:

Another way:  download this and look at the one-player scripts.  Look at the blue bullet's scripts, I mean.

It works! Thank you! :D

Reporting topic to be closed~


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/O0efo.png&amp;link2=http://i.imgur.com/B1KzK.png

Offline

 

#6 2012-08-18 17:19:19

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: How to make something continue in a direction

Zangooser wrote:

Firedrake969 wrote:

Another way:  download this and look at the one-player scripts.  Look at the blue bullet's scripts, I mean.

It works! Thank you!  big_smile

Reporting topic to be closed~

Ok thanks.  I make a lot of little games that turn out to be tutorials.... XD


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#7 2012-08-18 17:40:03

cheddargirl
Scratch Team
Registered: 2008-09-15
Posts: 1000+

Re: How to make something continue in a direction

Closed by request.


http://i.imgur.com/8QRYx.png
Everything is better when you add a little cheddar, because when you have cheese your life is at ease  smile

Offline

 

Board footer