【GameMaker】 Zelda Style Views

Information about object: obj_player
Sprite: spr_player
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Step Event:
execute code:

dx = (keyboard_check(vk_right) - keyboard_check(vk_left)) * 4
dy = (keyboard_check(vk_down) - keyboard_check(vk_up)) * 4
if !place_meeting(x+dx,y,obj_solid) x += dx
if !place_meeting(x,y+dy,obj_solid) y += dy    


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

view_enabled[0] = true;
view_visible[0] = true;

view_wview[0]=240;
view_hview[0]=160;
view_xport[0]=0;//set position of port
view_yport[0]=0;
view_wport[0]=240;//set size of port
view_hport[0]=160;






view_x = view_xview[0];
view_y = view_yview[0];
view_x1 = view_x;
view_y1 = view_y;
view_xspeed = 16; // x movement speed of view
view_yspeed = 8; // y movement speed of view
Step Event:
execute code:

if obj_player.x > view_x + view_wview[0] view_x += view_wview[0];
if obj_player.x < view_x view_x -= view_wview[0];
if obj_player.y > view_y + view_hview[0] view_y += view_hview[0];
if obj_player.y < view_y view_y -= view_hview[0];

if view_x1 < view_x view_x1 = min(view_x,view_x1 + view_xspeed);
if view_x1 > view_x view_x1 = max(view_x,view_x1 - view_xspeed);
if view_y1 < view_y view_y1 = min(view_y,view_y1 + view_yspeed);
if view_y1 > view_y view_y1 = max(view_y,view_y1 - view_yspeed);

view_xview[0] = view_x1;
view_yview[0] = view_y1;

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 *