In this act:
1 - How to load the first zone after starting a new game.
2 - How do we make a playable act/zone.
3 - How does the game save.
4 - Level Select after Credits.
How to load the first zone when we start a new game?
In order to start with the correct Zone, you have to make a little change to the initialization Script. (scr_initialize)
You have to change the variable called global.first_zone!
The value of this variable should be the first act of the first zone. (e.g rm_green_hill_act1)
Please keep that in mind!
How do we make a new Act/Zone?
In order to make a proper working Level, you need to add several Controller objects into your Level (or as game maker calls it, "Rooms").
Add these objects into your room:
- obj_controller > This is the main controller object. THIS OBJECT IS REQUIRED for flawless gameplay!
- obj_hud > This object will draw the HUD on the screen.
- obj_pause_screen > This object will pause the game if you press Enter or the mapped "PAUSE" Button on your Gamepad.
- obj_title_card > This object will draw the Title Card once the room starts. It's really fancy, isn't it?
- obj_water > This object is ONLY NECESSARY if you want Water in your level. It merely draws the Water surface.
Once all those objects are present in your room, you need to add / tweak a few global variables for the room. In Order to do that, go to the Settings tab while
you're using the Room Editor and click on "Creations Code"
You'll need to add the following Variables:
global.title_card_name = "NAME"
This is the name of the Zone. It's being used by the title card object. Use # for a new Line.
global.title_card_act = ACT NUMBER;
This is the Act Number that's drawn on the Title Card. Obviously, you can only use 1 to 3 (Unless you edit the Act Number sprites).
global.data_select_icon = ID;
To correctly display the Zone preview in the data select screen. 1 would be the 0 frame of spr_data_zone, 2 the 1 frame. Keep this in mind!
global.gravity_angle = 0;
This is the Gravitation Angle, you may keep this 0 unless you want to do some crazy things.
global.water = true;
Indicates if Water is being used in this Act. You may only use true and false for this.
global.water_y = Y Position;
This is the Starting Position of the Water.
global.water_y_change = global.water_y;
When you change this on level start, the position of the Water will slowly change to this value.
You may set this to global.water_y if you use a switch that changes the water level to prevent that it changes immediately.
global.death_height = Y Position
Indicates the death height for the Player. Once the Player hits this y position, it's death will be triggered.
And now, we need to initialize the Player and the AI!
if(global.save_cpu != 0){
global.character_amount = 2;
} else {global.character_amount = 1};
global.character_id[0] = global.save_char; --- Loads the saved Main character. NOTE: Manually change to a number to set different Character. 1 - Sonic, 2 - Tails, 3 - Knuckles
global.character_id[1] = global.save_cpu; --- Loads CPU follow character. NOTE: Can also be chosen manually here.
global.character_is_ai[0] = false; --- Determines if the Player is an ai or normal player.
global.character_is_ai[1] = true;
global.character_view[0] = 0; --- Determines what view will follow that player. (-1 for none)
global.character_view[1] = -1;
global.character_follow[0] = -1; --- Determines what character that character follows.
global.character_follow[1] = 0;
Once you've done all this, the Level should work without any issues.
If you encounter any issues when you run the room, check the creations code again, you might made a mistake!
If you're too lazy to copy this OR the room doesn't work, simply make a copy of rm_template_level.
How does the game save and load? (+1.1 only)
The game will automatically save your game when the first act of a zone starts AND ends.
And saves will be loaded once the data select screen appears. (Obviously)
Level Select after Credits:
When you completed a Game and return to the Data Select Menu, you'll notice that it displays the STH3 Completion Icon for the Zone Preview.
Choosing that slot will make a Level Select appear, where you can choose every zone in the game to replay your favorite level or to gather Chaos Emeralds you haven't found yet.
In order to make this work for your Game, you have to edit some variables in the Creations Event of obj_data_slot.
The Variable you need to change:
zones_in_game - This is the variable used to check how many zones are in the game, obviously. If you have 8 Zones, set this to 8. If you have 3, set it to 3.
After you've done that, you need to create a few new variables in the same event. (Below the zones_in_game variable)
called:
zone_name[id] and zone_room[id]
Zone name is the name that will be displayed in the Level Select Menu.
Zone room is the name of Game Makers room. (ex. rm_zone_test)
ID is the number of the zone. If you have 3 Zones and the first zone is called "Green Hill Zone" and has a room called rm_ghz_act1, do the following:
zone_name[1] = "GREEN HILL ZONE"
zone_room[1] = (rm_ghz_act1)
Do the same for each zone.
When you're done, you should have something like this:
zone_name[1] = "GREEN HILL ZONE"
zone_room[1] = (rm_ghz_act1)
zone_name[2] = "MARBLE ZONE"
zone_room[2] = (rm_mz_act1)
zone_name[3] = "SPRING YARD ZONE"
zone_room[3] = (rm_syz_act1)
zone_name[4] = "LABYRINTH ZONE"
zone_room[4] = (rm_lz_act1)
...
How do i add Background Music to my levels?
In order to play BGM in your levels, open the Creations Code of the object called obj_music_box located in
Objects > Music & Screen
You should see something like this:
https://i.imgur.com/KgXI8ny.png
For GM8.X: Create a new variable, lets say ZONENAME_act1_bgm
and as value do: caster_load(working_directory+"\gamedata\bgm\***.ogg)
***.ogg being your audio file.
For GM:Studio: Just like in GM8.X, create a new variable but instead of using caster_load()
load your background music via Game Maker Studio.
( Right click Sounds > Create Sound ) set a name like bgm_ZONENAME_act1 and use that as value.
Once you've done that, go to the Room Start event of obj_music_box
You should see this at the bottom:
https://i.imgur.com/ryLTAa1.png
Do exactly what i did for the test zone and you should be able to hear your music in the level!
Add new Characters:
In order to add new Characters to GMate, you have to do several things first...
1. Before we do anything with objects and scripts, go to the "Resources" tab and select "Define Constants"
Here, you define a new constant for the new Character.
Scroll down until you see "ConCharKnuckles":
https://i.imgur.com/FPJRif3.png
Click on the "+ Insert" button and define a new Constant.
As a example, we name it "ConCharAmy" and set the value to 4. That Value is the Character's ID we have to use later in Scripts.
If you want to add 2 Characters, make sure that the ID's are in order, so "ConCharAmy" is 4 and "ConCharBig" is 5. Do not use random numbers for this.
2. Open the Following Script: "scr_player_animation_get" which you can find in the "Player > Animation" Scripts Folder:
https://i.imgur.com/So9O0VH.png
You should see this when you open it:
https://i.imgur.com/MOHqY6y.png
Add the animation scripts for the new player here.
Once done, it should look like this:
https://i.imgur.com/ZbvRvtp.png
I won't show you how to add/set animations. Because you can figure that out by yourself when you check the animation scripts such as scr_player_animations_set.
Most of the time, you can just copy Sonics values in the animations scripts and change the ID behind it to the new players ID.
2. Once you added the animations for the player and etc, move on and open the object called "obj_character" which you can find in "Objects > Game > Player > Main"
In the "Begin Step" event of said object, you'll find what handles the Players physics. Copy the values from Sonic and paste them at the bottom of the script, change "character" to the new character.
And set the Values for the Player. If they act like Sonic, you don't have to change anything except the "if(character =...)" part like i said above.
It would look like this:
https://i.imgur.com/AHPBeEo.png
NOTE: You don't have to use (if(super_state...)) if said character has no super form.
Just look at Tails and Knuckles.
3. Move on to the Drawing event of obj_character.
Open the script called "Animation Set"
What needs to be done here should be self explanatory.
4. Almost done!
Now open the object called "obj_data_char" which you can find in the following folder: "Objects > Game > Data Select > Slot"
In the "Press up" and "Press Down" event of said object change the char_ variables that have a 3 as a value to the number of charactesr now, if you have 4 characters, set it to 4.
Open the sprite called spr_data_char and add a new sprite for the new character.
5. If you want to disable Actions and behaviours for the new character. Go back to obj_character and in the step event you should find a script called "Actions" and "Handle"
If you, as a example, want to remove the spindash for Amy, add a "if(character != ConCharAmy)" above the action, like this!
https://i.imgur.com/ReTDydp.png