Edited by _257502, 27 July 2012 - 04:21 PM.
megaman cannon
#1
Posted 22 June 2012 - 05:23 AM
#2
Posted 22 June 2012 - 09:00 AM
I'm working on my game and I want to make an enemy that shoots like the cannons in the megaman series. That every x seconds they fire a shot in an arc that goes right to where megaman was when it was shot. I would do this my self but I actually have no idea how to even start.
Create objects for the megaman, the enemy, and the bullet. I'll call them obj_megaman, obj_enemy, obj_bullet.
every x seconds they fire a shot
obj_enemy CREATE EVENT:
seconds = 4; alarm[0] = seconds*room_speed;You may replace "4" with however many seconds you want this interval to be.
obj_enemy ALARM 0 EVENT:
instance_create(x,y,obj_bullet); alarm[0] = seconds*room_speed;
I'm not sure what you mean by "an arc", but I will give you code that shoots it at any angle in a straight path towards megaman.in an arc that goes right to where megaman was
obj_bullet CREATE EVENT:
direction = point_direction(x,y,obj_megaman.x,obj_megaman.y); speed = 5;
That's it per what you described. Now with just the code above, eventually your game will slow down, as you want to delete these bullets at a certain point. Here is code to delete the bullet if it goes out of the room:
obj_bullet STEP EVENT:
if (x>room_width or x<0 or y>room_height or y<0) instance_destroy();
Edited by Yumegiwa, 22 June 2012 - 09:03 AM.
#3
Posted 22 June 2012 - 11:29 AM
If is that so, you will need oldX and oldY vars to store the original player position.
Probably the arc would be made by some funcion like: f(x) = ax˛ + bx + c
#4
Posted 22 June 2012 - 04:53 PM
For what I understand by arc... it seems to be like a angrybird shoot when the shoot goes up and fall on the player position was when the shoot was fired.
If is that so, you will need oldX and oldY vars to store the original player position.
Probably the arc would be made by some funcion like: f(x) = ax² + bx + c
Yes, like shooting a basketball. But as far as that code goes i have no idea, i figured that maybe i would make a code for every 10 pixels to check where he is and change the hspeed and vspeed based on his position but I don't think that would be a good code considering it would probably have over 300 lines if you count all the finding positions and the h and vspeed adjustments.
I know how to make a simple cannon that shoots straight, i'm WAY past that level now. Think of it as compensating for bullet drop in real life, you would aim up to hit the same spot like... a CANNON
exe.
http://www.youtube.com/watch?v=OWvj_RPGO-Q
at 1:39
and
http://www.youtube.com/watch?v=fYhiDapnR9s
at 0:49
Edited by _257502, 22 June 2012 - 05:01 PM.
#5
Posted 22 June 2012 - 05:01 PM
Edited by niiiiick, 22 June 2012 - 05:02 PM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











