Maths and Programming

Vectors and Trig:

Trigonometry is used both in the field of designing objects, characters and sets, as well as in movement systems for said variables. Whether its via moving an object, turning and moving an object at a certain speed. A lot of games use triangles for modelling, this is because of the fact that the three pointed shape of a triangle form objects subtly (aka you cant see the triangles) unlike their brother, squares, which is more obvious to the naked eye.

Trigonometry is used in rendering, modelling and character design.

Phythagoras’ theorem is a squared + b squared = c squared. It is used to find the length of sides on a triangle. Trigonometry is essentially used to help us find. The calculator functions sin, cos and tan are used to work out the other sides or angles. Sin being opposite/hypotenuse, cos being adjacent/hyp and tan being opp/adj. SOHCAHTOA can be used to remember there functions, SIN, OPP, HYP= SOH, COS, ADJ, HYP = CAH, TAN, OPP,ADJ =TAN

So, if we wanted to find out a new angle on a triangle, we find out what angles we know, and use the corresponding sin, cos or tan function.

A Vector is a force with both direction and magnitude, it is the way and speed an object goes. examples would be the way a light is reflected from the sun, the way a character flies when punched in smash bros, or the way an object bounces because of a trampoline (as well as the trampoline itself).

Numeral Systems:

Number systems can be anything, whether that’s dozens, with a base of 12, tally’s, with a base of 5, or our main numeral system used by everyone, decimal, with base 10. so we go to 9, and restart from 1 as we have no more symbols (10-19 and repeat)

Binary is used in computers, using only two digits. 1 and 0 are used because computers are just a series of switches, 1 for on, 0 for off. so 0 is 0, 1 is 1 but 2 would be 10, and 3 would be 11. Binary is mainly used to allow computers to perform large calculations easily, as well as to store numeral information easily.

Hexadecimal adds characters up to base 16, is is basically decimal with letters up to F afterwards. so if we have 9 then add 1, we get A which equals 10, then if we add 6 to get sixteen, we get 10. it is used to be a more readable version of binary. Hexadecimal is used in places like Youtube HTML’s, Among us codes and many many other places.

Conversion:

Firstly, converting binary to decimal. To convert, we first need to flip all the numbers, so say we have 101010, we make it 010101. Next, we add 1 to the number, so it would be 10110. Lastly, we convert the result to base 10, which makes it 22.

To convert decimal to binary, we simply want to take our number, and divide by 2 until we have a result that equals a 1 or a 0. So, if we take my age, 18, and first divide it by 2, we get 9 with remainder 1. Next we divide by 2 again and do the same again and again until we have the number. We put the MSB which is the most significant bit at the start, which would be 10, and the LSB being the least significant bit at the end, this would be 010. So we finish with 10010.

Next, decimal to hexadecimal. If the decimal number is a digit between 1-16, the result is the same. However, if higher, divide the number by 16, then divide by 16 again. Continue this process of dividing by 16 and noting the results until you have a number below 16. when the last digit is below 16, the quotient will be less than 0 and the remainder will be the digit itself.

Game Diagrams:

This image has an empty alt attribute; its file name is image-1.png
This image has an empty alt attribute; its file name is image-2.png

Activity diagrams are useful in games as they allow a coder to preplan the options of their game. Using diagrams like these are especially useful in games with a lot of decisions, like the telltale games or games like monkey island.

This image has an empty alt attribute; its file name is image-4.png

Revision work

Sudocode = immotation code, comes from latin

therefore, true random code is not true, it is sudorandom

if would be described as a conditional statement

Int stores decimal numbers

Float stores

String stores text informtion

bool stores binary numbers

Dot products

A dot product is the angle between two vectors

x times x + y x y

1.) (2,-7) . (3,3)

2 x 3 + -7 x 3 =

6 + -21 =

-15

2.) (-1.4,5.2).(-5,-0.5)

-1.4 x -5 + 5.2 x -0.5 =

-6.4 + -4.7=

-11.1

(17,-7,0.5)

(07,04,02)

17 -7 0.5 17 -7 0.5

7 4 2 7 4 2

X = (-7 x 2) – (0.5 x 4) = -14 – 2 = -16

Y =(0.5 x 7) – (17 x 2) = 3.5 – 34 = -30.5

Z =(17 x 4) – (-7 x 7) = 68 – -49 = 117

(17,-7,0.5) x (7,4,2) = (-16, -30.5, 117)

now to work out the magnitude

-16 x – 16 + -30.5 x -30.5 + 117 x 117 =

256 + 930.25 + 13689 =

14875.25

which has the square root of = 121.964134072

(17,-7,0.5)

(-16, -30.5,117)

X = (17 x -16) = -272

Y = (-7 x -30.5) = 213.5

Z = (0.5 x 117) = 58.5

272 + 213.5 + 58.5 = 544

in conclusion, a dot product is an algebraic product which takes two vectors and combines them to one singular number. after this, a cross product is a similar thing however it is used to calculate movement in a three dimensional space.

I’m gonna revise for the test by individually going through each class presentation and write notes on this page. I’ll answer any example questions in said presentations on here as well as coming up with original ones for the parts I think would be good to. I will add any blog posts needed with this as I missed some while absent because of COVID.

Matrixes

A matrix is something that carries all information about scale, rotation and position for a given model or sprite. Everything in a game whether it be enemies, npcs, the camera and even the player character are in a matrix.

Below, we see what happens to a matrix when using a scalar of two. Pretty self explanatory

Here are some more examples of scalars:

Finally, we have an example of multiplying a matrix by another matrix. To do this, we first multiply the first matrix column (horizontal) with the second matrix first row (vertical)

After this, we add each separate results together, and we have our first number

So; 1 x 2 = 2, 2 x 3 = 6, 3 x 9 = 27

2 + 6 + 27 = 35

After we multiply all the rows by column one, we move on to the second column and repeat our steps

Component Based Software Engineering

“a branch of software engineering that emphasises the separation of concerns with respect to the wide-ranging functionality available throughout a given software system”

Component based development is a type of development that makes the design and development more prominent using reusable software components.

The essential elements of component based software engineering include:

  • Interfaces
  • Naming
  • Meta Data
  • Interoperability
  • Customisation\
  • Composition.
  • Evolution Support
  • Packaging and Deployment

And the main components are:

  • Functionality
  • Reliability
  • Efficiency
  • Usability
  • Maintainability
  • Portability

Declaration

Declaration is a language construct that creates a variable or function. An example of this is.

How to Play Rummy Card Game - Rummy Rules & Guide To Play Rummy

Operator

Operators are constructs defined in programming languages that behave generally like functions, but are syntactically different.

Operator in Java programming language - Code for Java c

Class

A class is a program-code-template for creating objects, providing initial values for state and implementations of behavior.

Object-oriented Programming (OOP) in C++

Function

A function is a block of organised, reusable code that is used to perform a single, related action.

Encapsulation

In computer programming languages, the notion of encapsulation refers to the bundling of data, along with the methods that operate on that data, into a single unit.

Variables

variables are names used to hold one or more values. Instead of repeating these values, the variable holds the results of a calculation, database call, results of a database query, or other value. Examples of these are strings and bools (as mentioned below), chars,

examples of these could be; Player health, Player damage, Player Level, Enemy health etc.

String

Strings can contain any sequence of characters. They’re used to store text information. Examples of this can be any text in games, such as character name’s, character speech or any other words in a game.

Bool

Bool’s store true or false information. This can be whether a character is dead or not, whether the player has pressed a button or not and whether a player has reached a trigger or not.

Conditional

Conditional statements are the byproduct of booleans. conditional statements perform different actions depending on whether a programmer-specified boolean condition evaluates to true or false. This can be anything, the examples given previous or other.

Loops and Arrays

An array is essentially a set of variables laid out sequentially in memory. For example, to store player lives for multiple players we simply type:

int[] lives = new int [3]

so if lives[0] = 7 the int lives [0] but contains 7

Arrays always begin at 0

Menu Blog Task

Revision top 3:

Loops and Arrays

If a code has new int [16], it simply means an array with 16 integers. This is the same with any amount (within system memory). All arrays begin at 0! This means we start counting from 0 instead of 1 when creating an array.

25 Questions

1.) What are matrices?

2.) Name 5 examples of variables

3.) What is a while loop?

4.)What method do we use to work out dot products?

5.)What is 18 in binary?

6.)What is the base system of hexadecimal

7.)Name 3 classes

8.) What is the cross product?

9.) What is the formula/formulas in trigonometry?

10.) What are vectors?