【GameMaker】 Duck Hunt Game Remake

Information about object: obj_duck
Sprite: spr_duck
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

dir=choose("side","up");//choose a state
if dir="side"//if side
{
x=-50;//set just off of screen
y=irandom_range(100,room_height-100);//choose a ra
hspeed=1+random(3);//set random speed
}
if dir="up"//if up
{

x=irandom_range(50,room_width-50);//choose random position
y=room_height+50; //set just off of screen
dir=random(180);//set a random direction 
spd=1+random(3);//set a random speed
motion_set(dir,spd);//applydirection and speed
}

Step Event:
execute code:

//destroy if off screen
if x>room_width+100
{
instance_destroy();
}
if y<-50
{
instance_destroy();
}




Information about object: obj_gun
Sprite: spr_gun Solid: false Visible: true Depth: 0 Persistent: false Parent: Children: Mask:
No Physics Object
Create Event:
execute code:

alarm[0]=100+random(room_speed*3);//set alarm to spawn duck
score=0;
Alarm Event for alarm 0:
execute code:

instance_create(0,0,obj_duck);//spawn a duck
alarm[0]=100+random(room_speed*3);//set spawn alarm agin
Step Event:
execute code:

//update position
x=mouse_x;
y=mouse_y;

if mouse_check_button_pressed(mb_left) && position_meeting(x,y,obj_duck)//if mouse pressed
{
score+=10;
var inst=instance_position(x,y,obj_duck);
with (inst)
{
instance_destroy();
}
}
Draw Event:
execute code:

draw_self();
draw_text(20,20,"Score "+string(score));

No comments:

Renowned Water Expert Reynold Aquino Offers Exclusive Water Softener Discounts

Los Angeles, California - November 21, 2024 - World-renowned water expert Reynold Aquino is excited to announce exclusive discounts on prem...

Contact Form

Name

Email *

Message *