Pages

Tuesday 9 May 2017

Object Oriented Design - Assignment 2

Object Oriented Design Overview

O.O. Design refers to the technical aspects of a game, and primarily the code, which is what I will be talking about in this assignment. I will be showing blueprint code in Unreal Engine 4 that I am using for my Killer Klowns game, and the written code I used for my Space Invaders game in Gamemaker.

Health Bar Blueprint - UE4

Since the main focus of our Killer Klowns game is the combat, the player needs to have health that changes depending on his interactions with the in game enemies, and the player also needs a visual tell so they are aware of the state of their character. To accomplish this we have used a health bar blueprint. 

The blueprint is split into two sections which have been labeled to make it easier to understand. 

Part 1
The first part of the blueprint controls the health bar and how it behaves. On the left you can see different health values. Current health, max health and health regeneration. When the player takes damage from an enemy, their health will drop, the blueprint recognizes that the players health has dropped, and updates the percentage of the health bar on screen. If the players health has dropped it then begins regenerating at a rate of 5hp per second.

Part 2
The second part of the blueprint displays the health and updates it visually so that the player can see it. 
There is also a widget called "HealthBarWidget" which is responsible for displaying the actual bar shape on the screen. In the widget you can customise the size, colour etc.
The health bar widget. You can see the bar at the bottom.
The health bar in game.
  
Health/Lives - Gamemaker - Space Invaders

In Space Invaders, when the player dies they go invisible for a short period of time and then respawn. This next code in obj_alienbullet is in a collision event with obj_player, and it checks whether the player can take damage or not. If the player is visible, then they can be hit by the bullet and they will lose 1 life, however if they are invisible (respawing) then they cannot be hit. Like the player bullet, the enemy bullet is also destroyed upon impact.




When the player dies, the game also freezes for a short period of time. During this period all bullets in the room are destroyed. To do this, I simply added this code in a step event for the player bullet and alien bullet which destroys all bullets while the enemy is invisible (respawning.)



We also want to enemies to stop moving while the player is respawning, and to do this I simply added a line at the top of the movement code in the alarm event for obj_alien. This line only lets the aliens move if the player is visible.


Now we move on to adding the lives to the player, first a variable needs to be created in the create event called live=3, and then in the step event we use code that restarts the game when the lives are lower than 0.




Health - Which Engine Do I Prefer?

For this task I prefer Unreal Engine. The blueprint is fairly simple, and I like how you can use the widget to easily see and choose whereabouts on the screen the health bar will be. Blueprints also feel a lot more organised than Gamemakers code.

Dialogue - Unreal Engine - Killer Klowns Game

For my Killer Klowns level I wanted text/dialogue to pop up on the screen when the player approaches certain houses. To accomplish this I used trigger boxes, widgets and small level blueprints. 

I placed a trigger box in front of the house that I wanted to use.


Then I created a widget blueprint called House_Dialogue1. This includes the text itself, and allows me to change the font, colour and the position of the text on the screen/HUD.


I then created a blueprint in the level blueprint that connects the trigger box with the text widget. When the player walks inside the trigger box, text pops up at the bottom of the screen and stays there until the player leaves the box.




The text shown in game.


Dialogue - Gamemaker - Brainbox Game

For dialogue in Gamemaker I used basic drag and drop events. In the player object I added a collision event with my computer terminal, and in the actions tab I added "display a message."



When the player collides with the computer terminal, a small window appears over the game displaying the message. This automatically pauses the game in the background.


The text shown in game. 
Dialogue - Which Engine Do I Prefer?

For this task I prefer game maker. The drag and drop code is really easy to understand and to use. You go into your character object, drag in a collision event, add the object you want to collide with to the event, then add an action (what you want the game to do when the objects collide.)

No comments:

Post a Comment