Categories
Uncategorised

Developer Journal : Variables and Functions

Developer Journal

As of the 15th of Monday, I’ve been learning more about using the Unreal Engine.

During this week we covered on how to use variables and functions in the blueprint system, both of these are crucial to cover as they are mainly used to store important information from the game and to make certain actions possible.

What variables can do is to give certain objects or actors within the game world certain properties using values such as; floats, integers, booleans and even strings.

“Variables are properties that hold a value or reference an Object or Actor in the world.”

unrealengine.com, 2021

Shown in Figure 1, you can see that there are some examples as to what some variables can be.

Float & Integer variables may keep track of things such as time as they use numbers as values, whilst something like Booleans can be assigned to more simpler on/off functions such as toggling a player’s light – Strings may also be used for something such as storing the player’s name.

Variable Nodes
Figure 1 (UnrealEngine.com)

Essentially, variables can be used as statistics to help record what is happening within your game. As we are currently using the blueprint system, these variables will be mostly present within our node graphs we use to structure most of the game with.

This brings us into using Functions, which can be created and stored on a singular blueprint and then can be assigned to a simple function which can be called from a different graph.

“Functions are node graphs belonging to a particular Blueprint that can be executed, or called, from another graph within the Blueprint.”

unrealengine.com, 2021

An example of how a function may be used is shown in Figure 2, this presents us with a “Take Damage” function inside a character’s blueprint. Once this function is called, it will take away some of the player’s health.

PlayerHealthFunction.png
Figure 2 (UnrealEngine.com)

The reason why this may of been done is that there may be multiple ways to take damage within the game, and instead of having to recreate the structure over again for each way it is instead assigned to a simple function which can just be called and still serve the same purpose.

Unreal uses Classes, which can contain both the variables and functions we’ve covered together. These can be used as Parents which can allow the properties within them to be inherited into other blueprints.

“Selecting a Parent Class allows you to inherit properties from the Parent to use in the Blueprint you are creating.”

unrealengine.com, 2021

Anything in Unreal can be used as a parent class, for example a parent Actor blueprint can contain properties for ammo and health – which a child blueprint can inherit.

As it is separate from the parent blueprint, we can add some specific functionality that only applies to just the child blueprint such as a unique weapon only available to the actor whilst still inheriting the functionality shared from the parent blueprint.

A more general example of how a parent system is used can be seen here on Figure 3.

Figure 3 (Grewell, C)

The parent class is a tree, and its children are different sorts of trees that have their own specific properties unique to them. The text in bold displays the new properties of each child object, whilst also inheriting the previous properties from their parent.

I personally think that learning classes, variables and functions are a great at trying to get your head around how a good chunk of the blueprinting system might work in Unreal – it also helps with programming generally.

Although I’ve already been familiar with using these in different engines and programs before such as Visual Studio, it is a good idea to keep revising them and also seeing how they may be used differently.

Bibliography

Docs.unrealengine.com. 2021. Blueprint Variables. [online] Available at: https://docs.unrealengine.com/en-US/ProgrammingAndScripting/Blueprints/UserGuide/Variables/index.html [Accessed 21 March 2021].

Docs.unrealengine.com. 2021. Functions. [online] Available at: https://docs.unrealengine.com/en-US/ProgrammingAndScripting/Blueprints/UserGuide/Functions/index.html [Accessed 21 March 2021].

Docs.unrealengine.com. 2021. Blueprint Class. [online] Available at: https://docs.unrealengine.com/en-US/ProgrammingAndScripting/Blueprints/UserGuide/Types/ClassBlueprint/index.html [Accessed 21 March 2021].

Grewell, C., 2018. Classes. [online] Medium. Available at: https://medium.com/applab/classes-d2fb62e266c0 [Accessed 21 March 2021].

Categories
Uncategorised

Developer Journal : 2D Graphics

Developer Journal

As of the 8th of Monday during March, I’ve considered making a start on researching for our 2000-word essay on a technical discussion within the field of games development – we are given several topics to chose for this.

What’s important is that our discussion must be substantiated with evidence throughout it, so research is considered important for this task.

I’ve decided for my topic that I was going to do graphics in 2D games, so to help familiarize myself I’ve delved into researching different image file types such as Raster and Vector images.

Figure 1 (Wikipedia)

Vector graphics (See Figure 1) are known as the most flexible of the image types, they use mathematical formulas to form which can be easily retain a high quality no matter how much their shape and size changes.

“This means that the paths and objects that make up a vector image are individually scalable, preserving the quality of the image when scaling it up or down.”

Dawn Kuczwara, 2021

However, vector graphics are poor at creating realistic images due to this as they are best suited to more minimal styles.

Raster graphics are created by assembling pixels together to create graphics, they’re also the most common format of image types on the web – they also take up much less data than vectors.

“Raster images are ideal for realistic images, like photographs”

Dawn Kuczwara, 2021

They’re also capable of portraying realistic images much better than vectors can (See Figure 2).

Figure 2 (olypress.com)

The quality of Raster images however can degrade once their size is manipulated from the original proportions.

As Vector graphics are scalable, they’re ideal for features such as text fonts and even icons like logos. Figure 3 shows an example of what a Raster and Vector graphic looks like once it becomes scaled up.

Figure 3 (Amit Saxena)

I think that both image types can be vastly useful for many different situations within games, a good example would be how User Interfaces can use Vector graphics so that their quality stays the same regardless of how big a user’s screen is.

However Raster graphics may be better for details that don’t change size as much such as textures for models or scenery, it can also help with saving up memory within the game so Raster graphics may be good to consider if optimization needed to be improved upon.

Bibliography

Kuczwara, D., 2021. Raster Images vs Vector Graphics – Curotec. [online] Curotec. Available at: https://www.curotec.com/insights/raster-images-vs-vector-graphics/#:~:text=Vector%20graphics%20are%20known%20as,created%20with%20individual%2C%20colored%20squares.https://www.curotec.com/insights/raster-images-vs-vector-graphics/#:~:text=Vector%20graphics%20are%20known%20as,created%20with%20individual%2C%20colored%20squares. [Accessed 16 March 2021].

En.wikipedia.org. 2021. Vector graphics. [online] Available at: https://en.wikipedia.org/wiki/Vector_graphics [Accessed 16 March 2021].

Saxrena, A., 2017. What Is Vector Graphics [An Introduction]. [online] Dignitas Digital. Available at: https://www.dignitasdigital.com/blog/what-is-vector-graphics-an-introduction/ [Accessed 16 March 2021].

Olympus Press – Commercial Printing. 2013. Vector & Raster Graphics in Offset Printing – Olympus Press – Commercial Printing. [online] Available at: https://olypress.com/vector-vs-raster-graphics-in-printing/ [Accessed 16 March 2021].

Categories
Uncategorised

Developer Journal : Unreal Basics

Developer Journal

As of Monday the 1st on March, we learnt Unreal during the week. We learned the basics of the engine and how to use its user interface.

When we first started, we had to set our project settings. Within the project settings there are many ways to customize your project such as whether you want to use the blueprint system or C++ – We also have the option to set our quality and platform. (See Figure 1)

Project Settings Fullscreen
Figure 1 (docs.unrealengine.com)

We are going to be using blueprints for our first year of using Unreal, this is essentially a Visual Scripting system. This is a node-based interface which is used to create gameplay elements, used to define object-oriented classes or objects in the engine.

“This system is extremely flexible and powerful as it provides the ability for designers to use virtually the full range of concepts and tools generally only available to programmers.”

docs.unrealengine.com, 2021

This tool is very helpful to many beginners, as it is a simplified version of programming. This can also be especially useful for making small prototype projects as the blueprint system proves to be easy to use to create these types of projects within a short amount of time.

Another thing we learnt about was using Actors within a scene, this is any object you can place within a level. This can range from a simple shape to characters and even some lighting. (See Figure 2)

Place0.png
Figure 2 (docs.unrealengine.com)

Actors can also be modified in a multitude of ways, they are capable of many 3d transformations as well as housing some properties, this means they can be highly customizable.

“Actors are a generic Class that support 3D transformations such as translation, rotation, and scale.”

docs.unrealengine.com, 2021

These are basically what we will be mostly placing within our level, Actors can be thought of as containers that can hold special types of objects known as “components”.

Figure 3 (docs.unrealengine.com)

Many different types of these components can control how Actors work within the engine – this can range from how they’re rendered to how they move.

As shown in Figure 3, this is an example of what an Actor hierarchy of components looks like. As you can see, there are several components attached to this object which enable a mesh to show as well as some effects such as audio to emit from it.

I think that so far, learning Unreal has been quite interesting and I’m excited about getting around to using the engine. I’ve already used several different game engines before, such as Construct 3 or using Phaser with Visual Studio – however I don’t have as much experience with using 3d engines, So this’ll mostly be new and exciting to me.

Bibliography

Docs.unrealengine.com. 2021. Get Started with UE4. [online] Available at: https://docs.unrealengine.com/en-US/Basics/GettingStarted/index.html [Accessed 11 March 2021].

Docs.unrealengine.com. 2021. Blueprints Visual Scripting. [online] Available at: https://docs.unrealengine.com/en-US/ProgrammingAndScripting/Blueprints/index.html [Accessed 11 March 2021].

Docs.unrealengine.com. 2021. Placing Actors. [online] Available at: https://docs.unrealengine.com/en-US/Basics/Actors/Placement/index.html [Accessed 11 March 2021].

Categories
Uncategorised

Developer Journal : Digital Wellbeing

Digital Wellbeing

As of the 22nd of Monday, I’ve decided to cover a topic on digital wellbeing for my developer journal.

Digital Wellbeing is the idea of a state of personal wellbeing that’s from the use of technology, it can simply mean the improvement of a person’s well being through the use of media – but this can also include how the person maintains their relationship with technology.

“Digital wellbeing considers the impact of technologies and digital services on people’s mental, physical and emotional health”

Alicja Shah, 2019

People can use technology to stay in touch with distant family and friends, as well as use it for personal work – people are connected more than even in the world today. However, prolonged use to technology has negative side effects too as it can lead to psychological and physical issues.

Physically, staring at a screen for too long can induce digital eyestrain upon a user. This is because of exposure to Blue Light on most digital devices, overuse of this may lead to eyestrain and focusing problems.

“Digital eyestrain refers to blurred vision and other symptoms such as burning, stinging or tearing of the eyes associated with prolonged use of digital devices.”

Alicia Rohan, 2016

When using any digital devices, it is important to consider the 20/20/20 rule. (See Figure 1)

Debunking digital eyestrain and blue light myths
Figure 1 (medicalxpress.com)

This rule explains that to maintain a comfortable vision when using digital devices, for every 20 minutes of digital device use you have to look away for 20 seconds focusing on something else 20 feet away – this can help reduce eyestrain.

Another issue that could arise from the use of technology on the psychological side would be the overuse and dependence on technology, prolonged use can lead to issues such as isolation and depression.

“Young adults aged 19–32 years found that people with higher social media use were more than three times as likely to feel socially isolated than those who did not use social media as often.”

Timothy J. Legg, 2020

It is also important considering that we are also currently living during the coronavirus, which means a lot of people are isolated already in-doors to stay safe and have to rely on technology to communicate with most of their friends.

Finding ways to reduce social media use can however help reduce feelings of isolation in some people.

I think that personally, I have managed to keep myself well kempt when it comes to the internet. As I already have a lot of experience compared to other people, however it is sometimes hard to keep up with my health as I sometimes spend too much time on my computer – this can affect my sleep as well as my workflow.

Bibliography

Marsden, P., 2020. What is Digital Wellbeing? A List of Definitions. [online] digitalwellbeing.org. Available at: https://digitalwellbeing.org/what-is-digital-wellbeing-a-list-of-definitions/ [Accessed 28 February 2021].

Shah, A., 2019. Defining digital wellbeing – Jisc Building Digital Capability Blog. [online] Jisc Building Digital Capability Blog. Available at: https://digitalcapability.jiscinvolve.org/wp/2019/09/03/defining-digital-wellbeing/ [Accessed 28 February 2021].

J. Legg, T., 2020. Negative effects of technology: Psychological, social, and health. [online] Medicalnewstoday.com. Available at: https://www.medicalnewstoday.com/articles/negative-effects-of-technology#:~:text=Social%20media%20and%20mobile%20devices,on%20developing%20children%20and%20teenagers. [Accessed 28 February 2021].

Rohan, A., 2016. Debunking digital eyestrain and blue light myths. [online] Medicalxpress.com. Available at: https://medicalxpress.com/news/2016-04-debunking-digital-eyestrain-blue-myths.html [Accessed 28 February 2021].

Categories
Uncategorised

Developer Diary : Tutorial

Development Activity

As of Monday the 15th, we had an independent study week where we were given the chance to work on anything we had to catch up with during our spare time. For this week, I chose to start and finish my tutorial task.

For this task, we needed to make a Phaser Tutorial on anything of our choice. I decided to do a basic tutorial on Matter that many beginner level users would be able to learn how to set up their own scenes as well, it will cover most of how to set it up and how the user can create small simple contraptions using the engine.

Writing a coding tutorial can better help develop a basic understanding of your subject matter, it can help you to build something small and simple at a deeper understanding – this understanding can aid you in future projects.

“It requires that you understand what you’re doing/building enough to be able to explain it to somebody else”

ryanjyost, 2019

A great way to start your process on this would be to try and pick up a topic you want to learn and write about, which could just about be anything you’re not so experienced with.

I felt as if writing a tutorial on the basics of Matter from the ground up has helped to show me understand what the most simplest way to start on a foundation for a program using Phaser, as I’ve managed to explain in detail most of what goes into making the program work at a core level.

Figure 1

After having explained how to put some simple objects with attributes together, throughout the tutorial I’ve also provided links to the Phaser 3 documents that the reader can check to further entice them into starting to explore and experiment with what they can do in the program.

I’ve also provided some in-game screenshots of what I was able to achieve using this simple level of understanding, within the tutorial I managed to put together a small simple physics contraption that made use of constraints. (See Figure 2)

Figure 2

I think that I’ve managed to provide a decent tutorial for anyone without much prior knowledge to using Phaser on how to set up a simple scene, I’ve also left a lot of what you could possibly do in the guide as open-ended as possible to encourage experimentation by leaving many links to the Phaser documentation the user could use to expand upon.

Matter I feel is a good way to introduce beginner level programmers to using Phaser, it touches upon how these programs are usually set up which can help to further a beginner level user’s understanding of the basics, there’s also plenty of attributes you can assign to even basic objects that make it fun to experiment and learn with.

It’s also got many examples you can try on the Phaser website:

https://phaser.io/examples/v3/category/physics/matterjs

Although the coding in the tutorial is kept as brief and as simple as possible, I feel as if the next time I get the chance to write a tutorial I could do something slightly more complex to help further encourage myself to learn more new things about Phaser.

Bibliography

Ryanjyost.com. 2019. How to write a coding tutorial. [online] Available at: https://www.ryanjyost.com/how-to-write-a-coding-tutorial/ [Accessed 23 February 2021].

photonstorm.com, P., 2021. Phaser – Examples – physics – Matterjs. [online] Phaser.io. Available at: https://phaser.io/examples/v3/category/physics/matterjs [Accessed 23 February 2021].

Categories
Uncategorised

Developer Journal : Presentation

Presentations

As of the 8th of February, this week was about preparing and starting our presentations on Entry Level Games Developer jobs.

We were put into our seminar groups for this project, so we had to work as a team to put together a single presentation – each of us had to find and pick our own entry level job we wanted to present. (See Figure 1)

Figure 1

We planned on doing three slides each; the first would be a brief description of the job and company, second would be about the key skills required to get the job and last would be our own thoughts and conclusion about the job – since our presentation also had to be roughly around 20 minutes long, we gave ourselves 5 minutes to speak through our slides.

One important thing we had to consider for our presentation was to keep things simple, so we made sure that most of the text on our slides were a big size and written briefly.

“You should be able to communicate that key message very briefly. The important thing is to keep your core message focused and brief.”

skillsyouneed.com, 2021

Before, our slides were packed with text and had a much more smaller font – this proved to be too hard for people to read in a presentation. Due to this, we changed our font size to something much more bigger and cut off most of the unimportant text.

We moved most of this information into our speaker notes, which we’d look upon whilst presenting. (See Figure 2)

Figure 2

Another important thing to cover here which would help with our presentations would be to consider the Dual Coding Learning Theory, this is where both images and written information are combined to provide an easy visual and verbal way for people to process information.

“Dual coding is combining words and visuals such as pictures, diagrams, graphic organizers, and so on. The idea is to provide two different representations of the information, both visual and verbal, to help students understand the information better.”

Megan Sumeracki, 2019

Following these rules, we cut the amount of content we intend to include on a slide and instead present everything in a simple concise way.

We can also use images to help our readers to get a rapid gist of what we’re talking about.

Information is lined up neatly and written briefly to give our readers confidence, most of the details are saved for when we start to speak about our slides.

“Visuals are powerful for communicating complex ideas in an efficient way; it takes a great many words to describe the simplest of images”

“Cut the amount of content we intend to include on a slide or resource; chunk the information into headings that stand out”

Futurelearn.com, 2021

Using a combination of both of these, ideas we’ve managed to create a slide that’s quick to the point and comes across as clear as possible. Here you can see the brief description of the job and company as well as some images of their logo and most well known games within the industry. (See Figure 3)

Figure 3

I think that I managed to learn quite a bit about how important it is to condense information when making something such as a presentation, I learnt that with things such as Dual Coding Learning Theory that there are better and simpler ways to get messages across.

This was fairly important for this lesson, as we were given a 20 minute time limit to do our presentations, so we had to focus on getting our message out as clearly as possible rather than outputting as much information that can overwhelm the readers.

I think that maybe if I were to try and do another presentation, then I should focus more on getting a good balance between text and images. As although we shortened most of our work, we didn’t provide as much images to show to our audience.

Bibliography

skillsyouneed.com, (2021. Top Tips for Effective Presentations | SkillsYouNeed. [online] Skillsyouneed.com. Available at: https://www.skillsyouneed.com/present/presentation-tips.html [Accessed 11 February 2021].

FutureLearn. 2021. An introduction to Dual Coding Theory. [online] Available at: https://www.futurelearn.com/info/courses/technology-teaching-learn-ing/0/steps/53322 [Accessed 11 February 2021].

Sumeracki, M., 2019. Dual Coding and Learning Styles — The Learning Scientists. [online] The Learning Scientists. Available at: https://www.learningscientists.org/blog/2019/6/6-1 [Accessed 11 February 2021].

Categories
Uncategorised

Developer Journal : Rewards in Games

As of the 1st of February, we covered responses to rewards in games within our lecture.

Rewards can be anything players earn from gameplay, players are given achievements for accomplishing certain tasks and improving their performance with scoring, these can be a good incentive to keep the player interested and playing your game.

“Rewards and scoring should also correlate to what you want people to learn and the feedback you want to offer to them re: their performance.”

Sharon Boller, 2013

Rewards can be good teaching tools for rewarding the player with feedback for specific tasks you want them to complete, this can be an effective way to teach certain gameplay elements you want to teach by offering them something in return such as some loot. (See Figure 1)

Image result for quest rewards
Figure 1 (runescape.wiki)

However there is a psychological effect to this, whenever we receive an award this triggers a special behaviour in our brain that allows it to get stimulated by the process of receiving a reward – This in turn leads us to seeking out more rewarding stimuli.

An example of a game that uses rewards like this could be “Pokémon Go”, which is an Augmented Reality Game about collecting Pokémon. Within it, you can collect Pokémon of all sorts of rarities – this is done using a schedule of reinforcement called a Fixed Ratio: This is where the reward occurs after a certain amount of actions.

In the Fixed Ratio schedule of reinforcement, a specific number of actions must occur before the behaviour is rewarded.

theconversation.com, 2016

If the user catches enough Pokémon, they will be rewarded with a level up, or even possess enough candy to evolve their Pokémon – There is also a slim chance the players will end up coming across rare Pokémon, which keeps players interested. (See Figure 2)

Figure 2 (theconversation.com)

This is what makes the app addictive, as players will continue to check the app regularly throughout the day due to these regular reward schedules.

In my personal opinion, I think rewards can be a good as a learning tool to the player and encourages them to play better at the game via scoring systems. This can help the player to enjoy the game much more through a fun system that rewards and incentivises good play.

However, I disagree with using rewards to keep players addicted through tedious gameplay as it means your game gets less fun and becomes more of a chore to play through. Many games use this to further desensitise the player’s stimuli and keeps them playing for much longer.

Bibliography

Boller, S., 2013. Learning Game Design: Rewards and Scoring | Knowledge Guru. [online] Knowledge Guru. Available at: http://www.theknowledgeguru.com/learning-game-design-rewards-scoring/#:~:text=Rewards%20can%20be%20anything%20players,Some%20games%20have%20them.&text=If%20the%20task%20in%20a,for%20performance%20rather%20than%20completion. [Accessed 11 February 2021].

The Conversation. 2016. The power of rewards and why we seek them out. [online] Available at: https://theconversation.com/the-power-of-rewards-and-why-we-seek-them-out-62691 [Accessed 11 February 2021].

RuneScape Wiki. 2021. Post-quest rewards. [online] Available at: https://runescape.wiki/w/Post-quest_rewards [Accessed 11 February 2021].

Categories
Uncategorised

Developer Diary : Matter Physics

Development Activity

For this week, we were given the task to use experiment with “Matter”, which is a plugin for Phaser which enables physics. This is different from the other games we’ve been developing as we haven’t used any other physics mode besides “Arcade”.

“The Phaser Matter plugin provides the ability to use the Matter JS Physics Engine within your Phaser games. Unlike Arcade Physics, the other physics system provided with Phaser, Matter JS is a full-body physics system.”

photonstorm.github, 2021

Using “Matter” will give us a full proper physics system that is dynamic, it will also allow us to create many things such as rigid bodies and physics constraints – which is what I’ve added in for my project.

One of the first things I started to try and implement into the project, was a functional bridge that consists of many individual objects constrained to each other (See Figure 1).

Figure 1

This bridge was created for the first scene of the game, and is meant to assist the player in getting past the first pit.

Within the create function of the code, to create this bridge I first had to define a variable to group multiple objects together, then create another for the bridge itself – the bridge variable will be assigned to be added as a “.stack” because we plan on using multiple instances here.

Using our assigned variable from earlier, we create a chain with our bridge and then add a world constraint at our first and last instances created with at the chain – world constraints help to fix these ends of the bridge onto a specific Y and X axis without the object falling over.

“Constraints are used for specifying that a fixed distance must be maintained between two bodies (or a body and a fixed world-space position). The stiffness of constraints can be modified to create springs or elastic.”

brm.io, 2021

The final constraint for the other end of the bridge is added by specifying the total length of the bridge’s bodies in an array and inputting the similar code as before, only changing the coordinates (See Figure 2).

Figure 2

Another addition to the first scene I’ve added was a simple ball that’d block the player’s way, players traversing the bridge will have to try and jump over the ball or try to roll it into a nearby pit to use as a small platform (See Figure 3&4).

Figure 3
Figure 4

Creating this object was fairly simple, as I just had to preload an image of a circle I had and then in the game’s create function I included a new variable called “ball” which simply added in my image.

Although, this doesn’t mean the image spawned in itself has the collision of a ball, so we have to declare that the object has circular collision by using “.setCircle”.

Figure 5

The second scene of the game introduces a new mechanic where the player is able to click and drag onto certain objects, they use this mechanic later on in the level to try and build a staircase to the level’s goal point.

The player’s first obstacle in this level as you can see is a whole bunch of crates blocking their way, alongside one single image one tutoring the player that these blocks can be dragged.

Figure 6

For this to work, I implemented special objects that have been assigned a collision group referred to as “canDrag” (See Figure 7).

Figure 7

I’ve also implemented an extra control using the mouse called “mouseSpring” which enables the player to pick up certain objects with the mouse, this is helped by including a collision filter which enables it to only work on certain objects such as our “canDrag” objects (See Figure 8).

Figure 8

An effective way this mechanic is used is for a puzzle at the end of the level where the player’s entrance to the goal point is being blocked by several crates (See Figure 9).

Figure 9

Using the drag mechanic, they’re able to move the boxes out of the way and can even arrange them into a staircase to help themselves climb up onto the platform easier (See Figure 10).

Figure 10

I found learning Matter in Phaser to be quite fun, as I enjoy a lot of physics games. We were also given some time to try and experiment with this project more, which felt like there was some creative freedom to it.

Although one issue I have is that it is hard to find documentation on Matter, some features such as the bridge had no texture or fill so they couldn’t be seen unless debug mode was enabled – I could not find anything online that could help me with this – However, this was only a small issue I had with the project, as I feel the rest of it went fine.

Bibliography

Photonstorm.github.io. 2021. Phaser 3 API Documentation – Class: MatterPhysics. [online] Available at: https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Matter.MatterPhysics.html [Accessed 2 February 2021].

photonstorm.com, P., 2021. Phaser – Examples – Drag Filter With Pointer. [online] Phaser.io. Available at: https://phaser.io/examples/v3/view/physics/matterjs/drag-filter-with-pointer [Accessed 2 February 2021].

photonstorm.com, P., 2021. Phaser – Examples – Bridge. [online] Phaser.io. Available at: https://phaser.io/examples/v3/view/physics/matterjs/bridge [Accessed 2 February 2021].

Brm.io. 2021. [online] Available at: https://brm.io/matter-js/docs/classes/Constraint.html [Accessed 3 February 2021].

Photonstorm.github.io. 2021. Phaser 3 API Documentation – Namespace: Collision. [online] Available at: https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Matter.Components.Collision.html [Accessed 3 February 2021].

Categories
Uncategorised

Developer Diary : Maze

Development Activity

For this week, we’ve been working on a maze game that’d randomly generate a maze each time the player opened up the game. I learnt to try and implement textures from a tile sheet of my own as well as trying to generate my own simple structures into the maze.

First task I tried to do was implementing my own textures into the game, this required me to add two extra pngs to the assets folder of the game; “tilesDecoration” for randomized decorations, “tilesStructure” for the tiles of the structures that’ll be appearing throughout the game (See Figure 1).

Figure 1

How this works is that I’ve used a constant variable to define each tileset asset and gave them each a different ID, having these set as constant variables means that they cannot be altered by the program during regular execution – this is important as we will be reusing most of these values during our code.

Constants are useful for defining values that are used many times within a function or program. … By using constants, programmers can modify multiple instances of a value at one time.

Techterms, 2013

Once the constants are created, we then create another variable which will act as a layer within the game.

As shown in the bottom half of Figure 2, you can see the first three lines of code using our constant variables for every specific layer included with a unique ID for each. Afterwards the maze will then generate these tiles into the game.

Figure 2

Before we generate our tiles onto a path, we need to specify which tiles are needed to spawn and to place them in a random order. This is done within our MazeTiles.js file.

As shown in Figure 3, we have declared static variables for how we’d want the order of these tiles to be generated. For the main tilesheet, the variables are; “GetFloorTile”, “GetWallTile”, “GetHomeTile”, “GetDiasTile” and “GetWinTile”.

The first three will pick a random tile between a specific point, such as “GetFloorTile” choosing the first 16 random tiles to arrange onto a layout. Other variables such as “GetWallTile” and “GetHomeTile” will start off on a specific number as indicated by the number after the “return” function at the start and then add on the random number to choose between.

For our other tilesheets, we would have to use “GetDetailTile” as we have a different arrangement on tiles on these sheets, all of which being a selection of 4 tiles (See Figure 3).

Figure 3

As shown here in Figure 4, this is how our tiles will be arranged in the game. This code here generates our tiles onto a certain position within a unit (This is each area within our maze), it will generate some floor tiles on the area first, and then some wall tiles on the edges of the unit – these typically have been assigned the “groundLayer” variable.

Near the bottom, you can also notice the “detailLayer” variable being used for the centre fill, this fills the centre of each unit. However, our detailLayer has been assigned a random chance of spawning each tile by 10% chance (0.1 out of 1).

This makes details appear much less often and makes each room feel more unique and different from eachother.

Figure 4

As shown in Figure 5, this is what all of our tile arrangements look like within the game. You can see our walls and floors being arranged on most of the main units with some sprinkles of tiles from our “detailLayer”.

On the bottom right of the image is the custom unit I’ve created, which uses unique tiles from the “structureLayer”.

Figure 5

Unit layouts in the code are generated by detecting a place within the game space, and spawning some tiles within that designated area.

As Shown in Figure 6, the starting room for instance, looks for the middle of every layout by dividing the room’s height and width in half and placing the tiles directly in this spot.

Figure 6

For my own custom unit, I decided to go with a room that would be generated within a random place in the level.

To do this, I declared some variables at the start of the code which would be assigned a random number multiplied by the level’s height and width to give it some some accurate coordinates to be placed within as shown by Figure 7.

Figure 7

To get the position of the room, this line of code here is assigned the variables and inserts them as the room’s coordinates as seen in Figure 8.

Figure 8

The code here in Figure 9 shows that if one of the units positions within the level is equal to that of our randomUnit, then it will spawn the room here as well as assigning it a unique tileset compared to our other unit.

Figure 9

As shown by Figure 10 & 11, the room spawns in completely random places within the level – sometimes directly next to the middle of the level or either the far edges of it.

Figure 10
Figure 11

One particular issue that arises from this however is that there is a random chance that this will spawn on top of our player spawn.

I consider this project to be mostly a success, as I was able to implement most of what I had planned as well as tweaking them slightly to make improvements.

One problem I’d struggled with before was trying to implement multiple tilesets into the scene as I had tried to use a single variable before, however using multiple constant variables to assign new tileset images with unique IDs had worked out for me.

This meant that any new tileset I’d add into the assets folder would be given a fresh ID to help the code distinguish it from the others – I feel as if I have gotten a slightly better grasp on the concept of using constant variables from this.

Bibliography

Docs.microsoft.com. 2018. Const Statement – Visual Basic. [online] Available at: <https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/const-statement> [Accessed 26 January 2021].

Techterms.com. 2013. Constant Definition. [online] Available at: <https://techterms.com/definition/constant> [Accessed 26 January 2021].

Categories
Uncategorised

Developer Diary : Tank Game

Development Activity

For this week, we worked on a tank game during Tuesday in class using Phaser. Included in the project, we were also tasked to add on at least two customizations for the game as well.

The two addition I have decided to add to the game was a UI element that displayed the player’s current health, and some health pickups that dropped by random chance from defeated enemies (See Figure 1).

Figure 1

To add the text, I created a variable called ‘healthDisplay’ and assigned some text to it.

This text would subtract the player’s current ‘damageCount’ and ‘damageMax’ which would then display the amount of hitpoint’s the player has (See Figure 2)

Figure 2

Another important thing I added was to set the depth of the UI display to a high number, this is so that the UI can be drawn above most of the objects in the scene – this prevents anything from obscuring it such as enemies and projectiles.

The depth is also known as the ‘z-index’ in some environments, and allows you to change the rendering order of Game Objects, without actually moving their position in the display list.

The default depth is zero. A Game Object with a higher depth value will always render in front of one with a lower value.

Phaser 3 API Documentation, 2021

User interfaces are known to be specially important within games as they can display vital information to the player such as health, ammo or any general hud element that player has to keep track of.

This is typically why user interfaces are always on front, as obscuring them may prove to be unfair and frustrate the player from keeping track.

I’ve also made sure that the health user interface updates within the player’s bullet collision function as shown in Figure 3.

Figure 3

This is fairly simple as it is similar to our other line from before, however instead of adding text we are just setting the text in our variable to update the player’s health by setting it to their current damage variables.

The Player’s ‘damageMax’ is set to 20, this means the max amount of damage they can take is 20 hit points, when they take a hit their ‘damageCount’ goes up by one.

Figure 4

As shown by Figure 4, this is the player’s health as normal when unaffected. So the sum in the text we set is essentially 20 subtracted by 0, which displays full health.

For the pickups, I used a new javascript file and added a pickup class that I’ll be extending.

Figure 5

What Figure 5 is essentially showing is that any variable that appears from the ‘PickupHealth’ class from this file will inherit the following functions.

Amount, which is the number of health given back.

An enabled physics body as to make sure collisions can work with each object inheriting from the class.

For the pickups, I plan for them to randomly drop from defeated enemies, Which is where the variables for them will come in.

Figure 6

As shown in Figure 6 within the main scene’s code, I added a new variable called ‘randNumber’, what this does is that it currently has a number set to 0 at the start of the code.

However each time an enemy tank is defeated, within their ‘IsImmobilizeed’ function the ‘randNumber’ variable is called upon and is changed into a random number from 0 to 4 using the ‘Math.Floor’ and ‘Math.random’ features.

If the variable’s number matches the if statement’s conditions, then a new variable is created within the function using our recently created ‘PickupHealth’ class.

Figure 7

Once the player collides with the pickip, the function calls for ‘burgerHitPlayer’. This function essentially takes away one point of the player’s damage count using the pickup’s ‘amount’/

It is also noted that the text of the user interface from earlier is updated too.

Figure 8

Figure 8 shows a before and after of the player picking up health, the top image shows the pickup’s being spawned into the level via enemy drops.

Once the player collides with these, they disappear and the player’s health interface increases.

Although this is most of what I’d done this week, if I were to of had more time to expand upon this game then I would include possibly more pickup types with different functions for the player to experiment with.

However I am pleased with how far I managed to get and feel as if I have a better understanding of how to implement features such as these.

The bit I enjoyed doing the most was trying to make it so my pickups and health interface worked together, this was because it was quite satisfying to implement two features that both came hand in hand – picking up health would directly involve the user interface to change and to keep track of the player’s hit points.

One of the hardest parts for me to figure out was trying to make it so the pickup drops would be randomly dropped from enemies, the issue was that I wanted to implement the random chance as its own function rather than including it in an already existing function – as this was hard to figure out due to many issues trying to get its values to carry over to the enemy’s function. I thought it would be simpler to implement them both into the same function instead, however this is something I could possibly look into doing more efficiently.

Bibliography

photonstorm.com, P., 2021. Phaser – Examples – Ui Scene. [online] Phaser.io. Available at: https://phaser.io/examples/v3/view/scenes/ui-scene [Accessed 20 January 2021].

Photonstorm.github.io. 2021. Phaser 3 API Documentation – Namespace: Depth. [online] Available at: https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Components.Depth.html [Accessed 20 January 2021].