Activity Diagrams

We were introduced to activity diagrams in yesterdays lesson , an activity diagram is basically another word for flow charts and as did flow charts in computer science I understand the concept of them and how they work. We were given a few  on the board as a class to work out. We also were educated on what each shape stands for.

You start off with a whole circle , the circle indicates a start to the diagram , a real life situation would be waking up on a morning. then you have an arrow indicating transition to the next process this could be walking to the bus stop (lets skip out putting clothes on ,  washing and stuff you know why not right) then you have a diamond , diamonds represent decisions  , this could be what bus you are going to get at the bus stop , the bus journey would be another arrow transition , finally you would have a dot with a circle around it this is the end of the diagram and represents the closing of the process.

Here is a diagram of the symbols that may help explain it better  :

So now that we have covered what activity diagrams are , the next stage was making our own diagrams then creating them as code to make something take place within a game. We can also use this code for personal projects later on in the future .

I paired up with another member of the class and we decided to make a mini game in which there would be tiles and you have to jump on them and certain ones would be bad tiles and a bad tile would disappear on collision with the player and you would fall and die then be game over however if you succeeded to get to the other side you win.

Here is my code for the game :

First I start with adding in the cameras

 public GameObject cameraLoss;
 public GameObject cameraWin;

Then I had to make sure the cameras did not project on to the screen at the start of the game and so that you can only see the camera if it is called in.

void Start(){
cameraLoss.SetActive(false);
cameraWin.SetActive(false);
}

Finally I have the code that checks collision with tiles , in the code it checks for the tag of the object it makes contact with , one check is a bad tile  , the floor and finally the end platform (goal) , the bad tile will delete upon contact with the player , the floor will destroy you and activate the game over screen then last is the goal / end point which will destroy you and go to the win screen.

void OnCollisionEnter (Collision col)
{
 if (col.gameObject.tag == “Bad Tile”)
{

Destroy (col.gameObject);
}
 if (col.gameObject.tag == “Floor”)
{
cameraLoss.SetActive(true);
Destroy (gameObject);
}
 if (col.gameObject.tag == “Goal”)
{
cameraWin.SetActive(true);
Destroy (gameObject);
}
}

Here is some GIF’s of the game in action :

  1. hitting a bad tile and then falling to floor and lose .

bad tile gif.gif

2. Reaching the end and winning .

win gif

 

 

Leave a comment