GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 Re: Script News & Announcements » Forums Restored ... mostly » 2009-03-04 16:35:44

http://www.gmlscripts.com/forums/viewtopic.php?pid=1559 -- Burunduk -- Topic: draw_sprite_origin
http://www.gmlscripts.com/forums/viewtopic.php?pid=1560 -- Burunduk -- Topic: ds_grid_row

Fixed.

The others are all script mistakes, most of which concern variable declarations.
I'm sure you won't have any problems finding the mistakes again, if you keep that list of problematic scripts.
(motion_blur, normal_detect, sprite_desaturate)

#5 Script Submission » draw_sprite_origin » 2009-02-11 12:52:35

Burunduk
Replies: 3

Sorry no long descriptions this time. Here are the two versions:

Expand/*
**  Usage:
**      draw_sprite_origin( sprite, image, x, y, angle, hoff, voff )
**
**  Arguments:
**      0-3       like in draw_sprite
**      angle     rotation
**      hoff      desired horizontal offset of the origin
**      voff      desired vertical offset of the origin
**
**  Example:
**      draw_sprite_origin( sprite_index, image_index, x, y, direction, 0, 0 )
**
**  Returns:
**      nothing
**
**  Notes:
**      Sometimes, you cannot rotate your sprites using their origins
**      Then you use this function
**      d3d does not have to be initiated
**
**  Burunduk
*/
var hoff, voff;

// calculate offsets based on origin
hoff = argument5  - sprite_get_xoffset(argument0);
voff = argument6 - sprite_get_yoffset(argument0);

// reset
d3d_transform_set_identity()

// offset
d3d_transform_add_translation(-hoff, -voff, 0)

// rotate
d3d_transform_add_rotation_z(argument4)

// move to right position in room
d3d_transform_add_translation(argument2,argument3,0)

//draw sprite
draw_sprite(argument0, argument1, 0,0);

// reset
d3d_transform_set_identity()
Expand/*
**  Usage:
**      draw_sprite_origin_ext(sprite, subimg, x, y, xscale, yscale, rot, color, alpha, hoff, voff )
**
**  Arguments:
**      0-8       same as draw_sprite_ext
**      hoff      desired horizontal offset of the origin
**      voff      desired vertical offset of the origin
**
**  Example:
**      draw_sprite_origin_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, direction, c_white, 1, 0, 0 )
**
**  Returns:
**      nothing
**
**  Notes:
**      Sometimes, you cannot rotate your sprites using their origins
**      Then you use this function
**      The actual origin has to be at 0,0 for this version to work
**      d3d does not have to be initiated
**
**  Burunduk
*/
var hoff, voff;

// calculate offsets based on origin
hoff = argument9  - sprite_get_xoffset(argument0);
voff = argument10 - sprite_get_yoffset(argument0);

// reset
d3d_transform_set_identity()

// offset
d3d_transform_add_translation(-hoff, -voff, 0)

// rotate
d3d_transform_add_rotation_z(argument6)

// move to right position in room
d3d_transform_add_translation(argument2,argument3,0)

//draw sprite
draw_sprite_ext(argument0, argument1, 0,0, argument4, argument5, 0, argument7, argument8);

// reset
d3d_transform_set_identity()

#6 Script Submission » ds_grid_row » 2009-02-11 12:52:35

Burunduk
Replies: 0

Some code for when you need to fill in a ds_grid row all at once.

Expand// fill in a ds_grid row with arguments
// 0 = ds var | 1 = current row | 2 = width | 3 = column 1... etc

var i;

// GRIDS START WITH 0
for(i = 0; i <= argument2; i+=1)
{
    ds_grid_set(argument0, i, argument1, argument[i+3]);
}

Example usage.

Expand//================================================================================
// PROPERTIES:
//================================================================================
// weapon name | assoc projectile | firing speed | spread | max projectiles |  ..?
//                                    (p/s)         (deg)    0 = unlimited
//================================================================================

var WG,w,h;

// GRIDS START AT 0
// Meaning, 0 counts as 1 when setting w&h
// All FORS must be < NOT <=
w = 5; // number of properties
h = 6; // number of weapons


WG = ds_grid_create(w,h);



// bullets
row(WG,0,w,     "gatling",  p_bullet,   4,  5, 0);
row(WG,1,w,     "machine",  p_bullet,   6,  10, 0);
row(WG,2,w,     "chain",    p_bullet,   8,  15, 0);

// flak
row(WG,3,w,     "shotgun",  p_flak,     2,   40, 8);
row(WG,4,w,     "dblsg",    p_flak,     1.5, 50, 16);
row(WG,5,w,     "flkcnn",   p_flak,     .75, 35, 20);

// rocket
row(WG,3,w,     "rocket",  p_rocket,    4,  40, 6);

Board footer

Powered by FluxBB