ASPECTS OF PLAY - WEEK SEVEN
WEEKS COVERAGE
This week i spent my time coding a basic engine that would run my game, using both gravity and speed in conjunction along with the ability to pan the background as the character moves along throughout the level.
PHYSICS
The next step in design was the physics of the engine, which would weigh down to gravity and speed of both the player and each individual type of enemy. The general idea was to keep the player at a balanced speed and gravity in between that of the enemies so then it can define how hard the enemy is in theory and keep it in a general balance.
Here is my defining point for the character, this was called upon load to define the basics of what the engine would be drawing up during it's process to access the stored data via appropriately named variables. (To note i stored this in the players MovieClip due to the most likely case that collision would be relative to the player more than anything else due to the controlled movement rather than static or continuous)
onClipEvent (load) {
_root.gravity = 0;
_root.speed = 10;
_root.landed = false;
_root.jumpHeight = 16;
}
Since they were defined i did a very simple code to allow the character to fall until he comes in contact with the surface of the ground, of which was also stored as a MovieClip to allow an instance name to be stated.
onClipEvent (enterFrame) {
_root.gravity++;
_y += _root.gravity;
if (_root.ground.hitTest(_x, _y, true)) {
_y--;
_root.gravity = 0;
_root.landed = true;
}
}
}
The code above continuously increments the gravity until it has come in contact with the ground, when it does the players position is decremented on the y-axis and gravity is stored to 0, thus stopping the character from falling through the ground. It's also noted that i set the grounds registry point to the north and the players registry point to the south, this was done to avoid any contact problems, as they only register with each other via the registry points, elsewise the player may be halfway into the floor or just fall straight through it altogether.
(The square is the placeholder for the player, the black rectangle at the bottom is the ground and the small rectangle at the top was a button i was eventually adding to toggle difficulty)
After sorting out the gravity, which kept the character to the ground i needed to allow the character to leave the ground by jumping, along with being able to move from left to right. I did this by adding to onClipEvent(enterFrame) for the players movie clip:-
if (Key.isDown(Key.UP) and _root.landed == true) {
_root.gravity = -_root.jumpHeight;
_root.landed = false;
}
if (Key.isDown(Key.RIGHT)) {
_x += _root.speed
}
if (Key.isDown(Key.LEFT)) {
_x -= _root.speed
}
This then allowed me to move the character in the 3 needed directions, thus sorting out the basis of the engine that will drive my game.
PANNING
There were a few ideas i had for panning, my original idea was to store the background as a MovieClip which would increment when the player decremented along the x axis and vice versa, therefore allowing my character to move back and forth freely within the same spot on the screen. For example:-
if (Key.isDown(Key.RIGHT)) {
_x += _root.speed
_root.background._x -= _root.speed
}
if (Key.isDown(Key.LEFT)) {
_x -= _root.speed
_root.background._x += _root.speed
}
The problem with this was that being continuously didn't give me the right feel and flow to the game, so i looked into other means of doing so. I searched around for a while and found this site:- *insert site here* which provided me with a handy tool called the "vCam" which is a Viewport coded in actionScript 2.0 to allow you to move the viewing area to where you like therefore being very handy as i managed to attach it to the player so that when he moved the camera would too, giving me the exact desired effect and smoothness that i needed.
I found out that the vCam was coded for animation but many people have used it very effectively in Flash Games and overall it worked a treat for me too. The code i used to tie the vCam to the player was as follows:-
onClipEvent (enterFrame) {
_x += (_root.character._x-_x)/4;
}
WEEKS COVERAGE
This week i spent my time coding a basic engine that would run my game, using both gravity and speed in conjunction along with the ability to pan the background as the character moves along throughout the level.
PHYSICS
The next step in design was the physics of the engine, which would weigh down to gravity and speed of both the player and each individual type of enemy. The general idea was to keep the player at a balanced speed and gravity in between that of the enemies so then it can define how hard the enemy is in theory and keep it in a general balance.
Here is my defining point for the character, this was called upon load to define the basics of what the engine would be drawing up during it's process to access the stored data via appropriately named variables. (To note i stored this in the players MovieClip due to the most likely case that collision would be relative to the player more than anything else due to the controlled movement rather than static or continuous)
onClipEvent (load) {
_root.gravity = 0;
_root.speed = 10;
_root.landed = false;
_root.jumpHeight = 16;
}
Since they were defined i did a very simple code to allow the character to fall until he comes in contact with the surface of the ground, of which was also stored as a MovieClip to allow an instance name to be stated.
onClipEvent (enterFrame) {
_root.gravity++;
_y += _root.gravity;
if (_root.ground.hitTest(_x, _y, true)) {
_y--;
_root.gravity = 0;
_root.landed = true;
}
}
}
The code above continuously increments the gravity until it has come in contact with the ground, when it does the players position is decremented on the y-axis and gravity is stored to 0, thus stopping the character from falling through the ground. It's also noted that i set the grounds registry point to the north and the players registry point to the south, this was done to avoid any contact problems, as they only register with each other via the registry points, elsewise the player may be halfway into the floor or just fall straight through it altogether.
(The square is the placeholder for the player, the black rectangle at the bottom is the ground and the small rectangle at the top was a button i was eventually adding to toggle difficulty)
After sorting out the gravity, which kept the character to the ground i needed to allow the character to leave the ground by jumping, along with being able to move from left to right. I did this by adding to onClipEvent(enterFrame) for the players movie clip:-
if (Key.isDown(Key.UP) and _root.landed == true) {
_root.gravity = -_root.jumpHeight;
_root.landed = false;
}
if (Key.isDown(Key.RIGHT)) {
_x += _root.speed
}
if (Key.isDown(Key.LEFT)) {
_x -= _root.speed
}
This then allowed me to move the character in the 3 needed directions, thus sorting out the basis of the engine that will drive my game.
PANNING
There were a few ideas i had for panning, my original idea was to store the background as a MovieClip which would increment when the player decremented along the x axis and vice versa, therefore allowing my character to move back and forth freely within the same spot on the screen. For example:-
if (Key.isDown(Key.RIGHT)) {
_x += _root.speed
_root.background._x -= _root.speed
}
if (Key.isDown(Key.LEFT)) {
_x -= _root.speed
_root.background._x += _root.speed
}
The problem with this was that being continuously didn't give me the right feel and flow to the game, so i looked into other means of doing so. I searched around for a while and found this site:- *insert site here* which provided me with a handy tool called the "vCam" which is a Viewport coded in actionScript 2.0 to allow you to move the viewing area to where you like therefore being very handy as i managed to attach it to the player so that when he moved the camera would too, giving me the exact desired effect and smoothness that i needed.
I found out that the vCam was coded for animation but many people have used it very effectively in Flash Games and overall it worked a treat for me too. The code i used to tie the vCam to the player was as follows:-
onClipEvent (enterFrame) {
_x += (_root.character._x-_x)/4;
}

ABOUT ME
Hello there, my name is Matthew Hardiman and i welcome you to my University Portfolio Site. I am currently studying a BA(hons) in Games Design and have many skills, both in and out of that area.
Any questions or help, contact me:-
EMAIL: duoversity@gmail.com
MSN: animattions@googlemail.com
Facebook: Click Here
Twitter: Click Here
Hello there, my name is Matthew Hardiman and i welcome you to my University Portfolio Site. I am currently studying a BA(hons) in Games Design and have many skills, both in and out of that area.
- Animator
- Artist/Designer
- Scripter
- Writer
- Web Designer
- 3D Modeller
- Sound/Video Editor
- Composer
Any questions or help, contact me:-
EMAIL: duoversity@gmail.com
MSN: animattions@googlemail.com
Facebook: Click Here
Twitter: Click Here



