GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2011-02-20 05:17:38

Jimmynator
Member
Registered: 2011-02-19
Posts: 2

drawing deep/high backgrounds

I made a script (I also submitted it to GMLscripts.com):

Expand/*
**  Usage:
**      draw_background_depth_layer(background,x,y,ratio,view);
**
**  Arguments:
**      background          Background to draw, background.
**      x                   X coordinate where (background_center_x = view_center_x), real.
**      y                   Y coordinate where (background_center_y = view_center_y), real.
**      ratio               Movement ratio of the background, real.
**      view                Number of the view to use, real.
**
**  Notes:
**      The background's center is always drawn at (x,y) when the center of the view is (x,y).
**      
**      Ratio notes:
**      (if ratio < 0): strange reversed movement, not very useful.
**      (if ratio = 0): background follows view.
**      (if 0 < ratio < 1): slow-moving background.
**      (if ratio = 1): static background.
**      (if ratio > 1): fast-moving background.
**
**  GMLscripts.com
*/
{
    var r,bx,by,bw,bh,dx,dy,vx,vy,vw,vh;
    r = 1-argument3;
    bw = background_get_width(argument0);
    bh = background_get_height(argument0);
    dx = argument1;
    dy = argument2;
    vw = view_wview[argument4];
    vh = view_hview[argument4];
    vx = view_xview[argument4]-dx;
    vy = view_yview[argument4]-dy;
    bx = ((vx+vw/2)*r)-bw/2+dx;
    by = ((vy+vh/2)*r)-bh/2+dy;
    draw_background(argument0,bx,by);
}

Last edited by Jimmynator (2011-03-31 11:46:25)

Offline

#2 2011-02-20 15:18:40

xot
Administrator
Registered: 2007-08-18
Posts: 1,240

Re: drawing deep/high backgrounds

Welcome to the GMLscripts.com forums! This is a really great idea for a script. Thanks for the submission.


Abusing forum power since 1986.

Offline

#3 2011-03-31 11:36:29

Jimmynator
Member
Registered: 2011-02-19
Posts: 2

Re: drawing deep/high backgrounds

Are you going to put this code online?
It can ba also done with sprites, and it's really fast.

Note: if you are going to post it you should change the name, it's too long.

Offline

Board footer

Powered by FluxBB