Game Maker Time Saver Extension
By Mark Henderson
Update: Added many new functions ingluding GML based API.
Game Maker Time Saver Extension, is an extension for Game Maker 7 that was designed to save you a lot of time when programming. GMTSE takes a large bunch of code commonly used by programmers and turns it into a new function which is one line of code! For example, instead of writing the following code:
bulletvar=instance_create(x,y,obj_bullet) bulletvar.direction=320 bulletvar.speed=10 bulletvar.image_angle=320
You would type:
Thus saving you typing it all out and saving you time.
So far there is only 11 functions but i plan on adding as many more as possible.
The current functions are:
current_date(separator,format) This function returns the current date, the argument 'separator' is the character that will separate the day, month and year. So if you entered "/" it would return dd/mm/yyyy. Format changes the order of the day and month, 1 would return day, month and year, 2 would return month, day and year. So current_date('/',1) would return dd/mm/yyyy.
current_time_hms(separator) This function is the same as the last except it returns the hour, minute and second. Again, separator is the separator, so current_time(':') would return hour:minute:second.
directory_copy(from,to) This function is like the file_copy function except it copys folders and all files, sub-directories from one place to another. From is the directory to copy and TO is the folder to copy to.
draw_api_button(x,y,string) This draws a windows XP style button. No need for width or height as it calculates those by the string.This function will return 1 when pressed
draw_api_checkbox(x,y,checked) This function draws a checkbox for the user to click. x and y set the position on the window and checked sets wether it is checked when drawn. It will return 0 when it is not checked and 1 when it is.
draw_api_dropdown(x,y,items) THis draws a drop down box with the given items and returns the selected item. x and y set the position and items is where you put the items as a string like 'item1|item 2|item 3|item 4'. If the user selected item 1 a 0 would be returned, if they selected item 2, a 1 would be returned and so on.
draw_api_input(x,y,length,default,active) This will draw a textbox for the user to enter text. x and y set the position, length sets how long the input box is, default is the default text as a string and active sets whether the user can enter text straight away, if not it will not take keyboard input until the user clicks it. This function returns the text entered in it.
draw_api_slider(x,y,default) This function draws a sliding control. x and y set the position on the window and default is the initial value of the slider. This returns the position of the slider.
draw_grid(w,h,x,y,hn,vn,col1,col2,width) Use this to draw a grid on the window, w and h are the width and height of the squares, x and y are the position where the grid is drawn, hn and vn are the amound of horizontal and vertical squares, col1 and col2 are the colors to use and width is the width of the lines.
a) Use this to draw a laser beam that stops when it hits other objects. x and y are where the beam comes from, angle is the angle to draw it at, length is how long the laser should be, object is the object that the laser will stop at, step is the amount the laser will grow once it is no longer hitting an object, color is the color of the beam, and alpha is the alpha of the beam.
draw_sprite_solidcolor(sprite,subimg,x,y,color) This function is like Game Makers own draw_sprite function except it draws the sprite as a solid color. Sprite is the name of the sprite to be drawn, subimg is the sub image, x and y are the positions to draw the sprite and color is the color to draw the sprite.
set_stats(lives,health,score) Instead of setting the number of lives, health and score separately at the start of a game you can use this function to do it all at once. lives is the number of lives to give, health and score have the same idea.
ion,speed,image_angle) This function is a real time saver, it allows you to create an instance and set its direction, speed and image angle. objectvar is the name of the variable that will store the instance id. x and y are the positions to create the instance. Direction is the direction the instance will travel, speed is how fast it should move and image angle is what angle the image should have. This function is great for creating bullets. For example, instance_create_motion("bulletvar",0,0,obj_bullet,320,10,320)
instance_deactivate_view(viewnum,inside,notme) This function will deactivate all instances inside or outside a view depending on the number you pass. viewnum is the number of the view, so if you are using view then you would pass 0 as the viewnum, if inside is set to true all instances inside the view are deactivated, if set to false then it affects the instances on the outside of the view. if notme is set to true the calling instance is not deactivated.
instance_destroy_ext(object) This function destroys a specific instance.
move_to_mouse(speed) This makes the instance move towards the mouse with the given speed, once the instance is at the mouse it stops until the mouse is moved again.
point_mouse() Call this function in a step or draw event to make the image angle point towards the mouse.
ram) You can use this function to register a file extension with your program. extension is the file extension, for example, if you put '.sav' all files with the .sav extension will be given the following information. Description is a quick description about the file such as 'save file'. Icon is the full path to an icon file to associate with the extension, use working_directory+'images/icon.ico' finally, program is the full path to the program that will be opened when the extension is clicked.
hcaption,showscore,scorecaption) This function takes the stats and draws them on the window caption. set showlives, showhealth and showscore to true or false to set whether or not to show each of them. livescaption, healthcaption and scorecaption is the text that will be shown before each stat.
) Use this to load an external sound and play it. variable is the name of the ariable as a string that will store the sounds ID. fname is the path and filename as a string. kind is what type of sound it is (look in GM help). preload sets whether or not to load the sound before it is played. loop sets whether or not to loop the file and olume is the volume to play it at (between 0 and 1)
sound_play_volume(sound,volume) Use this to play the sound at a certain volume. volume should be a number between 0 and 1. So sound_play_volume(snd_shot,0.5) would play the sound snd_**** at half volume.
website(url) Open up the users default browser with the given url.
op,sizeable,caption,cursor,color,x,y,w,h) Set all the most commonly used window_set functions all in one go.
Do you know a script or piece of code that you spend too much time typing out? Then let me add it to GMTSE and i will credit you. Just post it here, pm me or email me at firstname.lastname@example.org
Download from host-a.net
Edited by -!MBC!- R3D R3AP3R, 18 March 2007 - 04:11 AM.