Jump to content


Photo

Shooting Help


  • Please log in to reply
4 replies to this topic

#1 hubbardh

hubbardh

    GMC Member

  • New Member
  • 2 posts
  • Version:GM8

Posted 28 May 2012 - 03:17 PM

Hey i'm making a game and i dont know how 2 make my character shoot in the direstion he's facing. i'm having the same problem with jumping and dying and being hit. i'd really appreciate some help
  • 0

#2 YellowAfterlife

YellowAfterlife

    GMC Member

  • Global Moderators
  • 3530 posts
  • Version:GM:Studio

Posted 28 May 2012 - 03:21 PM

Note: please care to make topic in appropriate section next time. See Rules for more information regarding usage of this forum.
  • 0

#3 oopl.x.beast

oopl.x.beast

    GMC Member

  • GMC Member
  • 77 posts
  • Version:GM8

Posted 28 May 2012 - 03:48 PM

So basically, you need help with the most important aspects of the game? I'll give you a rough outline of the code required and you can ask questions about what you don't get.

Player object
//Create Event:

hp = 100;
maxhp = 100;
canShoot = true;

//Step Event:

if(hp<=0){
    game_restart();
}

if(keyboard_check_pressed(vk_space)){
    yy = yprevious;
    y += 5;
    while(y!=yy){
    y -= .5;
    }
}
if(mouse_check_button_pressed(mb_left) && canShoot==true){
    canShoot = false;
    bullet = instance_create(x,y,obj_bullet)
    bullet.direction = direction;
    bullet.speed = 10;
}

//Alarm 0 Event:

canShoot = true;

//Collision Event(with obj_bullet)

hp -= 10;

Enemy object
//Create Event: 

canShoot = true;
hp = 100;
maxhp = 100;

//Step Event:

if(canShoot){
    canShoot = false;
    bullet = instance_create(x,y,obj_bullet);
    bullet.direction = direction;
    bullet.speed = 10;
    alarm[0] = room_speed*1.5;
}

//Alarm 0 Event:

canShoot = true;

//Collision Event(with Bullet object)

hp -= 10;

That should do it.

-Java

Edited by oopl.x.beast, 28 May 2012 - 03:50 PM.

  • 0

#4 hubbardh

hubbardh

    GMC Member

  • New Member
  • 2 posts
  • Version:GM8

Posted 28 May 2012 - 05:40 PM

Thnx 4 da code but i figured it out while i wasnt looking at dis thing but i got an nu problem my character only shoots once
  • 0

#5 aaabbbccc

aaabbbccc

    GMC Member

  • GMC Member
  • 525 posts

Posted 28 May 2012 - 09:23 PM

Thnx 4 da code but i figured it out while i wasnt looking at dis thing but i got an nu problem my character only shoots once


Just a more simple version of what he was doing

Right release (or whatever key it is)

if canshoot = true
{
instance_create(x,y,obj_bullet
canshoot = false
alarm[1]=room_speed*1
}

alarm1
canshoot = true

bullet create
image_angle = direction
move_towards_point(mouse_x,mouse_y,speed)

This will work.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users