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
Shooting Help
Started by hubbardh, May 28 2012 03:17 PM
4 replies to this topic
#1
Posted 28 May 2012 - 03:17 PM
#3
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
Enemy object
That should do it.
-Java
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.
#4
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
#5
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 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











