The VG Resource

Full Version: Game Maker and GML thread
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Please do not worry though, this thread and post is extremely easy to understand.

Uploads are okay if all of the four conditions are met:
#1: legal

#2: safe

#3: allowed

#4: permissioned


GML stands for Game Maker Language

III stands for 3

NES stands for Nintendo Entertainment System

Talk about Game Maker, GML etc. here


Example:

Code:
Just like in Mega Man III for NES
Mega Man III Stage Selector object’s sprite status:
Origin X: 0
Origin Y: 0
Have Precise collision checking used
Does not have Smooth edges
Does have Preload texture
Bounding Box Left: 0
Bounding Box Top: 0
Bounding Box Right: 51
Bounding Box Bottom: 47
Sprite Height: 48
Sprite Width: 52
Top left pixel of its sprite is on x: 3 y: 0 with only 3 (x: 0 y: 0 x: 1 y: 0 x: 2: y: 0) nothingness to the left
Of its top left pixel




Code:
Just like in Mega Man III for NES
Mega Man III Stage Selector left pressed object's status:


sound_play(stageSelectorSound); //Plays the stage select Sound just like in Mega Man III for NES

//Top Row
if place_meeting(x,y,sparkManCubeObj) //just like in Mega Man III for NES if colliding with Spark Man Cube's object
{x = needleManCubeObj.x; exit} //just like in Mega Man III for NES now go to Needle Man Cube's x and then exit
if place_meeting(x,y,needleManCubeObj) //just like in Mega Man III for NES if colliding with Needle Man Cube's object
{x = snakeManCubeObj.x; exit} //just like in Mega Man III for NES now go to Snake Man Cube's x and then exit
if place_meeting(x,y,snakeManCubeObj) //just like in Mega Man III for NES if colliding with Snake Man Cube's object
{x = sparkManCubeObj.x; exit} //just like in Mega Man III for NES now go to Spark Man Cube's x and then exit

//Middle Row
if place_meeting(x,y,megaManCubeObj) //just like in Mega Man III for NES if colliding with Mega Man Cube's object
{x = hardManCubeObj.x; exit} //just like in Mega Man III for NES now go to Hard Man Cube's x and then exit
if place_meeting(x,y, hardManCubeObj) //just like in Mega Man III for NES if colliding with Hard Man Cube's object
{x = topManCubeObj.x; exit} //just like in Mega Man III for NES now go to Top Man Cube's x and then exit
if place_meeting(x,y,topManCubeObj) //just like in Mega Man III for NES if colliding with Top Man Cube's object
{x = megaManCubeObj.x; exit} //just like in Mega Man III for NES now go to Mega Man Cube's x and then exit

//Bottom Row
if place_meeting(x,y,magnetManCubeObj) //just like in Mega Man III for NES if colliding with Magnet Man Cube's object
{x = geminiManCubeObj.x; exit} //just like in Mega Man III for NES now go to Gemini Man Cube's x and then exit
if place_meeting(x,y, geminiManCubeObj) //just like in Mega Man III for NES if colliding with Gemini Man Cube's object
{x = shadowManCubeObj.x; exit} //just like in Mega Man III for NES now go to Shadow Man Cube's x and then exit
if place_meeting(x,y,shadowManCubeObj) //just like in Mega Man III for NES if colliding with Shadow Man Cube's object
{x = magnetManCubeObj.x; exit} //just like in Mega Man III for NES now go to Magnet Man Cube's x and then exit
What is this topic's objective? Are you just posting GML codes, or is there a question and/or tutorial here? I'm tending towards the latter, so it might be interesting, I guess.
I doubt anyone will be able to make use of the posted code oput of its context.

It also isn't the most elegant way to code such a selection. I'm pretty sure MM3 on the NES didn't check for collisions between the selection marker and stage icon to determine the position.

You have nine stages. Easy solution would be to have a variable for the selection with values from 0 to 8 - let us call if selectionVar for fancyness.

Interpret the stage icons like this:

0 1 2
3 4 5
6 7 8

When the selector has been moved, place it at the position of the appropriate stage icon.

To move the selector to the left (<-) you can simply subtract 1 from the current value.

Code:
if ((selectionVar % 3) > 0) {
    selectionVar--;
}

Why I use the modulo operator? To prevent moving from 3 to 2 (middle row to top row) for example. What it does? This:

0 % 3 = 0
1 % 3 = 1
2 % 3 = 2
3 % 3 = 0
4 % 3 = 1
5 % 3 = 2
6 % 3 = 0
7 % 3 = 1
8 % 3 = 2

So the selection will not move when it is on 0, 3 or 6 (the leftmost icons)! Fancy, isn't it?

Move right:

Code:
if ((selectionVar % 3) < 2) {
    selectionVar++;
}

Move up:

Code:
if (selectionVar > 3) {
    selectionVar -= 3;
}

Move down:

Code:
if (selectionVar < 6) {
    selectionVar += 3;
}

Afterwards, in every case independent of the direction, reposition the selection marker:

Code:
switch (selectionVar) {
    case 0:
        x = sparkManCubeObj.x;
        y = sparkManCubeObj.y;
    break;
    case 1:
        x = needleManCubeObj.x;
        y = needleManCubeObj.y;
    break;
    // ET CETERA OKAY ;)
}
sed 's/just like in Mega Man III for NES/'

(You don't really need that on every single line. Just sayin')
please read the rules,
To my understanding this is a place for game projects with sufficient information, not a help area.
I'd advise game maker community for help with game maker.
We have the GameDev lounge for games-you-are-making-that-don't-need-their-own-thread-yet discussion. We have a QIT section for questions. I'm mergng this into the general GML thread we have somewhere.