Tuesday, 20 March 2018

OOD Assessment 2

Unit 71: Object Oriented design for computer games.


Concepts and principles-

I would say that Game Maker is a lot simpler to use and easier to understand than Unreal is and the Action Event stuff is all just drag and drop, the actions are very easy to understand. In Unreal 4 the blueprinting takes a while to get your head around however when you finally do it makes sense and is all very logical. 
In terms of reusability both engines have this as you are able to make almost anything you can imagine, you are a lot more limited in Game Maker than you are in Unreal as it can only act as a 2D game engine whereas Unreal acts as both 2D and 3D. In terms of efficiency you can make a very quick game in Game Maker however it will never be as good a quality as a game you could make in Unreal 4. 


Game Object -

 In Game Maker we have to make sprites and set them as objects specifically for playable characters so that we can have something that the player can control, we can do this through the sprite editor that is built into Game Maker. We also have to make sprites for things like walls and platforms we would have in the game so that we can place them into the room and have our character and any enemies collide with them. In terms of Unreal 4, it can act as both a 3D and 2D game engine,however there is no in built sprite or model editor this means that you have to make either sprites or models in a different program and import them in to be used.

A room in Game Maker with Walls.
Walls and rooms in Game Maker are extremely easy to set up, you just create a room in the options on the left and then you can drag and drop everything into in order to flesh the game out. For example if I were to make the sprite of a platform and set up collision for it with my character i would then just drag and drop it into the room I have created to make a platform my character could jump onto. In Unreal 4 a room isn't quite as simple as it could mean many different things, is the room the entire level or simply one area of it, if we look at it in the same way as Game Maker we would take it to mean the entire level. The main comparison to walls would be and buildings or areas our character can not get through, there are several ways that this could happen for example if we made a building in Maya and imported it to Unreal then the sides of the buildings would be walls for our character since he cannot get through them. However if we also used the landscape tool to raise the ground so our character could not get past this would also act as a wall in the same sense. 

Power ups work pretty much the same way in both Game Maker and Unreal 4, you basically want to make it so that when your character touches a certain object it disappears and boosts your character in some way. To have this in Game Maker you can make it so that when your character collides with the power up object it is destroyed and gets a speed boost for example. In Unreal it is very much the same thing, In my game at the moment I have a health boost that when you walk over it a particle effect spawns at the player location and the power up disappears, the players health is then increased.



Object Properties-

We also use things called Action Event in Game Maker this is a simple drag and drop mechanic that really simplifies the whole coding mechanic. Underneath you can see an example of how you can make a health bar in Game Maker using these blue prints.

HEALTH BAR IN GAME MAKER:   https://youtu.be/kBQHGHKkePk?t=289

First you have to draw the health bar on the screen with the draw command and then set the size of it. In this example you can then set the game to reset when the health is smaller than 1.

To set the health in unreal it can be a little complicated depending on how you do it, personally I found it quite easy. You simply have to set a float variable for health so that you can increase and decrease it, you can then drag and drop a bar into the window and set its colour, sections and size on the right side of the screen.
Image result for game maker moving code

This is an example of code in Game Maker that you can use to make your character walk and jump. As you can see it is fairly simple, this shows that when the left arrow is pressed the character will move left and it also shows how far it will move.


Related image

This is the code for movement in Unreal 4 as you can see it is a bit more complex than the Game Maker counterpart, because it is a 3D engine the code has to get the characters position in the world via velocity and then uses the key inputs for movement.


After you have set the movement you would then have to set the speed at which your object will move, to do this in Game Maker is very simple, since it is a 2D engine we are working in, you can use the code below to set the speed and direction of the instance.
if keyboard_check(vk_up) speed = 2;
if keyboard_check(vk_left) direction += 5;
if keyboard_check(vk_right) direction -= 5;

It is also quite simple to set the characters speed in Unreal, you can use the blueprint below to change the max speed for your character. You can just get the variable Character Movement and Set Max Walk Speed to whatever number you like.
MaxWalk1





Actions and Events-

Scoring is a very easy concept to get you head around, there are two ways that you can achieve a good scoring system and this is by either using the action event score button or coding a scoring system in a draw event and then applying it to all of the events you need it on. You simply increase the vale by whatever you like when a certain event happens like a enemy dying for example.
It is done pretty much the same way in Unreal 4, however I find it is a lot easier to visualise the actual event happening.
Image result for scoring system in unreal 4

To make collision in Game Maker you simply add the collision event onto the character and object so that they cant go though each other. You can choose from a bunch of different events to happen when the collision takes place for example you could set the speed to 0 so the character will stop moving.Image result for game maker collision

To give collision to any of the objects you import into Unreal you first need to select keep collision and then set it to use simple as complex. This will wrap the model in a mesh that acts as the collision.
Image result for Unreal 4 use simple as complex


We can use the destroy event to get rid of any sprites in Game Maker when a certain event happens, for example if you shoot an enemy, when it collides with the bullet the sprite will be destroyed and give the effect that you have killed it. You do the exact same thing in Unreal 4, you just destroy to entity whenever you need via blueprints.


Inheritance -

Parenting in Game Maker is a very useful tool that overall saves you a lot of time and confusion. As an example if you have 3 enemies that all have the same collision event with your character you can set up a parent for all three of these and then just set up one collision event with the parent to save you doing 3 different ones. To keep it neat and keep your game structured you would use object hierarchy where parent 1 is child of parent 2 is child of parent 3. In Unreal you can 'Set Owner' of another action and then reference that owner in other actions.
Image result for parents in game maker