【GameMaker】 Top Down Football

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

motion_set(random(360),2);
Step Event:
execute code:

inst=instance_nearest(x,y,obj_player);//get id of nearest player

if (keyboard_check(ord('A')))  {inst.x-=5;} //make inst move
if (keyboard_check(ord('D')))  {inst.x+=5;} 
if (keyboard_check(ord('W')))  {inst.y-=5;} 
if (keyboard_check(ord('S')))  {inst.y+=5;}
Collision Event with object obj_border:
execute code:

hspeed*=-1;
vspeed*=-1;
Collision Event with object obj_player:
execute code:

hspeed*=-1;
vspeed*=-1;

No comments:

Top 3 UX Design Articles of 2024 to Remember

Based on most subscriptions ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­...

Contact Form

Name

Email *

Message *