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

#1 2007-08-25 21:50:34

PaulMathews
Scratcher
Registered: 2007-08-08
Posts: 4

Moveing ship and fireing at the same time.

I have a sprite and I can move it around with the arrow keys and now I want it to start shooting. I know its possible to do as I want it to, because I have at least seen  360 shooting.

I want to be ale to move my ship around the screen and using the mouse cursor shoot in 360* dirrections at enemy ships, I don't want the ship to move really fast,  just 2x speed or -2 times which it is now doing speed wise.  I am just a little stumped on how to do this, I have looked at some other code and am trying.

I have made a little cross hair spite and its on the screen now, but I can't control it or anything, working on it.


If you could give me a few pointers that would be cool, just new to this But its fun so far  smile


Thanks.

Last edited by PaulMathews (2007-08-25 21:52:09)

Offline

 

#2 2007-08-26 12:30:23

beny
Scratcher
Registered: 2007-07-24
Posts: 100+

Re: Moveing ship and fireing at the same time.

crosshair:
when flag clicked
forever
*go to x: mouse x y: mouse y

now when you do the green flag the crosshair will always go to the mouse
sorry if that isnt what you wanted


more people like the letter B than the letter A!
i'm going for 250 posts!

Offline

 

#3 2007-08-26 12:48:00

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Moveing ship and fireing at the same time.

Your forever loop should have a small delay in it, to keep the loop from causing scheduling problems for other parts of the code.  Updating a cursor location 20 times a second is usually plenty.

when greenflag
forever
   goto x: mouse x y: mouse y
   wait 0.05 seconds

Offline

 

#4 2007-09-06 15:34:40

dinther
Scratcher
Registered: 2007-08-22
Posts: 19

Re: Moveing ship and fireing at the same time.

It sounds like you are doing an asteroids game. Maybe my demo project has some solutions you could use. http://scratch.mit.edu/projects/dinther/34522


Find out what it is like to steer large ships into the Port of Rotterdam in ShipSim http://scratch.mit.edu/projects/dinther/32891

Offline

 

Board footer