Step 1: How to install, into Construct 2 as a starter Template.
Open "C:\Program Files\Construct 2\startdlg.xml" with your favourite text editor and add this:
Open "C:\Program Files\Construct 2\startdlg.xml" with your favourite text editor and add this:
<template filename="super-roguelike-engine.capx">
<name>Super Roguelike Engine - Desktop Edition [Version 1.0.0]</name>
<image>0</image>
<description>Starter template for Construct 2 - to create a roguelike game of your dreams. </description>
</template>
Copy the file super-roguelike-engine.capx to "C:\Program Files\Construct 2\templates"
Here i'll explain how the template layouts are set up in all the project.
Level 0
l_level_0
is where the player starts the adventure.
Level 1
l_level_1
is a regular dungeon for demo purposes.
Level 2
l_level_2
is a regular dungeon differnt tilemaps for demo purposes.
Loader Screen
loader
is the first layout for Construct to load.
Main Menu Screen
main
main menu layout in this layout all resources are placed to be loaded
Options Screen
options
options layout.
Loading Screen
loading
is a fake loading screen for each level.
Hud
hud
is where all the game UI elements are placed.
Camera
camera
a layout for acts as a camera.
Here i'll explain how the template events are set up in all the project.
Level 1
e_level_1
a specific event sheet for l_level_1
When you want to add a specific events to a level you can simply add a e_level_n where n is the level number. So this way you can separate different events for that level.
If you add for instance a e_level_1 event sheet remember that this new event sheet must be set it up on l_level_1 on the Layout Properties in Construct 2 panel.
Loader Manager
loader_manager
an event sheet for loader layout.
Loading Manager
loading_manager
an event sheet for loading layout.
Main Menu Manager
menu_manger
an event sheet for menu layout
Options Manager
options
an event sheet for game_manager event sheet.
Globals Manager
globals_manager
All global variables,functions that need to be available everywhere.
Game Manager
game_manager
this eventsheet is to controls all the game actions.
Hud Manager
hud_manager
this eventsheet is to controls all the game actions.
Lobby Manager
lobby_manager
this eventsheet is to controls all the game actions on l_level_0.
Quests Manager
quests_manager
this eventsheet is to controls all the game quests.
Most of the global variables are started in menu_manager and it is one of the first layouts to load, then we use it to initialize the values of those global variables that we will need for the game.
Our player is a container composition of various Sprites, such as:
This is a little tricky, since we add obj_player_sword as a Container of obj_player_mask, we place all the ATTACK animations in the obj_player_sword like this:
Since the Super Roguelike Engine has three different Swords, our player can switch between
Later in game_manager we check which Sword is equipped the play the animation according to the sword number
Our Sprite for player when is dead
To set up our player in levels we only need to add the Sprite named obj_start_point on the level, here is where our player starts as far as Loading screen reach 100%
obj_start_point has an instance variable named level_number remember to set up this variable to the l_level_n. For instance in l_level_1 the obj_start_ponint level_number is 1
Initially the player does not have any assigned quests, when entering the Lobby, and colliding with the NPC Karina will open a window of the Hud where the player is asked if he wants to accept that quest
On menu_manager we set up all init data for quets, like how many quests we want in the game
g_total_quests is an int variable set to 20
We store in a Dictionary, the pair KEY/VALUE like quest_1 = 0, quest_1_completed = 0
Later in quests_manager we can check which quest is completed
Open the file super-roguelike-engine.capx go to tab panel Projects -> Files -> Dialogs -> AllQuests.xml double click to open the XML file, with your preferred Text Editor
Since the template already has two quests added you need to copy and paste below the last quest which is number 2, a code like this:
<quest id='3'>
<line id='intro1'>Welcome! warrior please I need your help, hunting monsters on the dungeons. </line>
<line id='intro2'>Please go to the first dungeon and hunt "20 Minotaurs" </line>
<line id='intro3'>Do you accept the quest? </line>
<enemies id='enemiestokill'>20</enemies>
<corpse id='sprname'>obj_enemy_minotaur_corpse</corpse>
<dungeon id='questdungeon'>2</dungeon>
<reward id='coins'>20</reward>
</quest>
Note that every id of the XML AllQuests.xml is single quoted
When you add a new quest the Lobby NPC, will automatically recognize that quest
In the Everytick of quests_manager there is a group that is called "Quests: Killed Enemies" that controls which enemy we have just killed and if it is within the
When enemies killed is equal to total enemies to kill, then the current quest is completed. Plus a Sprite will show on HUD so the player can claim the reward.
In order for the quest to work properly you must add an additional check in the group "Quests: Killed Enemies" as shown in the picture below.
This is what we do is create a Sprite type corpse according to the enemy we just killed
In this case we know that the enemy is a Minotaur so we create a Sprite with obj_enemy_minotaur_corpse
At the moment that we create the corpse Sprite , this code adds 1 to g_killed_enemies and so on.
With this will be enough to create a quest, as in game_manager already placed a condition for killing an enemy to generate a corpse, we do not need anything else.
To place a new sign in the game you just drag a Sprite called obj_sign to the level you want and fill in the variable inst_sign_text with the text you want to show when the player is on collision with that sign
the inventory works based on Array, LocalStorage and Family, the ArrInventory Array is created with a dimension of: Width: 15 Height: 2.
The Family: Inventory is created with a variable of type int called: itemFrameOnInventory
An entry is created in LocalStorage with the key: inventoryKey type text like inventoryKey = myInventoryKey which is the variable where we will store the ArrInventory as JSON
In the main Layout you will find obj_inventory_1 this is the main Sprite to manage the inventory, has a variable called "itemFrameOnInventory" inherited from the Inventory Family, and we will use it to know what item we have collected in the game, based on its Frame
When our player collides with an Inventory Item we use itemFrameOnInventory to identify which item we have to add to our Inventory and so display the Item on HUD
Here we're calling a Function AddToInv, which checks if there is a free slot to add this Item, and if the Item already exis then update it's Qty.
AddToInv function: Take two params
First Param: 0 is the item frame we want to add - right now is from 1 to 6 based on obj_inventory_1
Second Param: an int number to set the quantity of the Item
In the main Layout you will finf obj_item_bg which is the button on HUD, for our player to use Items.
For instance here is our inventory in the game HUD with a Dash Potion in it.
So obj_item_bg has now a Dash Potion with the Qty. of 1 assigned to it's first slot.
The player can now use the item by clicking on it or pressing the assigned keyboard key which in this case is the key:1
Enemies can have hp so when the player attack withdraw some of the hp
For instance: Minotaur are enemies of one hit kill, dragons has 100hp, you can set the enemy HP when is created.
Creeps are one hit kill and they don't shoot.
As our player has a bow and a sword, to kill the flying enemies you have to use the bow and arrow.
To enhance Construct 2 performance we're going to create enemies on demand, with a zone technique, how this is going to work:
When our player collides a zone we're set the boolean collided to tue
In a ForEach obj_spwn we check if spawned is equal to 0, so if is 0 go on.
If zone is collided equal true and obj_spwn is overlapping obj_zone then we check obj_spaw enemyName variable to assign the enemy.
Each Button of the Main Menu Layout is assigned to an ins_menu_id so we can retrieve the ins_menu_id and identify which button was clicked.
When user press "Tab" key, display the game contextual help.
Floor trap is an Sprite with a Default animation and the 0 Frame is set to 20 speed.
So we can controls if our player is overlaping obj_floor_trap_1 and if the current frame is bigger than 0, then the spikes are up so our player take some damage.
In order to play a sound the obj_floor_trap_1 has a inst_distance to check his current position and player position, so if the player is in distance range then play trap sound.
If our player is overlapping obj_floor_trap_1 and is not flashing already, is damaged
Example: To place a hidden area just go to Layer TilemapHidden and draw some tiles to hide the Tilemap_map, since TilemaHidden is abobe when the game is running if the player is not overlapping a TilemapHidden the area is not showed at all.
Example: Place a chest in a l_level_n and add some values, set inst_is_open to false, set inst_name to the color of the chest, leave inst_uid and inst_drop_rate to 0
- Brown chest name = brown_chest
- Red chest name = red_chest
- Silver&Blue; chest name = blue_chest
When our player is overlapping the Health Fountain will gain HP and Dash points to replenish.