The codebox allows you to move, change, and draw while the program is testing the particle. This can be used to simulate the actions that it would go through when put into the game. It gives the options to move system functions such as emitters and attractors, and their properties. It also allows you to use the draw functions, and the particle functions. You can change the properties of particles and system functions while testing as well.
See particle system variables See particle system functions See limited functions See example codes |
Particle System variables allows you to use the current system in the codebox. These values are mostly simplified to make this easier. These variables can be used to change the current system, including the values in the tabs. It also supplies the variables for the parts of the system so you can use them. If you want to change the settings without changing the tab values, you can also use particle system functions in the codebox. | |
step | This is the number of steps since the code was executed, so each step the value is incremented by 1. It also starts at 1. You may want to use this to initiate the variables. This variable can also be changed. |
val[#] | These are the free variables. At default, the values are 0. The array is any number from 1 to 50. |
sys | This is the particle system variable that is used by default. |
prt[#] | The particles. You can use this for "part_type" functions for example. The array is for each particle(1-3). |
emt[#] att[#] chg[#] def[#] des[#] | Same as prt, but for the other functions.(#: 1-3) |
global. op_(size, speed, direction, etc.) _val(min, max, inc, wig, etc.)[#] global.op_(color, alpha, etc.) _val(1, 2, 3)[#] global.op_blend_valadd[#] etc. | The most complicated settings is for the particles. For each type of setting there is "global.op_", then there is its name of the setting, and finally "_val" followed by the 3 letter abbreviation for the individual option. Scale uses "valx" and "valy". Others besides alpha and color use min, max, inc, and wig. Orientation uses "valrel" for the relative value(1 or 0). Gravity uses "valamt" and "valdir". Finally, there are different methods for part_step and part_death, but be careful working with these, and be sure to have crash prevention on while you do. "global.op_part_step[#]" is the particle, and "_numb" added to it is the number emitted(a negative value is allowed). "part_death" is the same with 'step' changed to 'death'. Modifying the sprite values is not an option to prevent easy errors. Be sure to inlude the array for the particle! |
ex[#] ey[#] | The center point values for the emitter exclusively. |
global.e_(x1, x2, y1, y2, shape, distr)[#] | The emitter values. You may use the constants for the shape and distribution. |
global.a_(x, y, force, dist, kind, add)[#] | The attractor values. |
global.c_(x1, x2, y1, y2, shape, part1, part2, kind, mx, my)[#] | The changer values. The "mx" and "my" are the center points of the dimentions. |
global.df_(x1, x2, y1, y2, kind, friction, mx, my)[#] | The deflector values. |
global.ds_(x1, x2, y1, y2, shape, mx, my)[#] | The destroyer values |
The codebox supports mainly particle functions, math functions, and drawing functions. This can help to test the particle as it would change or how it would move in the game. You can use or change variables in the tabs, particularly if the tabs are set each step with the code. Otherwise, particle functions can change the particle. Warning: Particle systems and other parts of the system cannot be destroyed. So be carefull when creating any parts of the system. Refer to the GM manual for the list of particle functions and their action. For example: part_emitter_burst(sys,emt[1],prt[1],10); sys, emt, and prt are particle system variables. The function will burst using the settings set in the tabs. part_attractor_force(sys,att[1],global.a_force[1],global.a_dist[1],0,1); the global variables can be used from the tabs. They can also be changed by setting the variables to another value. part_system_position(sys,mouse_x,mouse_y); This draws the system relative to the mouse position. Particle functions cannot be used on the tab settings when the 'Set tabs each step' option is selected. |
Some functions in GML are limited to prevent abuse of the codebox. These functions include: game_,file_,room_,window_,highscore_,instance_,sound_,d3d_,message_,mp_,mplay_,registry_,splash_,view_, object_,display_, datastructures, or any objects or global variables used for the program other than the settings for the particle system. This helps avoid code that other people use in a pdsf file that you may not want. |
Here are some codes that you may want to reference when coding for your own particle system.
This is an effective way to burst a particle only for a specific amount of time, and then wait before bursting again.
if (step < 30) {
part_emitter_burst(sys,emt[1],prt[1],10); } if (step > 60) { part_emitter_burst(sys,emt[1],prt[1],0); step = 0; } You can set values of the particle(with 'Set tabs each step' setting on) in the codebox as well.
global.op_speed_valmin[1] = point_distance(ex[1],ey[1],mouse_x,mouse_y)/60;
global.op_direction_valmin[1] = point_direction(ex[1],ey[1],mouse_x,mouse_y); global.op_direction_valmax[1] = global.op_direction_valmin[1]; Movement of the emitter is also helpful to see some effect movement.
val[0] += 5;
ex[1] = 320+100*cos(degtorad(val[0])); ey[1] = 240-100*sin(degtorad(val[0])); |