A
AFD456
Guest
Hello everyone, I have 3 object in my game: Plane (oPlane), bullet (oBullet) and tube (oTube).
What I want to code is following... When I shoot a bullet out of the plane and the bullet meets with the tube I want to show only a part of the tube. And it kinda works, until when I move the plane (right or left) then the revealed part of the tube changes according to position of the plane. In other words It moves along with the plane. Which doesnt make sense to me. Here's the code:
oPlane
Create Event:
globalvar can_shoot;
can_shoot = true
Alarm Event for alarm 0:
can_shoot = true
Step Event:
if keyboard_check_pressed(vk_space)
{
if can_shoot == true
{
can_shoot = false
instance_create(x,y,oBullet)
oBullet.vspeed = -8
alarm[0] = 10
}
}
// movement control
if keyboard_check(vk_left)
{
if x > 10
{
x -= 10
}
}
if keyboard_check(vk_right)
{
if x < room_width-40
{
x += 10
}
}
oTube
Create Event:
globalvar hit, touch;
//hit = false
touch = noone
Step Event:
if (place_meeting(x,y,oBullet))
{
touch = place_meeting(x,y,oBullet)
with(oBullet)
{
instance_destroy()
}
}
Draw Event:
if touch != noone
{
draw_sprite_part(sprite_index, 0, touch.x, 0, 50, sprite_height, touch.x-25, y);
}
Thank you for your time and answers.
What I want to code is following... When I shoot a bullet out of the plane and the bullet meets with the tube I want to show only a part of the tube. And it kinda works, until when I move the plane (right or left) then the revealed part of the tube changes according to position of the plane. In other words It moves along with the plane. Which doesnt make sense to me. Here's the code:
oPlane
Create Event:
globalvar can_shoot;
can_shoot = true
Alarm Event for alarm 0:
can_shoot = true
Step Event:
if keyboard_check_pressed(vk_space)
{
if can_shoot == true
{
can_shoot = false
instance_create(x,y,oBullet)
oBullet.vspeed = -8
alarm[0] = 10
}
}
// movement control
if keyboard_check(vk_left)
{
if x > 10
{
x -= 10
}
}
if keyboard_check(vk_right)
{
if x < room_width-40
{
x += 10
}
}
oTube
Create Event:
globalvar hit, touch;
//hit = false
touch = noone
Step Event:
if (place_meeting(x,y,oBullet))
{
touch = place_meeting(x,y,oBullet)
with(oBullet)
{
instance_destroy()
}
}
Draw Event:
if touch != noone
{
draw_sprite_part(sprite_index, 0, touch.x, 0, 50, sprite_height, touch.x-25, y);
}
Thank you for your time and answers.