Windows Question on Shooting straight via Bullet Hell game

R

RoscoeIII

Guest
Hello, I'm brand new to GML and don't know much about the coding. I've tried looking up countless tutorials and can't find not ONE that can show me how to get an image to just shoot straight, like that of a bullet hell game.

I'm testing the waters and for some reason in my Test, my bullet object wont shoot straight instead and shoots to the right of the player object and I cant find any code to change that and have it just shoot straight. Any help would be appreciative.

Here is the code attached the the Player Object under the Event "Space-Press." :
beam1 = instance_create(x,y,obj_beam1);
beam1.direction = image_angle;
beam1.image_angle = image_angle;
beam1.speed = 15;

player object moves up and down and head of the object always points forward on the Y axis, Bullet shoots to the right every time, I want it to go straight.

Thank You.
 
You are setting the direction to the image_angle. The image_angle always starts at zero, which GMS treats as being the right side. If the shooting object was moving down - it would need to fire at 270 degree's, as GMS treats angles counter clockwise

EDIT: Think of a circle - the top half is 0 (the right side) to 180 (left side). The bottom half is 180 to 360
 

Shawn Basnett

Discount Dev
beam1.image_angle = image_angle;
What are you doing here?



Side note; A workaround that might work:


Try setting a "dir" variable in your player's create event

In the player STEP event, have the key for right set the variable to 1, and have the key for left set the variable to negative one.

Doing this means you can set "beam1.direction = dir"
 
R

RoscoeIII

Guest
You are setting the direction to the image_angle. The image_angle always starts at zero, which GMS treats as being the right side. If the shooting object was moving down - it would need to fire at 270 degree's, as GMS treats angles counter clockwise

EDIT: Think of a circle - the top half is 0 (the right side) to 180 (left side). The bottom half is 180 to 360
So I need to make sure the Beam1 isn't connected to the Image Angle. However, How do I get the Beam to shoot straight Forward no matter where the Player object moves, what code am I missing/doing incorrectly to make it so?
 
R

RoscoeIII

Guest
What are you doing here?



Side note; A workaround that might work:


Try setting a "dir" variable in your player's create event

In the player STEP event, have the key for right set the variable to 1, and have the key for left set the variable to negative one.

Doing this means you can set "beam1.direction = dir"

As for the code you quoted, It was in a Tutorial I tried as a last resort to see if it would change anything from what i had previously. It did not.

I'll try the example you gave to see what fruit it bears. Thank you.
 
R

RoscoeIII

Guest
What are you doing here?



Side note; A workaround that might work:


Try setting a "dir" variable in your player's create event

In the player STEP event, have the key for right set the variable to 1, and have the key for left set the variable to negative one.

Doing this means you can set "beam1.direction = dir"
As I am still new to this can you explain to me in detail how I would go about that in my events? I would just go to either of my Movement events and type "dir = 1," and "dir = -1," respectively? As for my Movement Events their set to "Keyboard Event For <left,Right,Up and Down> each with their own value on how they should move on the axis.
left: x-=3;
right: x+=3;
Up: y-=3;
Down: y+=3;

this is how I have them set up on Keyboard Event.
 
Top