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

#1 2011-10-04 15:19:03

toastythecat
Scratcher
Registered: 2009-05-01
Posts: 10

scrolling enemy shooting projectiles

i am making a scrolling platformer/shooter and i need help getting the enemy to shoot bullets.

here are the scripts i use for the enemy to move.
http://i51.tinypic.com/2ivzgaf.gif


http://i49.tinypic.com/15notb9.png

Offline

 

#2 2011-10-04 17:21:51

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

Re: scrolling enemy shooting projectiles

Well...Do you understand trig, or not?  I can answer after you say.


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

Offline

 

#3 2011-10-04 17:45:51

TinkerZone
New Scratcher
Registered: 2011-08-25
Posts: 10

Re: scrolling enemy shooting projectiles

My question:  What will be the trigger for your enemy to shoot?  What I see is movement but nothing as an event trigger.  Will it be something random?  Will it be an object interaction? (such as the enemy sees your player object at x,y position) Will the enemy be efficient at targeting? (It knows where you are and can aim well) Or does it shoot towards you but may not be able to aim well? Do you plan on using real world physics? (Gravity, velocity, distance, resistance, factor x, factor y, factor z,.....)

These questions are important to how you code.

Offline

 

#4 2011-10-04 19:47:38

toastythecat
Scratcher
Registered: 2009-05-01
Posts: 10

Re: scrolling enemy shooting projectiles

TinkerZone wrote:

My question:  What will be the trigger for your enemy to shoot?  What I see is movement but nothing as an event trigger.  Will it be something random?  Will it be an object interaction? (such as the enemy sees your player object at x,y position) Will the enemy be efficient at targeting? (It knows where you are and can aim well) Or does it shoot towards you but may not be able to aim well? Do you plan on using real world physics? (Gravity, velocity, distance, resistance, factor x, factor y, factor z,.....)

These questions are important to how you code.

i want the bullet to be able to go to the enemy's scrollx position and make the bullet scroll forward. when the enemy is visible the bullet should appear on the enemy and scroll to the left until it reachs the edge and disappears. i also want to make diffrent enemies do diffrent things such as an enemy that drops a bomb and an enemy that shoots diagonally.

i was also planning on making the main player be able to jump like mario (press key to make the player jump. if holding key, make player jump higher) but i dont know how that will work.


http://i49.tinypic.com/15notb9.png

Offline

 

#5 2011-10-05 10:20:05

TinkerZone
New Scratcher
Registered: 2011-08-25
Posts: 10

Re: scrolling enemy shooting projectiles

First; script the bullets to go the your desired X,Y positions relative to the enemy and hide. The X,Y position must remain with the enemy, so if the enemy moves the script needs to change the position accordingly.
At the beginning of your game(or current scene) broadcast a message to set the bullet in its starting position.

When Green flag is pressed
broadcast setupBullet

When setupBullet is received
set var shooter to 0
Hide
repeat until shooter = 1
go to X position of enemy, Y position of enemy

At the moment you want the bullet to shoot broadcast a message to the bullet. When the message is received, make the bullet visible, and change the  position of it until it leaves the stage.
Something like:

When 'shoot' received,
set shooter to 1
show,
repeat until x <= -240
move -10 steps (change this for desired speed)
hide
set shooter to 0
broadcast setupBullet (this places the bullet into its ready position to use again.

I hope this helps. And is understandable.

If you need more help you could always email me: info (at) tinkerzone (dot) org

I am always willing to help.

Offline

 

#6 2011-10-05 11:56:13

toastythecat
Scratcher
Registered: 2009-05-01
Posts: 10

Re: scrolling enemy shooting projectiles

TinkerZone wrote:

First; script the bullets to go the your desired X,Y positions relative to the enemy and hide. The X,Y position must remain with the enemy, so if the enemy moves the script needs to change the position accordingly.
At the beginning of your game(or current scene) broadcast a message to set the bullet in its starting position.

When Green flag is pressed
broadcast setupBullet

When setupBullet is received
set var shooter to 0
Hide
repeat until shooter = 1
go to X position of enemy, Y position of enemy

At the moment you want the bullet to shoot broadcast a message to the bullet. When the message is received, make the bullet visible, and change the  position of it until it leaves the stage.
Something like:

When 'shoot' received,
set shooter to 1
show,
repeat until x <= -240
move -10 steps (change this for desired speed)
hide
set shooter to 0
broadcast setupBullet (this places the bullet into its ready position to use again.

I hope this helps. And is understandable.

If you need more help you could always email me: info (at) tinkerzone (dot) org

I am always willing to help.

ok. i found a diffrent way for the bullet to work.

http://i51.tinypic.com/wva4x2.gif

when the enemy is visible and broadcasts the bullet to shoot, the bullet will appear in the enemy's position and it will go to the left until it touches the left side.

the characters scrolling speed is 5. so if the player is running left while the bullet is going forward, the bullet will go the opposite direction the player is going by 5. so the bullet will go slower which makes its current x speed 2.

if the player is running right, the bullet will go faster.

if the player is not moving. the bullet goes into its normal speed.

that way the player will be able to dodge the bullets easily.

but thanks anyway for the the help.


http://i49.tinypic.com/15notb9.png

Offline

 

#7 2011-10-05 21:29:57

GameCentral
Scratcher
Registered: 2011-10-05
Posts: 100+

Re: scrolling enemy shooting projectiles

Nice Posts They do Help a lot
big_smile


http://i1237.photobucket.com/albums/ff468/sciteccf/gamecentral.gif
http://i.imgur.com/2RYxb.png

Offline

 

#8 2011-11-10 17:48:38

GameCentral
Scratcher
Registered: 2011-10-05
Posts: 100+

Re: scrolling enemy shooting projectiles

i do mean that these were helpful in making my own game


YAY!!! First post as a Scratcher not New Scratcher !!!YAY


http://i1237.photobucket.com/albums/ff468/sciteccf/gamecentral.gif
http://i.imgur.com/2RYxb.png

Offline

 

Board footer