I Wanna Be The Forums!

Please login or register.

Login with username, password and session length
Advanced search  

News:

Chat button has been eaten. Click here to join in the idling fun!

Author Topic: Game creating help - shoot in all directions (not literally all, but a lot)  (Read 6204 times)

Ingredient

  • Newbie
  • *
  • Posts: 1
    • View Profile

Okay, this isn't a long term I need help with my fangame thing, it's just a simple coding question. I'm semi-noobish with coding, and I really don't know how some fangames have like a boss shoot a circle of delicious fruit. (relax, I'm not going to be like every fangame and use  :fruit: for my only attack. Seriously.) I know I could possibly do it with direction... I'm using gamemaker btw. I was thinking something like:
shot.direction = d;
for(d=0;d<360;d+1) and then the boss doing:
instance_create(x,y,shot) over and over in step, maybe an alarm for balancing it... but that would make a circle shooting repeatedly, instead of the entire circle at once. Sorry, I know that I'm not making any sense, and that people aren't really going to be able to help me, and that I should know this, and that I'm an idiot, and that I should quit coding, IWBTG, computers, and life, but seriously... help?

Thanks!
Logged

ValDenStudios

  • Jr. Member
  • **
  • Posts: 68
    • View Profile

Okay, this isn't a long term I need help with my fangame thing, it's just a simple coding question. I'm semi-noobish with coding, and I really don't know how some fangames have like a boss shoot a circle of delicious fruit. (relax, I'm not going to be like every fangame and use  :fruit: for my only attack. Seriously.) I know I could possibly do it with direction... I'm using gamemaker btw. I was thinking something like:
shot.direction = d;
for(d=0;d<360;d+1) and then the boss doing:
instance_create(x,y,shot) over and over in step, maybe an alarm for balancing it... but that would make a circle shooting repeatedly, instead of the entire circle at once. Sorry, I know that I'm not making any sense, and that people aren't really going to be able to help me, and that I should know this, and that I'm an idiot, and that I should quit coding, IWBTG, computers, and life, but seriously... help?

Thanks!
If I understood your problem correctly this should work:

for (i = 0; i < 360; i += 1) {
    a = instance_create(x,y,shot)
    a.speed = 8
    a.direction = i
}

This should give you a shooting circle let me explain:
a is the ID that has the object shot which just got created there
change a.speed to a speed of your choice (pixel per frame)
change i += 1 to anything you want between 0 and 360, it will change the distance between the shots!
Hope I could help
Logged