Jump to content


FOGHAT

Member Since 16 Apr 2012
Offline Last Active Apr 20 2013 05:54 PM

Posts I've Made

In Topic: Pause Help

19 February 2013 - 03:05 AM

A simple method is to show a pop-up message.
Press P Event

show_message("Game Paused");
You can customize the message by changing the defaults. The size, background, buttons etc.

Another method is to temp save the game, move to another room (like an options menu) and to continue simply re-load the game. This will also work with Lite versions.

Press P Event
game_save(temp_directory+"\tmpsave.sav");
room_goto(options_room);
Continue Button or Key Event
game_load((temp_directory+"\tmpsave.sav");

Either can be used with Lite and both are simple to implement.

Well I can already make the game stop and show a popup message, but to unpause the game with my method, any key will play it. What I want is for only "P" to unpause it.

In Topic: Pause Help

17 February 2013 - 11:03 PM

How elaborate do you want the pause?
Professional looking or just functional?
Obviously you will vote for the first but the first may mean adding a lot of code.
So then.
How elaborate do you want the pause, easy or hard?
I can do either.


Well if you can do either than the professional one, but i don't have gm pro,
so all codes need to be useable by the free version.

In Topic: Full collision with the ground

05 January 2013 - 12:24 AM

Post your code, some pics and the collision mask of the player sprite

Alright, here are my codes:
//jump
if keyboard_check(vk_up)||keyboard_check(ord("W")) && !place_free(x,y+1)
vspeed = -14.5;

if place_free(x,y+1)
gravity = 3;

else gravity = 0;

if vspeed > 13
vspeed = 13;

And the collision mask sprite is:
32x32
The actual mask is 8 hight 9 width
and is sentered 11 pixels from the far left and is plased at the bottom of the sprite
The origin is x 16 y 23

In Topic: Full collision with the ground

04 January 2013 - 11:37 PM

the move_to_contact function doesn't work 100% of the time, because it will contact the first object it comes into contact with. So for example if you had a powerup sitting on the ground and you fell onto it from above, move_contact_all would stop at the powerup and not the ground.

In the Game Maker's Companion book they went over this, and they gave this script to use in it's place, where you can name the object you want to contact with to avoid this problem.

// An alternative to the "Move To Contact" action that allows for contact with a specified object / instance
{
    var dirn, max_dist, contact_obj, dx, dy;

    dirn        = argument0;
    max_dist    = argument1;
    contact_obj = argument2;
    
    if( max_dist == -1 ) then max_dist = 1000;

    dx = lengthdir_x( 1, dirn );
    dy = lengthdir_y( 1, dirn );
    
    dist = 1;
      
    while( dist <= max_dist )
    { 
        if( place_meeting( x+dx, y+dy, contact_obj ) == true ) then return true;
        x = x + dx;
        y = y + dy;
        dist = dist + 1;
    }   
   
    return false;
}

To prevent the issue of going too fast and landing in the middle of an object, you need to set x and y to their value from the previous step before using the move contact function:
x = xprevious;
y = yprevious;
//then use the script I linked above like:
move_to_contact_with(direction,-1,obj_ground); //assuming you named the script move_to_contact_with and your ground object is named obj_ground


Would all of this be in the collision event?

In Topic: about the x += -= etc.

14 October 2012 - 04:52 PM

nvm I solved it

my new code

//controls
if keyboard_check(vk_left)||keyboard_check(ord("A"))
{
if place_free(x-4,y)
x -= 4;
else if place_free(x-3,y)
x -= 3;
}

if keyboard_check(vk_right)||keyboard_check(ord("D"))
{
if place_free(x+4,y)
x += 4;
else if place_free(x+3,y)
x += 3;
}

but thanks to every one!