Home

Maker Camp 6


Gamemaker code for generating a high score table:

var name;
name=get_string("Enter your name","");

highscore_add(name,score)

for (i = 0; i < 10; i += 1)
{
    highscorenamearray[i + 1] = highscore_name(i + 1) 
    highscorevaluearray[i + 1] = highscore_value(i + 1)
}

show_message("HIGHSCORE LIST

1  - " + highscorenamearray[1] + " = " + string(highscorevaluearray[1]) + "
2  - " + highscorenamearray[2] + " = " + string(highscorevaluearray[2]) + "
3  - " + highscorenamearray[3] + " = " + string(highscorevaluearray[3]) + "
4  - " + highscorenamearray[4] + " = " + string(highscorevaluearray[4]) + "
5  - " + highscorenamearray[5] + " = " + string(highscorevaluearray[5]) + "
6  - " + highscorenamearray[6] + " = " + string(highscorevaluearray[6]) + "
7  - " + highscorenamearray[7] + " = " + string(highscorevaluearray[7]) + "
8  - " + highscorenamearray[8] + " = " + string(highscorevaluearray[8]) + "
9  - " + highscorenamearray[9] + " = " + string(highscorevaluearray[9]) + "
10 - " + highscorenamearray[10] + " = " + string(highscorevaluearray[10]) + "")

Basic Code for a Platformer (posted on http://gamemakertutorials.com/):
used in objPlayer -> Step event -> execute code action

//Get the player's input
key_right = keyboard_check(vk_right);
key_left = -keyboard_check(vk_left);
key_jump = keyboard_check_pressed(vk_space);
 
//React to inputs
move = key_left + key_right;
hsp = move * movespeed;
if (vsp < 10) vsp += grav;
 
if (place_meeting(x,y+1,objWall))
{
    vsp = key_jump * -jumpspeed
}
 
//Horizontal Collision
if (place_meeting(x+hsp,y,objWall))
{
    while(!place_meeting(x+sign(hsp),y,objWall))
    {
        x += sign(hsp);
    }
    hsp = 0;
}
x += hsp;
 
//Vertical Collision
if (place_meeting(x,y+vsp,objWall))
{
    while(!place_meeting(x,y+sign(vsp),objWall))
    {
        y += sign(vsp);
    }
    vsp = 0;
}
y += vsp;

Basic Code for a Platformer (posted on http://gamemakertutorials.com/):
used in objPlayer -> Create event -> execute code action

///Initialize Variables
grav = 0.5;
hsp = 0;
vsp = 0;
jumpspeed = 7;
movespeed = 3;