Jump to content


Photo

Object created every second


  • Please log in to reply
4 replies to this topic

#1 naseem142

naseem142

    GMC Member

  • New Member
  • 100 posts
  • Version:GM8

Posted 03 June 2012 - 10:29 AM

I want an enemy_object to create a bullet every 1 second ( in actions if possible ),
I already have the enemy script and the bullet-damage script.

Please help

Thanks :D
  • 0

#2 Super Lala

Super Lala

    GMC Member

  • New Member
  • 95 posts

Posted 03 June 2012 - 10:35 AM

To make things happen on regular intervals, alarms are a good idea.

In the create event, use "Set Alarm" in the main2 tab set an alarm (alarm0) to 30.
Add an "Alarm 0" event and in it, make the enemy fire a bullet and again set alarm0 to 30.

That setup makes the enemy have a 1 second timer that fires the bullet and resets the timer to 1 second so it will continue firing.

If you don't know why I chose 30, in the "Settings" tab in your room, you will see that "Speed" is set to 30. That means 30 frames per second. Alarms use frames.
  • 0

#3 SmithyK

SmithyK

    SmithyK Games

  • New Member
  • 7 posts
  • Version:GM8

Posted 03 June 2012 - 10:43 AM

obj_enemy
create event - set alarm[0] to 30 (main2 tab)
alarm[0] event - instance create, obj_enemy.x, obj_enemy.y, obj_bullet (main1 tab). Set alarm[0] to 30 (main2 tab).

obj_bullet
create event - Put here what you want the bullet to do. If you want it to shoot in a random direction, add: move towards point, random(360), random(360), 3 (move tab). You can change the 3 to anything you want, this is the speed of the bullet.

The names of the objects may differ, so just change them as required.
  • 0

#4 naseem142

naseem142

    GMC Member

  • New Member
  • 100 posts
  • Version:GM8

Posted 03 June 2012 - 10:46 AM

To make things happen on regular intervals, alarms are a good idea.

In the create event, use "Set Alarm" in the main2 tab set an alarm (alarm0) to 30.
Add an "Alarm 0" event and in it, make the enemy fire a bullet and again set alarm0 to 30.

That setup makes the enemy have a 1 second timer that fires the bullet and resets the timer to 1 second so it will continue firing.

If you don't know why I chose 30, in the "Settings" tab in your room, you will see that "Speed" is set to 30. That means 30 frames per second. Alarms use frames.


Is this right? please tell me if im wrong :S

http://i1081.photobucket.com/albums/j360/naseem142/sarggggggggggg.png
  • 0

#5 creators124

creators124

    awesomeliciousmember

  • GMC Member
  • 866 posts
  • Version:GM8

Posted 03 June 2012 - 11:00 AM


To make things happen on regular intervals, alarms are a good idea.

In the create event, use "Set Alarm" in the main2 tab set an alarm (alarm0) to 30.
Add an "Alarm 0" event and in it, make the enemy fire a bullet and again set alarm0 to 30.

That setup makes the enemy have a 1 second timer that fires the bullet and resets the timer to 1 second so it will continue firing.

If you don't know why I chose 30, in the "Settings" tab in your room, you will see that "Speed" is set to 30. That means 30 frames per second. Alarms use frames.


Is this right? please tell me if im wrong :S

http://i1081.photobu...ggggggggggg.png

yes but if you have many different room_speeds(and don't bother doing the math) use room_speed* seconds to get the desired number of seconds without doing the math.:P
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users