GameMakerHelpBlog

Saturday, December 2, 2006

GMHB Libs

Hi

Welcome to:GameMakerHelpBlogLibs

I will post libs here including the content in the GMHBlog so it is user friendly with new comers to Game Maker.

I will update this hopefully every now and then when the site has new GM Script content

Current libs....
GMHB Lib1




CMHB Lib 1
Includes
Menu actions
-Opens a website (has arguments)
-Button animator (like 2 sprites changing from one to other when object meets mouse)
-Save (Save a Game)
-Load (Load a Game)
-Exit (Exit a game)
-NewGame (isn't included in GMHB!!!!)(Hasn't been tested)
Movement
-Look at mouse
-RTS Style Movement Create
-RTS Style Movement Step
-RTS Style Movement Global.Left Pressed

Thats all too it for now.. update with new lib soon... Please tell me if there are any errors!

Sorry i have lost the tool for a link so i'll try my own HTML skills.
Download

Labels:

Labels:

Car - Example

Hi

This is a car example.

It has

360 rotation (without mouse)
Skids
Hand brake non - completed

I will add on to it soon

Link:http://z10.invisionfree.com/GM_Help_forum/index.php?showtopic=190&st=0&#last

Labels:

Expansions

Ever wanted expansions on your games. Well this is a simple script to do so. (change the directory to where your game is located and change the name and file)

[code]
if file_exists("c:/program files/example/example.exe")
then
show_message("Example2 has found example on the computer you can play now")
room_goto(playexample)
[/code]

Labels:

Easy Screen

Note: To xp users , i don't know how to make this apart of the selectable screen savers yet :( but it can be used for great trailors

Have you ever wanted to make a screen saver? In GM? Well it is simple with this easy program.

Easy Screen - is a great tool which will export GM exe files to screen saver. it will read paths and most functions and make them work as a screen saver. Unforunately i can't make keyboard actions. But you can make 3D screen savers!
I've only tried a quick 2d one.

Now one word of advice if you use a path remember in step event of the object with the path remember to put image_angle=direction

I will update one day soon hopefully.

The link:Easy Screen

Labels:

Friday, December 1, 2006

Drawing Mouse position and fps

This is a simple script for showing the position of the mouse and the fps in your game... the max fps is usually the game speed

[code]

//get the mouse's position another simple script in draw event!!!!!!!
draw_text(x,y,mouse_x)
draw_text(x,y+16,mouse_y)
//also draw your fps and room speed
draw_text(x,y+32,fps)
draw_text(x,y+48,room_speed)
[/code]

Example included:Link

Labels:

User imput

Ever wanted for the player to type in something in your game e.g to save a game they need to type it? well this is a simple script to do so
[code]
//draw event!!!!!!!!!!!!!!!!!!!!!!!
text=draw_text(x,y,keyboard_string)
[/code]
so we have the text drawn but how about doing the command???
[code]

//enter pressed
if text="save"
then
str=get_string("filename",'')
game_save(str)
[/code]

there you have it.... this script could be used for commanding your allies in a game very simple script

Labels:

Thursday, November 30, 2006

Cheats

Cheats - The games of today.......
Just about every game has cheats these days so i decided to add
a script to show to a simple way to do them

[code]
cheat=get_string("insert cheat",'')
if cheat="won"//change the word if you want too
then
game_end() // this is a default setting change it if you want
//and for multiable cheats
if cheat="restart" //change the word if you want
then
game_restart()//this is a default setting for cheat //change it if you want
[/code]

Labels:

Money - AI and Player

this code is good for the AI and players use... it will show you setting up the money variable.. show you with + and - the money
[code]
my_money=0
[/code]
Simple ay? well it gets easier
[code]
//+ money
my_money+=argument0
[/code]
Below: for minusing money
[code]
my_money-=argument0
[/code]

Labels:

AI - Lives Minus

This is bloody simple but it is an addon to the AI - Lives:Link

[code]
my_lives-=1
[/code]

Labels:

AI - Lives

This is a simple code for checking for how many lives you have left or the AI does in create event put this
[code]
my_lives=3
[/code]
[code]
if my_lives=0 then instance_destroy()
[/code]

Labels:

AI - Shoot

//uses arguments... Argument0=object checking distance Argument1=Distance Argument2=bullet
if distance_to_object(argument0)<argument1 then instance_create(x,y,argument2)

Labels:

AI - Step Towards Player

//argument0=object to check distance and to look at
//argument1=distance
//argument2=speed
//argument3=whether it dodges all instances all=true solid=false
[code]
if distance_to_object(argument0)<argument1 then mp_potential_step(argument0.x,argument0.y,argument2,argument3)
[/code]

Labels:

Sunday, November 26, 2006

AI


//argument0=object to check distance and to look at
//argument1=distance
//argument2=object (player)

[code]

if distance_to_object(argument0)

direction=point_direction(x,y,argument2.x,argument2.y)

image_angle=direction

[/code]

Labels:

Sprite-Thompson SMG gun

Here is a thompson sprite i made..... It is ok for what i do with sprites if you look closely you can see the shading on the bottom........

The only credit i want is for people to join my forum....

http://s10.invisionfree.com/GM_Help_forum/index.php?act=idx



Here it is


<- Yes it is a thompson!

Labels:

Shadow

Here is a simple shadow script you can put in the draw event. Best for topdown games

[code]
draw_sprite_ext(sprite_index,image_index,x+7,y+5,1,1,image_angle,c_black,0.4)draw_sprite_ext(sprite_index,image_index,x,y,1,1,image_angle,c_white,1)
[/code]

Labels:

Pacman style Outside Room script

You know in Pacman how the Monsters go through that tunnel outside the room and end up on the other side well this sctipt will do the same thing for you.

[code]
{
if (x < 0 && hspeed < 0) x = room_width + sprite_xoffset;
if (x > room_width && hspeed > 0) x = -sprite_width + sprite_xoffset;
if (y < 0 && vspeed < 0) y = room_height + sprite_yoffset;
if (y > room_height && vspeed > 0) y = -sprite_height + sprite_yoffset;
}
[/code]

Labels:

Jumping - Platformer

This code will let you jump in a platformer. It is a simple code having 1 part in step event and the other in the jump button event

The step code is
[code]
if position_empty(x,y+1)
gravity=0.5
gravity_direction=270
if !position_empty(x,y+1)
then
gravity=0
gravity_direction=270
if vspeed>12
then
vspeed=12
[/code]

And for the up it is
[code]

if collision_point(x,y+1,solid,true,false)
then vspeed=-10
[/code]

This code has been tested!

Labels:

Drag and Drop boxes....

Hi

Well it is hard to explain but this is for draging a object with the mouse and the dropping it again.
It is NOT for Ragdoll games
It can be for other games
Remember [code]&[/code] have nothing to do with the code
[code]

//this is for create event only
Drag=false//this switches the object "on and off" basicaly
Mouse_Offset_X=0//used to calculate the offset of the mouse click to object for X
Mouse_Offset_Y=0//used to calculate the offset of the mouse click to object for Y
global.myid=id//used to grab the instance id of the object directly under mouse pointer
[/code]

[code]

//this is for end step only
with(global.myid)//with the object directly under mouse pointer
{
if(Drag=true)//if the object has been clicked (is "on")
{
x=mouse_x-Mouse_Offset_X//object's X = offset of obj.x & mouse_x
y=mouse_y-Mouse_Offset_Y//object's Y = offset of obj.y & mouse_y
}
}
[/code]
[code]

//you can change this to any mouse button (warning it is a mouse only function

with(all)//you can put whatever you want to check for in this, not just "all"
{
if(position_meeting(mouse_x,mouse_y,self))//checks for obj directly under mouse
{
global.myid=self.id;//sets the global var to the id of instance under mouse
Drag=true;// turns "Drag" on making the obj dragable by the mouse
Mouse_Offset_X=mouse_x-x;//moves object to the mouse_x possition
Mouse_Offset_Y=mouse_y-y;//moves object to the mouse_y possition
}
}
[/code]
[code]
//global.left release event
Drag=false
[/code]

Labels:

Save and Load - Save your game properly

This code is for saving your game through directories and is good for saving your game....
-Copying files to change the extention
E.g i have a file which is text and i want to change it .dll i would go.
file_copy(example.txt,example.dll)
filename_change_ext(example.txt,example.dll)
or you can use global vars but it will require to do some editing to the code so i don't recommend it.

Anyway here is the code for saving your game
Remember [code]&[/code] has nothing to do with the code it is just there to tell you tha it is code

[code]

SaveGameName = "";
SaveGameName = get_save_filename("Save Files (*.sav)*.sav", "");
if (SaveGameName != "")
{
if (string_copy(SaveGameName, string_length(SaveGameName) - 3, 4) != ".sav")
{
SaveGameName = SaveGameName + ".sav";
}
game_save(SaveGameName);
}
[/code]
And for loading
[code]

LoadGameName = "";
LoadGameName = get_open_filename("Saved Games (*.sav)*.sav", "");
if (LoadGameName != "")
{
if (string_copy(LoadGameName, string_length(LoadGameName) - 3, 4) != ".sav")
{
LoadGameName = LoadGameName + ".sav";
}
game_load(LoadGameName);
}
[/code]

Labels: