我怎么了
到底是怎么回事
怎么会有这种感觉
我不要这样
我不要
心底话 谁与诉求?
眼里泪 往何处流?
此一念 安将悠悠?
谁予我 药解千愁?
Thursday, August 12, 2010
Sunday, August 8, 2010
Turn-based RPG Model with Game Maker
Recently was requested to create a simple game by using Game Maker as a project. After that, the thought of building a turn-based Role Playing Game (RPG) which looks and feels similar to Final Fantasy Game Series was started to develop in my mind. With the initial intention of building the skeleton and practicing the basic mechanisms and functionalities present in a normal RPG, this game model is constructed in a considerably simple way and it is a typical one. Of course, it couldn't be compared with those commercial games developed by a huge team of programmers, designers, music composers and many more.
Here comes the overview of the whole game:
There will be an explorer (which is a representation of a team of members) who wanders around the world (which is actually an area within the room) and he can converse with the NPCs (Non-Player Characters) present throughout the world for getting useful information in the game. Then the explorer may encounter random enemies (which are actually invisible objects with its moving path set for colliding with the wandering explorer) that moving around and lead to a normal fight/battle. After a victorious fight, the team gains golds, EXP and level-ups and gets back to the 'world' again. There will be some key NPCs to be met and conversed with or boss to be defeated before the storyline can proceed, I used to call these key objects as 'checkpoints'.
Figure 1 - The semi-transparent white boxes with a red X are the 'PathBlocker's.
To make life easier, I've decorated the land by using the desired tiles which loaded as a background in Game Maker. To restrict the explorer from moving beyond the borders, fences, or woods, objects called 'PathBlocker' ware created and placed at the right places for stopping the explorer's movement when he moves into contact with them.
Figure 2 - Move the explorer near to the NPC and press Space key to converse and press Enter key to continue the conversation.
For this, the dialog box used is actually an object with semi-transparent blue-colored image as its sprite, msg as its attribute used for storing the string to be shown in the draw event. Besides, each NPC will have a set of dialog which stored as its own attribute for use in the dialog box later.
In each room-step, check for the existence any NPCs around explorer by using the collision checking function. If yes, enable the interception of the Space key and if the key is hit, simply get the ID of the nearby colliding NPC and set the dialog box's msg attribute to the NPC's, this makes the dialog box draws its corresponding text on itself. At the same time, enable the Enter key for terminating the conversation by destroying the dialog box.
All these attributes' value loaded from the global variable in the 'world' room when every battle starts. These attributes are stored in arrays. Note that these are just the basic attributes of a typical RPG's characters will have, we can add in more attributes if necessary.
Figure 3 - The interface of the battle field.
A battle shall start by entering another room which serves as the battle field when the explorer collides with invisible enemy objects present in the room. Setting path for the random enemy object will save alot of time. To keep everything tidy and easily manageable, a controller object is specifically created and initialized when the battlefield room starts. This controller object will contain the following data structures and variables:
Well, here comes the logical part of the battle model when the battle get started:
When the battle starts, a random number of predefined enemies will be created in the room if it is a normal battle. Else, it will be a boss fight with preset boss unit and no random units. As the enemies get created and ally units' attributes are loaded, their IDs are appended to the their corresponding list.
For every step of the game, the game checks whether the AllyAliveCount and EnemyAliveCount is equal to zero. If yes, it is either the player wins the battle or all the ally units have been defeated by enemies. This will then leads to adding EXP points to the alive ally units and return to the 'world' again, or, say goodbye to the player because it is already game over!
Now comes to the commanding mechanism of the ally units during the battle. The player may press Up and Down key to select different command such as Attack, Skill, Defend, Escape or selecting different skills available. Pressing Left and Right Key will change the commanding unit's target while Space key is used to change the commanding unit which is ready to fight. Hitting Enter key will confirm an action with target. Both ally and enemy units can perform action once they are ready. For the enemy units which is not under the player's control, it will automatically add to the Sequence list when they are ready to perform actions.
Figure 4 - Positioning units using linear positioning system.
Till now, ally and enemy units are just created but not positioned at the right place. And yet, there will be random number of enemy units required to be placed in a normal battle, thus, a dynamic but simple linear positioning system is used to solve this problem. As as shown on the figure, the starting point and ending point of the position range are set and the interval is set to the number of units in a line plus one. Then, the gap between the two subsequent units in a line is calculated based on the positioning range and intervals. After all, a For loop is enough for placing all the units in a line at a time.
Okay, now I will end the documentation here.
This article is credited to the author of this blog, Tiong Soon Seng.
Here comes the overview of the whole game:
There will be an explorer (which is a representation of a team of members) who wanders around the world (which is actually an area within the room) and he can converse with the NPCs (Non-Player Characters) present throughout the world for getting useful information in the game. Then the explorer may encounter random enemies (which are actually invisible objects with its moving path set for colliding with the wandering explorer) that moving around and lead to a normal fight/battle. After a victorious fight, the team gains golds, EXP and level-ups and gets back to the 'world' again. There will be some key NPCs to be met and conversed with or boss to be defeated before the storyline can proceed, I used to call these key objects as 'checkpoints'.
Designing the 'World'
Figure 1 - The semi-transparent white boxes with a red X are the 'PathBlocker's.
To make life easier, I've decorated the land by using the desired tiles which loaded as a background in Game Maker. To restrict the explorer from moving beyond the borders, fences, or woods, objects called 'PathBlocker' ware created and placed at the right places for stopping the explorer's movement when he moves into contact with them.
Conversing with NPCs
Figure 2 - Move the explorer near to the NPC and press Space key to converse and press Enter key to continue the conversation.
For this, the dialog box used is actually an object with semi-transparent blue-colored image as its sprite, msg as its attribute used for storing the string to be shown in the draw event. Besides, each NPC will have a set of dialog which stored as its own attribute for use in the dialog box later.
In each room-step, check for the existence any NPCs around explorer by using the collision checking function. If yes, enable the interception of the Space key and if the key is hit, simply get the ID of the nearby colliding NPC and set the dialog box's msg attribute to the NPC's, this makes the dialog box draws its corresponding text on itself. At the same time, enable the Enter key for terminating the conversation by destroying the dialog box.
Setting Attributes of Units and Skills
Every unit in the game represents a real world object, which has all the attributes. Ally and enemy units shared some common attributes, such as: name, status, lvl, hp, maxhp, mp, maxmp, atk, def, turnspeed, turnspeedctr, EXP, target.All these attributes' value loaded from the global variable in the 'world' room when every battle starts. These attributes are stored in arrays. Note that these are just the basic attributes of a typical RPG's characters will have, we can add in more attributes if necessary.
Engaging in a Battle
Figure 3 - The interface of the battle field.
A battle shall start by entering another room which serves as the battle field when the explorer collides with invisible enemy objects present in the room. Setting path for the random enemy object will save alot of time. To keep everything tidy and easily manageable, a controller object is specifically created and initialized when the battlefield room starts. This controller object will contain the following data structures and variables:
- AttackSequence, a queue which determines the attack sequence of both allies and opponents in a First-In-First-Out manner.
- AllyList - a list which stores all ally units who participate in the current battle.
- EnemyList - a list which stores all enemy units who participate in the current battle.
- AllyListIndex, EnemyListIndex, SkillListIndex, MenuIndex - stores current index of the AllyList, EnemyList, SkillList and command menu for traversal between them.
- AllyAliveCount, EnemyAliveCount - store the number of allies and enemies which are still alive at the moment.
Well, here comes the logical part of the battle model when the battle get started:
When the battle starts, a random number of predefined enemies will be created in the room if it is a normal battle. Else, it will be a boss fight with preset boss unit and no random units. As the enemies get created and ally units' attributes are loaded, their IDs are appended to the their corresponding list.
For every step of the game, the game checks whether the AllyAliveCount and EnemyAliveCount is equal to zero. If yes, it is either the player wins the battle or all the ally units have been defeated by enemies. This will then leads to adding EXP points to the alive ally units and return to the 'world' again, or, say goodbye to the player because it is already game over!
Now comes to the commanding mechanism of the ally units during the battle. The player may press Up and Down key to select different command such as Attack, Skill, Defend, Escape or selecting different skills available. Pressing Left and Right Key will change the commanding unit's target while Space key is used to change the commanding unit which is ready to fight. Hitting Enter key will confirm an action with target. Both ally and enemy units can perform action once they are ready. For the enemy units which is not under the player's control, it will automatically add to the Sequence list when they are ready to perform actions.
Positioning Units in Battle Field
Figure 4 - Positioning units using linear positioning system.
Till now, ally and enemy units are just created but not positioned at the right place. And yet, there will be random number of enemy units required to be placed in a normal battle, thus, a dynamic but simple linear positioning system is used to solve this problem. As as shown on the figure, the starting point and ending point of the position range are set and the interval is set to the number of units in a line plus one. Then, the gap between the two subsequent units in a line is calculated based on the positioning range and intervals. After all, a For loop is enough for placing all the units in a line at a time.
Okay, now I will end the documentation here.
This article is credited to the author of this blog, Tiong Soon Seng.
"JUARA RAKYAT" Karnival Kerjaya dan Keluarga Kamunting 2010
I attended this event as I was selected as a representative of Game Development Programme in YKS. Well, this is my first time going to Kamunting, which is a place very close to Taiping.
We were there to promote the courses provided by YKS and at the same time, to seek for other opportunities.
This event was organized by Northern Corridor Implementation Authority (NCIA). To be sincere, I don't know anything about this authority before, and now I get to know that this authority is actually for bringing up the people, technologies for future industries and economies in Northern Corridor Economy Region (NCER) that covers Kedah, Northern Perak, Perlis and Penang. And the YKS I'm currently joining is one of the bodies which operates under this authority and is financially supported by the government.
The event was held at the Dewan Majlis Perbandaran Taiping in Kamunting and there was around 20 booths. Most of the attendees are Malays and many kids were there. Besides, YB Dato' Seri Mohamed Nazri Abdul Aziz, Minister of the Ministry of Prime Minister was invited to uphold the open ceremony. When he visited our booth and I've got my chance to demonstrated my little simple games to him and shook hand with him.
I'm quite satisfied that some of the Malay kids are interested in the game I've created and we've quite a long discussion there. And what we enjoyed the most was the cakes brought by the representative of cake baking course. Haha!
When it was lunch time, we had free 'mee rebus Muar', laksa and drinks provided by the organizer.
Here are some pictures snapped by me:
This is our booth, pretty small huh?
The stage of the Dewan Majlis Perbandaran Taiping, Kamunting.
That's me, snapped when bored.
We were there to promote the courses provided by YKS and at the same time, to seek for other opportunities.
This event was organized by Northern Corridor Implementation Authority (NCIA). To be sincere, I don't know anything about this authority before, and now I get to know that this authority is actually for bringing up the people, technologies for future industries and economies in Northern Corridor Economy Region (NCER) that covers Kedah, Northern Perak, Perlis and Penang. And the YKS I'm currently joining is one of the bodies which operates under this authority and is financially supported by the government.
The event was held at the Dewan Majlis Perbandaran Taiping in Kamunting and there was around 20 booths. Most of the attendees are Malays and many kids were there. Besides, YB Dato' Seri Mohamed Nazri Abdul Aziz, Minister of the Ministry of Prime Minister was invited to uphold the open ceremony. When he visited our booth and I've got my chance to demonstrated my little simple games to him and shook hand with him.
I'm quite satisfied that some of the Malay kids are interested in the game I've created and we've quite a long discussion there. And what we enjoyed the most was the cakes brought by the representative of cake baking course. Haha!
When it was lunch time, we had free 'mee rebus Muar', laksa and drinks provided by the organizer.
Here are some pictures snapped by me:
This is our booth, pretty small huh?
The stage of the Dewan Majlis Perbandaran Taiping, Kamunting.
That's me, snapped when bored.
Subscribe to:
Posts (Atom)